buffet 0.3.3

Thread-local buffer pool for the `loona` crate.
Documentation
use std::net::SocketAddr;
use tokio::net::{TcpListener as TokListener, TcpStream as TokStream};

pub type TcpStream = TokStream;

pub type TcpReadHalf = tokio::net::tcp::OwnedReadHalf;
pub type TcpWriteHalf = tokio::net::tcp::OwnedWriteHalf;

pub struct TcpListener {
    tok: TokListener,
}

impl TcpListener {
    pub async fn bind(addr: SocketAddr) -> std::io::Result<Self> {
        let tok = TokListener::bind(addr).await?;
        Ok(Self { tok })
    }

    pub fn local_addr(&self) -> std::io::Result<SocketAddr> {
        self.tok.local_addr()
    }

    pub async fn accept(&self) -> std::io::Result<(TcpStream, SocketAddr)> {
        self.tok.accept().await.map(|tuple| {
            tuple.0.set_nodelay(true).unwrap();
            tuple
        })
    }
}