[][src]Enum susyp2p::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, impl FnOnce(T) -> U>(
    self,
    f: impl FnOnce(T) -> U
) -> ListenerEvent<U> where
    impl FnOnce(T) -> U: FnOnce(T) -> 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 for ListenerEvent<T> where
    T: Clone
[src]

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

Performs copy-assignment from source. Read more

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

impl<T> PartialEq<ListenerEvent<T>> for ListenerEvent<T> where
    T: PartialEq<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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto 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> Borrow for T where
    T: ?Sized
[src]

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

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

impl<T> Same for T

type Output = T

Should always be Self

impl<T> Erased for T

impl<T> Erased for T

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.