[][src]Enum libp2p_core::transport::ListenerEvent

pub enum ListenerEvent<T> {
    NewAddress(Multiaddr),
    Upgrade {
        upgrade: T,
        listen_addr: Multiaddr,
        remote_addr: Multiaddr,
    },
    AddressExpired(Multiaddr),
}

Event produced by Transport::Listeners.

Transports are expected to produce Upgrade events only for listen addresses which have previously been announced via a NewAddress event and which have not been invalidated by an AddressExpired event yet.

Variants

NewAddress(Multiaddr)

The transport is listening on a new additional Multiaddr.

Upgrade

An upgrade, consisting of the upgrade future, the listener address and the remote address.

Fields of Upgrade

upgrade: T

The upgrade.

listen_addr: Multiaddr

The listening address which produced this upgrade.

remote_addr: Multiaddr

The remote address which produced this upgrade.

AddressExpired(Multiaddr)

A Multiaddr is no longer used for listening.

Methods

impl<T> ListenerEvent<T>[src]

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ListenerEvent<U>[src]

In case this ListenerEvent is an upgrade, apply the given function to the upgrade and multiaddress and produce another listener event based the the function's result.

pub fn is_upgrade(&self) -> bool[src]

Returns true if this is an Upgrade listener event.

pub fn into_upgrade(self) -> Option<(T, Multiaddr)>[src]

Try to turn this listener event into upgrade parts.

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

pub fn is_new_address(&self) -> bool[src]

Returns true if this is a NewAddress listener event.

pub fn into_new_address(self) -> Option<Multiaddr>[src]

Try to turn this listener event into the NewAddress part.

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

pub fn is_address_expired(&self) -> bool[src]

Returns true if this is an AddressExpired listener event.

pub fn into_address_expired(self) -> Option<Multiaddr>[src]

Try to turn this listener event into the AddressExpired part.

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

Trait Implementations

impl<T: Clone> Clone for ListenerEvent<T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: PartialEq> PartialEq<ListenerEvent<T>> for ListenerEvent<T>[src]

impl<T: Debug> Debug for ListenerEvent<T>[src]

Auto Trait Implementations

impl<T> Send for ListenerEvent<T> where
    T: Send

impl<T> Sync for ListenerEvent<T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T