Mplex

Struct Mplex 

Source
pub struct Mplex<C> {
    pub la: Multiaddr,
    pub ra: Multiaddr,
    pub local_priv_key: Keypair,
    pub local_peer_id: PeerId,
    pub remote_pub_key: PublicKey,
    pub remote_peer_id: PeerId,
    /* private fields */
}
Expand description

A Mplex connection.

This implementation isn’t capable of detecting when the underlying socket changes its address, and no [StreamMuxerEvent::AddressChange] event is ever emitted.

Fields§

§la: Multiaddr

The secure&connection info provided by underlying socket. The socket is moved into Connection, so we have to make a copy of these information

The local multiaddr of this connection

§ra: Multiaddr

The remote multiaddr of this connection

§local_priv_key: Keypair

The private key of the local

§local_peer_id: PeerId

For convenience, the local peer ID, generated from local pub key

§remote_pub_key: PublicKey

The public key of the remote.

§remote_peer_id: PeerId

For convenience, put a PeerId here, which is actually calculated from remote_key

Implementations§

Source§

impl<C: ConnectionInfo + SecureInfo + AsyncRead + AsyncWrite + Send + Unpin + 'static> Mplex<C>

Source

pub fn new(io: C) -> Self

Trait Implementations§

Source§

impl<C> Clone for Mplex<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Send> ConnectionInfo for Mplex<C>

Source§

impl<C> Debug for Mplex<C>

Source§

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

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

impl<C> SecureInfo for Mplex<C>

Source§

impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> StreamMuxer for Mplex<C>

Source§

fn open_stream<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<IReadWrite, TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Opens a new outgoing substream.
Source§

fn accept_stream<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<IReadWrite, TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accepts a new incoming substream.
Source§

fn close<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Closes the stream muxer, the runtime of stream muxer will then exit.
Source§

fn task(&mut self) -> Option<BoxFuture<'static, ()>>

Returns a Future which represents the main loop of the stream muxer.
Source§

fn box_clone(&self) -> IStreamMuxer

Returns the cloned Trait object.
Source§

impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> StreamMuxerEx for Mplex<C>

Auto Trait Implementations§

§

impl<C> Freeze for Mplex<C>

§

impl<C> !RefUnwindSafe for Mplex<C>

§

impl<C> Send for Mplex<C>
where C: Send,

§

impl<C> Sync for Mplex<C>
where C: Send,

§

impl<C> Unpin for Mplex<C>

§

impl<C> !UnwindSafe for Mplex<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V