summaryrefslogtreecommitdiffstats
path: root/src/sandbox/wire.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sandbox/wire.rs')
-rw-r--r--src/sandbox/wire.rs9
1 files changed, 4 insertions, 5 deletions
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<Option<Frame>> {
}
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));