cargo clippy --fix

This switches to inlining variable names into format args. clippy
now suggests this syntax, and I like it.
This commit is contained in:
Scott Lamb
2023-01-29 15:01:19 -08:00
parent 159e426943
commit a9430464b6
31 changed files with 119 additions and 162 deletions

View File

@@ -91,7 +91,7 @@ impl Service {
Some(o) => o.id,
};
let camera = db.get_camera(uuid).ok_or_else(|| {
plain_response(StatusCode::NOT_FOUND, format!("no such camera {}", uuid))
plain_response(StatusCode::NOT_FOUND, format!("no such camera {uuid}"))
})?;
stream_id = camera.streams[stream_type.index()].ok_or_else(|| {
format_err_t!(NotFound, "no such stream {}/{}", uuid, stream_type)

View File

@@ -366,7 +366,7 @@ impl Service {
let db = self.db.lock();
let camera = db
.get_camera(uuid)
.ok_or_else(|| not_found(format!("no such camera {}", uuid)))?;
.ok_or_else(|| not_found(format!("no such camera {uuid}")))?;
serve_json(
req,
&json::Camera::wrap(camera, &db, true, false).map_err(internal_server_err)?,
@@ -412,12 +412,12 @@ impl Service {
video_sample_entries: (&db, Vec::new()),
};
let camera = db.get_camera(uuid).ok_or_else(|| {
plain_response(StatusCode::NOT_FOUND, format!("no such camera {}", uuid))
plain_response(StatusCode::NOT_FOUND, format!("no such camera {uuid}"))
})?;
let stream_id = camera.streams[type_.index()].ok_or_else(|| {
plain_response(
StatusCode::NOT_FOUND,
format!("no such stream {}/{}", uuid, type_),
format!("no such stream {uuid}/{type_}"),
)
})?;
db.list_aggregated_recordings(stream_id, r, split, &mut |row| {
@@ -464,7 +464,7 @@ impl Service {
.build(self.db.clone(), self.dirs_by_stream_id.clone())
.map_err(from_base_error)?;
if debug {
Ok(plain_response(StatusCode::OK, format!("{:#?}", mp4)))
Ok(plain_response(StatusCode::OK, format!("{mp4:#?}")))
} else {
Ok(http_serve::serve(mp4, req))
}

View File

@@ -275,14 +275,11 @@ mod tests {
| (SessionFlag::SameSite as i32)
| (SessionFlag::SameSiteStrict as i32)
),
format!(
"s={}; HttpOnly; Secure; SameSite=Strict; Max-Age=2147483648; Path=/",
s64
)
format!("s={s64}; HttpOnly; Secure; SameSite=Strict; Max-Age=2147483648; Path=/")
);
assert_eq!(
encode_sid(s, SessionFlag::SameSite as i32),
format!("s={}; SameSite=Lax; Max-Age=2147483648; Path=/", s64)
format!("s={s64}; SameSite=Lax; Max-Age=2147483648; Path=/")
);
}

View File

@@ -46,10 +46,10 @@ impl Service {
let db = self.db.lock();
let camera = db
.get_camera(uuid)
.ok_or_else(|| not_found(format!("no such camera {}", uuid)))?;
.ok_or_else(|| not_found(format!("no such camera {uuid}")))?;
camera_name = camera.short_name.clone();
stream_id = camera.streams[stream_type.index()]
.ok_or_else(|| not_found(format!("no such stream {}/{}", uuid, stream_type)))?;
.ok_or_else(|| not_found(format!("no such stream {uuid}/{stream_type}")))?;
};
let mut start_time_for_filename = None;
let mut builder = mp4::FileBuilder::new(mp4_type);
@@ -61,7 +61,7 @@ impl Service {
let s = Segments::from_str(value).map_err(|()| {
plain_response(
StatusCode::BAD_REQUEST,
format!("invalid s parameter: {}", value),
format!("invalid s parameter: {value}"),
)
})?;
trace!("stream_view_mp4: appending s={:?}", s);
@@ -177,7 +177,7 @@ impl Service {
"ts" => builder
.include_timestamp_subtitle_track(value == "true")
.map_err(from_base_error)?,
_ => return Err(bad_req(format!("parameter {} not understood", key))),
_ => return Err(bad_req(format!("parameter {key} not understood"))),
}
}
}
@@ -210,7 +210,7 @@ impl Service {
.build(self.db.clone(), self.dirs_by_stream_id.clone())
.map_err(from_base_error)?;
if debug {
return Ok(plain_response(StatusCode::OK, format!("{:#?}", mp4)));
return Ok(plain_response(StatusCode::OK, format!("{mp4:#?}")));
}
Ok(http_serve::serve(mp4, req))
}