Enum libp2p_core::transport::TransportEvent
source · [−]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
Fields
listener_id: ListenerIdThe listener that is listening on the new address.
listen_addr: MultiaddrThe new address that is being listened on.
A new address is being listened on.
AddressExpired
Fields
listener_id: ListenerIdThe listener that is no longer listening on the address.
listen_addr: MultiaddrThe new address that is being listened on.
An address is no longer being listened on.
Incoming
Fields
listener_id: ListenerIdThe listener that produced the upgrade.
local_addr: MultiaddrLocal connection address.
send_back_addr: MultiaddrAddress used to send back data to the incoming client.
A connection is incoming on one of the listeners.
ListenerClosed
Fields
listener_id: ListenerIdThe ID of the listener that closed.
A listener closed.
ListenerError
A listener errored.
The listener will continue to be polled for new events and the event is for informational purposes only.
Implementations
sourceimpl<TUpgr, TErr> TransportEvent<TUpgr, TErr>
impl<TUpgr, TErr> TransportEvent<TUpgr, TErr>
sourcepub fn map_upgrade<U>(
self,
map: impl FnOnce(TUpgr) -> U
) -> TransportEvent<U, 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 the function’s result.
sourcepub fn map_err<E>(
self,
map_err: impl FnOnce(TErr) -> E
) -> TransportEvent<TUpgr, E>
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.
sourcepub fn is_upgrade(&self) -> bool
pub fn is_upgrade(&self) -> bool
Returns true if this is an Incoming transport event.
sourcepub fn into_incoming(self) -> Option<(TUpgr, Multiaddr)>
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.
sourcepub fn is_new_address(&self) -> bool
pub fn is_new_address(&self) -> bool
Returns true if this is a TransportEvent::NewAddress.
sourcepub fn into_new_address(self) -> Option<Multiaddr>
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.
sourcepub fn is_address_expired(&self) -> bool
pub fn is_address_expired(&self) -> bool
Returns true if this is an TransportEvent::AddressExpired.
sourcepub fn into_address_expired(self) -> Option<Multiaddr>
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.
sourcepub fn is_listener_error(&self) -> bool
pub fn is_listener_error(&self) -> bool
Returns true if this is an TransportEvent::ListenerError transport event.
sourcepub fn into_listener_error(self) -> Option<TErr>
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
Auto Trait Implementations
impl<TUpgr, TErr> RefUnwindSafe for TransportEvent<TUpgr, TErr>where
TErr: RefUnwindSafe,
TUpgr: RefUnwindSafe,
impl<TUpgr, TErr> Send for TransportEvent<TUpgr, TErr>where
TErr: Send,
TUpgr: Send,
impl<TUpgr, TErr> Sync for TransportEvent<TUpgr, TErr>where
TErr: Sync,
TUpgr: Sync,
impl<TUpgr, TErr> Unpin for TransportEvent<TUpgr, TErr>where
TErr: Unpin,
TUpgr: Unpin,
impl<TUpgr, TErr> UnwindSafe for TransportEvent<TUpgr, TErr>where
TErr: UnwindSafe,
TUpgr: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more