From 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 Mon Sep 17 00:00:00 2001 From: aur-build Date: Sun, 22 Nov 2026 10:36:24 +0000 Subject: rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three. --- src/sandbox/wire.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/sandbox/wire.rs') diff --git a/src/sandbox/wire.rs b/src/sandbox/wire.rs index 4ae1ec0..75fc0a5 100644 --- a/src/sandbox/wire.rs +++ b/src/sandbox/wire.rs @@ -36,8 +36,7 @@ pub(crate) enum Frame { } pub(crate) fn write_frame(w: &mut impl Write, f: &Frame) -> io::Result<()> { - let body = serde_json::to_vec(f) - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let body = serde_json::to_vec(f).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; if body.len() as u64 > MAX_FRAME_BYTES as u64 { return Err(io::Error::new(io::ErrorKind::InvalidInput, "frame too large")); } @@ -59,8 +58,7 @@ pub(crate) fn read_frame(r: &mut impl BufRead) -> io::Result> { } let mut body = vec![0u8; n]; r.read_exact(&mut body)?; - let f: Frame = serde_json::from_slice(&body) - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let f: Frame = serde_json::from_slice(&body).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; Ok(Some(f)) } @@ -79,7 +77,8 @@ mod tests { #[test] fn frames_round_trip_through_a_byte_stream() { let mut buf = Vec::new(); - write_frame(&mut buf, &Frame::Hello { token: "t".into(), agent_id: "a".into(), profiles: vec!["p".into()] }).unwrap(); + write_frame(&mut buf, &Frame::Hello { token: "t".into(), agent_id: "a".into(), profiles: vec!["p".into()] }) + .unwrap(); write_frame(&mut buf, &Frame::Log { req: 7, stream: "stdout".into(), data: hex_bytes(b"hello") }).unwrap(); write_frame(&mut buf, &Frame::Exit { req: 7, code: Some(0) }).unwrap(); let mut cur = std::io::BufReader::new(std::io::Cursor::new(buf)); -- cgit v1.2.3