use crate::{codec::Codec, context::Context, transport::Result}; pub trait PacketSender: Send + Sync { fn send>(&self, packet: P, ctx: &Context) -> Result<()>; } pub trait PacketSenderBuf: Send + Sync { fn send_buf(&self, buf: &[u8]) -> Result<()>; } impl> PacketSender for S { fn send>(&self, packet: P, ctx: &Context) -> Result<()> { let mut buf = Vec::new(); packet.encode(&mut buf, ctx)?; self.send_buf(&buf) } }