udp_pool/
sender.rs

1#[derive(Debug)]
2pub struct Sender {
3    tx: crate::UdpTx,
4}
5
6impl Sender {
7    pub fn new(tx: super::UdpTx) -> Self {
8        Sender { tx }
9    }
10
11    pub async fn send(&self, data: bytes::BytesMut) -> Result<(), net_pool::error::Error> {
12        self.tx
13            .send(data)
14            .await
15            .map_err(|e| net_pool::error::Error::from_other(e))
16    }
17
18    pub fn is_closed(&self) -> bool {
19        self.tx.is_closed()
20    }
21}