pub struct AddressBook {
pub addresses: Vec<NetworkAddress>,
pub last_known_good: Option<NetworkAddress>,
}Expand description
Collection of network addresses for a peer
Fields§
§addresses: Vec<NetworkAddress>Primary addresses for this peer
last_known_good: Option<NetworkAddress>Last known good address
Implementations§
Source§impl AddressBook
impl AddressBook
Sourcepub fn with_address(address: NetworkAddress) -> Self
pub fn with_address(address: NetworkAddress) -> Self
Create an address book with a single address
Sourcepub fn add_address(&mut self, address: NetworkAddress)
pub fn add_address(&mut self, address: NetworkAddress)
Add an address to the book
Sourcepub fn remove_address(&mut self, address: &NetworkAddress)
pub fn remove_address(&mut self, address: &NetworkAddress)
Remove an address from the book
Sourcepub fn update_last_known_good(&mut self, address: NetworkAddress)
pub fn update_last_known_good(&mut self, address: NetworkAddress)
Update the last known good address
Sourcepub fn best_address(&self) -> Option<&NetworkAddress>
pub fn best_address(&self) -> Option<&NetworkAddress>
Get the best address to try first
Sourcepub fn addresses(&self) -> &[NetworkAddress]
pub fn addresses(&self) -> &[NetworkAddress]
Get all addresses
Trait Implementations§
Source§impl Clone for AddressBook
impl Clone for AddressBook
Source§fn clone(&self) -> AddressBook
fn clone(&self) -> AddressBook
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AddressBook
impl Debug for AddressBook
Source§impl Default for AddressBook
impl Default for AddressBook
Source§impl<'de> Deserialize<'de> for AddressBook
impl<'de> Deserialize<'de> for AddressBook
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for AddressBook
impl Display for AddressBook
Source§impl PartialEq for AddressBook
impl PartialEq for AddressBook
Source§impl Serialize for AddressBook
impl Serialize for AddressBook
impl Eq for AddressBook
impl StructuralPartialEq for AddressBook
Auto Trait Implementations§
impl Freeze for AddressBook
impl RefUnwindSafe for AddressBook
impl Send for AddressBook
impl Sync for AddressBook
impl Unpin for AddressBook
impl UnsafeUnpin for AddressBook
impl UnwindSafe for AddressBook
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.