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 Transport
s.
Variants§
NewAddress
A new address is being listened on.
Fields
listener_id: ListenerId
The listener that is listening on the new address.
AddressExpired
An address is no longer being listened on.
Fields
listener_id: ListenerId
The listener that is no longer listening on the address.
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.
ListenerClosed
A listener closed.
Fields
listener_id: ListenerId
The ID of the listener that closed.
ListenerError
A listener errored.
The listener will continue to be polled for new events and the event is for informational purposes only.
Implementations§
source§impl<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 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> Freeze for TransportEvent<TUpgr, TErr>
impl<TUpgr, TErr> RefUnwindSafe for TransportEvent<TUpgr, TErr>where
TUpgr: RefUnwindSafe,
TErr: RefUnwindSafe,
impl<TUpgr, TErr> Send for TransportEvent<TUpgr, TErr>
impl<TUpgr, TErr> Sync for TransportEvent<TUpgr, TErr>
impl<TUpgr, TErr> Unpin for TransportEvent<TUpgr, TErr>
impl<TUpgr, TErr> UnwindSafe for TransportEvent<TUpgr, TErr>where
TUpgr: UnwindSafe,
TErr: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.