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.