Trait NetworkStream

Source
pub trait NetworkStream:
    Read
    + Write
    + Any
    + Send
    + GetType {
    // Required methods
    fn peer_addr(&mut self) -> Result<SocketAddr>;
    fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>;
    fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>;

    // Provided method
    fn close(&mut self, _how: Shutdown) -> Result<()> { ... }
}
Expand description

An abstraction over streams that a Server can utilize.

Required Methods§

Source

fn peer_addr(&mut self) -> Result<SocketAddr>

Get the remote address of the underlying connection.

Source

fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>

Set the maximum time to wait for a read to complete.

Source

fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>

Set the maximum time to wait for a write to complete.

Provided Methods§

Source

fn close(&mut self, _how: Shutdown) -> Result<()>

This will be called when Stream should no longer be kept alive.

Implementations§

Source§

impl dyn NetworkStream

Source

pub fn is<T: Any>(&self) -> bool

Is the underlying type in this trait object a T?

Source

pub fn downcast_ref<T: Any>(&self) -> Option<&T>

If the underlying type is T, get a reference to the contained data.

Source

pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T>

If the underlying type is T, get a mutable reference to the contained data.

Source

pub fn downcast<T: Any>( self: Box<dyn NetworkStream>, ) -> Result<Box<T>, Box<dyn NetworkStream>>

If the underlying type is T, extract it.

Source§

impl dyn NetworkStream + Send

Source

pub fn is<T: Any>(&self) -> bool

Is the underlying type in this trait object a T?

Source

pub fn downcast_ref<T: Any>(&self) -> Option<&T>

If the underlying type is T, get a reference to the contained data.

Source

pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T>

If the underlying type is T, get a mutable reference to the contained data.

Source

pub fn downcast<T: Any>( self: Box<dyn NetworkStream + Send>, ) -> Result<Box<T>, Box<dyn NetworkStream + Send>>

If the underlying type is T, extract it.

Trait Implementations§

Source§

impl Debug for Box<dyn NetworkStream + Send>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: NetworkStream + Send> From<T> for Box<dyn NetworkStream + Send>

Source§

fn from(s: T) -> Box<dyn NetworkStream + Send>

Converts to this type from the input type.

Implementors§