[][src]Struct libp2p_kad::Addresses

pub struct Addresses { /* fields omitted */ }

A non-empty list of (unique) addresses of a peer in the routing table.

Implementations

impl Addresses[src]

pub fn new(addr: Multiaddr) -> Addresses[src]

Creates a new list of addresses.

pub fn first(&self) -> &Multiaddr[src]

Gets a reference to the first address in the list.

pub fn iter(&self) -> impl Iterator<Item = &Multiaddr>[src]

Returns an iterator over the addresses.

pub fn len(&self) -> usize[src]

Returns the number of addresses in the list.

pub fn into_vec(self) -> Vec<Multiaddr>[src]

Converts the addresses into a Vec.

pub fn remove(&mut self, addr: &Multiaddr) -> Result<(), ()>[src]

Removes the given address from the list.

Returns Ok(()) if the address is either not in the list or was found and removed. Returns Err(()) if the address is the last remaining address, which cannot be removed.

An address should only be removed if is determined to be invalid or otherwise unreachable.

pub fn insert(&mut self, addr: Multiaddr) -> bool[src]

Adds a new address to the end of the list.

Returns true if the address was added, false otherwise (i.e. if the address is already in the list).

pub fn replace(&mut self, old: &Multiaddr, new: &Multiaddr) -> bool[src]

Replaces an old address with a new address.

Returns true if the previous address was found and replaced with a clone of the new address, returns false otherwise.

Trait Implementations

impl Clone for Addresses[src]

impl Debug for Addresses[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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<V, T> VZip<V> for T where
    V: MultiLane<T>,