Skip to main content

NetworkStreamControl

Trait NetworkStreamControl 

pub trait NetworkStreamControl: Debug {
    // Required methods
    fn accept(
        self,
    ) -> Result<impl Stream<Item = (PeerId, impl AsyncRead + AsyncWrite + Send)> + Send, impl Error>;
    fn open<'async_trait>(
        self,
        peer: PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<impl AsyncRead + AsyncWrite + Send, impl Error>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Control object for the opening and receiving of network connections in the form of network streams.

Required Methods§

fn accept( self, ) -> Result<impl Stream<Item = (PeerId, impl AsyncRead + AsyncWrite + Send)> + Send, impl Error>

Starts accepting incoming streams.

Each stream item yields the remote peer identifier and the opened stream.

fn open<'async_trait>( self, peer: PeerId, ) -> Pin<Box<dyn Future<Output = Result<impl AsyncRead + AsyncWrite + Send, impl Error>> + Send + 'async_trait>>
where Self: 'async_trait,

Opens a new outbound stream to the given peer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§