[][src]Struct libp2p_kad::Addresses

pub struct Addresses { /* fields omitted */ }

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


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).

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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>,