(
msg: &T,
dst: &mut (impl AsyncWrite + Unpin),
)
| 21 | } |
| 22 | |
| 23 | pub async fn write_message<T: Serialize>( |
| 24 | msg: &T, |
| 25 | dst: &mut (impl AsyncWrite + Unpin), |
| 26 | ) -> std::io::Result<()> { |
| 27 | let encoded = serde_json::to_string(msg)?; |
| 28 | assert!(encoded.len() < 0xffffffff); |
| 29 | |
| 30 | dst.write_u32(encoded.len() as u32).await?; |
| 31 | dst.write_all(encoded.as_bytes()).await?; |
| 32 | |
| 33 | Ok(()) |
| 34 | } |
| 35 | |
| 36 | pub async fn message_writer<T: Serialize>( |
| 37 | dst: &mut (impl AsyncWrite + Unpin), |
no outgoing calls
no test coverage detected