libp2p::core::transport

Enum TransportEvent

pub enum TransportEvent<TUpgr, TErr> {
    NewAddress {
        listener_id: ListenerId,
        listen_addr: Multiaddr,
    },
    AddressExpired {
        listener_id: ListenerId,
        listen_addr: Multiaddr,
    },
    Incoming {
        listener_id: ListenerId,
        upgrade: TUpgr,
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
    },
    ListenerClosed {
        listener_id: ListenerId,
        reason: Result<(), TErr>,
    },
    ListenerError {
        listener_id: ListenerId,
        error: TErr,
    },
}
Expand description

Event produced by Transports.

Variants§

§

NewAddress

A new address is being listened on.

Fields

§listener_id: ListenerId

The listener that is listening on the new address.

§listen_addr: Multiaddr

The new address that is being listened on.

§

AddressExpired

An address is no longer being listened on.

Fields

§listener_id: ListenerId

The listener that is no longer listening on the address.

§listen_addr: Multiaddr

The new address that is being listened on.

§

Incoming

A connection is incoming on one of the listeners.

Fields

§listener_id: ListenerId

The listener that produced the upgrade.

§upgrade: TUpgr

The produced upgrade.

§local_addr: Multiaddr

Local connection address.

§send_back_addr: Multiaddr

Address used to send back data to the incoming client.

§

ListenerClosed

A listener closed.

Fields

§listener_id: ListenerId

The ID of the listener that closed.

§reason: Result<(), TErr>

Reason for the closure. Contains Ok(()) if the stream produced None, or Err if the stream produced an error.

§

ListenerError

A listener errored.

The listener will continue to be polled for new events and the event is for informational purposes only.

Fields

§listener_id: ListenerId

The ID of the listener that errored.

§error: TErr

The error value.

Implementations§

§

impl<TUpgr, TErr> TransportEvent<TUpgr, TErr>

pub fn map_upgrade<U>( self, map: impl FnOnce(TUpgr) -> U, ) -> TransportEvent<U, TErr>

In case this TransportEvent is an upgrade, apply the given function to the upgrade and produce another transport event based the function’s result.

pub fn map_err<E>( self, map_err: impl FnOnce(TErr) -> E, ) -> TransportEvent<TUpgr, E>

In case this TransportEvent is an ListenerError, or ListenerClosed apply the given function to the error and produce another transport event based on the function’s result.

pub fn is_upgrade(&self) -> bool

Returns true if this is an Incoming transport event.

pub fn into_incoming(self) -> Option<(TUpgr, Multiaddr)>

Try to turn this transport event into the upgrade parts of the incoming connection.

Returns None if the event is not actually an incoming connection, otherwise the upgrade and the remote address.

pub fn is_new_address(&self) -> bool

Returns true if this is a TransportEvent::NewAddress.

pub fn into_new_address(self) -> Option<Multiaddr>

Try to turn this transport event into the new Multiaddr.

Returns None if the event is not actually a TransportEvent::NewAddress, otherwise the address.

pub fn is_address_expired(&self) -> bool

Returns true if this is an TransportEvent::AddressExpired.

pub fn into_address_expired(self) -> Option<Multiaddr>

Try to turn this transport event into the expire Multiaddr.

Returns None if the event is not actually a TransportEvent::AddressExpired, otherwise the address.

pub fn is_listener_error(&self) -> bool

Returns true if this is an TransportEvent::ListenerError transport event.

pub fn into_listener_error(self) -> Option<TErr>

Try to turn this transport event into the listener error.

Returns None if the event is not actually a TransportEvent::ListenerError`, otherwise the error.

Trait Implementations§

§

impl<TUpgr, TErr> Debug for TransportEvent<TUpgr, TErr>
where TErr: Debug,

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TUpgr, TErr> Freeze for TransportEvent<TUpgr, TErr>
where TUpgr: Freeze, TErr: Freeze,

§

impl<TUpgr, TErr> RefUnwindSafe for TransportEvent<TUpgr, TErr>
where TUpgr: RefUnwindSafe, TErr: RefUnwindSafe,

§

impl<TUpgr, TErr> Send for TransportEvent<TUpgr, TErr>
where TUpgr: Send, TErr: Send,

§

impl<TUpgr, TErr> Sync for TransportEvent<TUpgr, TErr>
where TUpgr: Sync, TErr: Sync,

§

impl<TUpgr, TErr> Unpin for TransportEvent<TUpgr, TErr>
where TUpgr: Unpin, TErr: Unpin,

§

impl<TUpgr, TErr> UnwindSafe for TransportEvent<TUpgr, TErr>
where TUpgr: UnwindSafe, TErr: UnwindSafe,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T