(reader: &mut R)
| 494 | // ============================================================================= |
| 495 | |
| 496 | fn read_message<R: Read, T: for<'de> Deserialize<'de>>(reader: &mut R) -> io::Result<T> { |
| 497 | let mut len_buf = [0u8; 4]; |
| 498 | reader.read_exact(&mut len_buf)?; |
| 499 | let len = u32::from_le_bytes(len_buf) as usize; |
| 500 | let mut buf = vec![0u8; len]; |
| 501 | reader.read_exact(&mut buf)?; |
| 502 | bincode::deserialize(&buf).map_err(io::Error::other) |
| 503 | } |
| 504 | |
| 505 | fn write_message<W: Write, T: Serialize>(writer: &mut W, msg: &T) -> io::Result<()> { |
| 506 | let bytes = bincode::serialize(msg).map_err(io::Error::other)?; |
no outgoing calls