pub trait NetworkStream:
Read
+ Write
+ Any
+ Send
+ Typeable {
// Required methods
fn peer_addr(&mut self) -> Result<SocketAddr, Error>;
fn set_read_timeout(&self, dur: Option<Duration>) -> Result<(), Error>;
fn set_write_timeout(&self, dur: Option<Duration>) -> Result<(), Error>;
// Provided method
fn close(&mut self, _how: Shutdown) -> Result<(), Error> { ... }
}
Expand description
An abstraction over streams that a Server
can utilize.
Required Methods§
Sourcefn peer_addr(&mut self) -> Result<SocketAddr, Error>
fn peer_addr(&mut self) -> Result<SocketAddr, Error>
Get the remote address of the underlying connection.
Provided Methods§
Implementations§
Source§impl dyn NetworkStream
impl dyn NetworkStream
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: Any,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: Any,
If the underlying type is T
, get a reference to the contained data.
Sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
If the underlying type is T
, get a mutable reference to the contained
data.
Sourcepub fn downcast<T>(
self: Box<dyn NetworkStream>,
) -> Result<Box<T>, Box<dyn NetworkStream>>where
T: Any,
pub fn downcast<T>(
self: Box<dyn NetworkStream>,
) -> Result<Box<T>, Box<dyn NetworkStream>>where
T: Any,
If the underlying type is T
, extract it.
Source§impl dyn NetworkStream + Send
impl dyn NetworkStream + Send
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: Any,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: Any,
If the underlying type is T
, get a reference to the contained data.
Sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: Any,
If the underlying type is T
, get a mutable reference to the contained
data.