use std::io::Result as IoResult;
use std::net::{SocketAddr, Shutdown};
use mio::net::TcpStream as MioTcpStream;
#[derive(Debug)]
pub struct TcpConnection {
stream: MioTcpStream,
}
impl TcpConnection {
pub(crate) fn new(stream: MioTcpStream) -> Self {
Self {
stream,
}
}
pub(crate) fn stream(self) -> MioTcpStream {
self.stream
}
pub fn peer_addr(&self) -> Option<SocketAddr> {
self.stream.peer_addr().ok()
}
pub fn local_addr(&self) -> Option<SocketAddr> {
self.stream.local_addr().ok()
}
pub fn shutdown(&self, how: Shutdown) -> IoResult<()> {
self.stream.shutdown(how)
}
}