pub enum ListenerEvent<TUpgr, TErr> {
NewAddress(Multiaddr),
Upgrade {
upgrade: TUpgr,
local_addr: Multiaddr,
remote_addr: Multiaddr,
},
AddressExpired(Multiaddr),
Error(TErr),
}
Expand description
Event produced by Transport::Listener
s.
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
Fields
local_addr: Multiaddr
The local address which produced this upgrade.
remote_addr: Multiaddr
The remote address which produced this upgrade.
An upgrade, consisting of the upgrade future, the listener address and the remote address.
AddressExpired(Multiaddr)
A Multiaddr
is no longer used for listening.
Error(TErr)
A non-fatal error has happened on the listener.
This event should be generated in order to notify the user that something wrong has happened. The listener, however, continues to run.
Implementations
sourceimpl<TUpgr, TErr> ListenerEvent<TUpgr, TErr>
impl<TUpgr, TErr> ListenerEvent<TUpgr, TErr>
sourcepub fn map<U>(self, f: impl FnOnce(TUpgr) -> U) -> ListenerEvent<U, TErr>
pub fn map<U>(self, f: impl FnOnce(TUpgr) -> U) -> ListenerEvent<U, TErr>
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.
sourcepub fn map_err<U>(self, f: impl FnOnce(TErr) -> U) -> ListenerEvent<TUpgr, U>
pub fn map_err<U>(self, f: impl FnOnce(TErr) -> U) -> ListenerEvent<TUpgr, U>
In case this ListenerEvent
is an Error
,
apply the given function to the error and produce another listener 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 Upgrade
listener event.
sourcepub fn into_upgrade(self) -> Option<(TUpgr, Multiaddr)>
pub fn into_upgrade(self) -> Option<(TUpgr, Multiaddr)>
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.
sourcepub fn is_new_address(&self) -> bool
pub fn is_new_address(&self) -> bool
Returns true
if this is a NewAddress
listener event.
sourcepub fn into_new_address(self) -> Option<Multiaddr>
pub fn into_new_address(self) -> Option<Multiaddr>
Try to turn this listener event into the NewAddress
part.
Returns None
if the event is not actually a NewAddress
,
otherwise the address.
sourcepub fn is_address_expired(&self) -> bool
pub fn is_address_expired(&self) -> bool
Returns true
if this is an AddressExpired
listener event.
sourcepub fn into_address_expired(self) -> Option<Multiaddr>
pub fn into_address_expired(self) -> Option<Multiaddr>
Try to turn this listener event into the AddressExpired
part.
Returns None
if the event is not actually a AddressExpired
,
otherwise the address.
sourcepub fn into_error(self) -> Option<TErr>
pub fn into_error(self) -> Option<TErr>
Try to turn this listener event into the Error
part.
Returns None
if the event is not actually a Error
,
otherwise the error.
Trait Implementations
sourceimpl<TUpgr, TErr> Clone for ListenerEvent<TUpgr, TErr> where
TUpgr: Clone,
TErr: Clone,
impl<TUpgr, TErr> Clone for ListenerEvent<TUpgr, TErr> where
TUpgr: Clone,
TErr: Clone,
sourcepub fn clone(&self) -> ListenerEvent<TUpgr, TErr>
pub fn clone(&self) -> ListenerEvent<TUpgr, TErr>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<TUpgr, TErr> Debug for ListenerEvent<TUpgr, TErr> where
TUpgr: Debug,
TErr: Debug,
impl<TUpgr, TErr> Debug for ListenerEvent<TUpgr, TErr> where
TUpgr: Debug,
TErr: Debug,
sourceimpl<TUpgr, TErr> PartialEq<ListenerEvent<TUpgr, TErr>> for ListenerEvent<TUpgr, TErr> where
TUpgr: PartialEq<TUpgr>,
TErr: PartialEq<TErr>,
impl<TUpgr, TErr> PartialEq<ListenerEvent<TUpgr, TErr>> for ListenerEvent<TUpgr, TErr> where
TUpgr: PartialEq<TUpgr>,
TErr: PartialEq<TErr>,
sourcepub fn eq(&self, other: &ListenerEvent<TUpgr, TErr>) -> bool
pub fn eq(&self, other: &ListenerEvent<TUpgr, TErr>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcepub fn ne(&self, other: &ListenerEvent<TUpgr, TErr>) -> bool
pub fn ne(&self, other: &ListenerEvent<TUpgr, TErr>) -> bool
This method tests for !=
.
impl<TUpgr, TErr> StructuralPartialEq for ListenerEvent<TUpgr, TErr>
Auto Trait Implementations
impl<TUpgr, TErr> RefUnwindSafe for ListenerEvent<TUpgr, TErr> where
TErr: RefUnwindSafe,
TUpgr: RefUnwindSafe,
impl<TUpgr, TErr> Send for ListenerEvent<TUpgr, TErr> where
TErr: Send,
TUpgr: Send,
impl<TUpgr, TErr> Sync for ListenerEvent<TUpgr, TErr> where
TErr: Sync,
TUpgr: Sync,
impl<TUpgr, TErr> Unpin for ListenerEvent<TUpgr, TErr> where
TErr: Unpin,
TUpgr: Unpin,
impl<TUpgr, TErr> UnwindSafe for ListenerEvent<TUpgr, TErr> where
TErr: UnwindSafe,
TUpgr: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more