(&self, writer: &mut T)
| 383 | |
| 384 | impl UdpTraffic { |
| 385 | pub async fn write<T: AsyncWrite + Unpin>(&self, writer: &mut T) -> Result<()> { |
| 386 | let hdr = UdpHeader { |
| 387 | from: self.from, |
| 388 | len: self.data.len() as UdpPacketLen, |
| 389 | }; |
| 390 | |
| 391 | let v = bincode::serde::encode_to_vec(&hdr, bincode::config::legacy()).unwrap(); |
| 392 | |
| 393 | trace!("Write {:?} of length {}", hdr, v.len()); |
| 394 | writer.write_u8(v.len() as u8).await?; |
| 395 | writer.write_all(&v).await?; |
| 396 | |
| 397 | writer.write_all(&self.data).await?; |
| 398 | |
| 399 | Ok(()) |
| 400 | } |
| 401 | |
| 402 | #[allow(dead_code)] |
| 403 | pub async fn write_slice<T: AsyncWrite + Unpin>( |
no test coverage detected