pub struct MultiAddr { /* private fields */ }
Expand description

A sequence of Protocols.

Implementations§

source§

impl MultiAddr

source

pub fn new(r: Registry) -> Self

Create an empty address with an explicit protocol codec registry.

source

pub fn registry(&self) -> &Registry

Access the registry of this MultiAddr.

source

pub fn try_from_str(input: &str, r: Registry) -> Result<Self, Error>

Try to parse the given string as a multi-address.

Alternative to the corresponding TryFrom impl, accepting an explicit protocol codec registry.

source

pub fn try_from_bytes(input: &[u8], r: Registry) -> Result<Self, Error>

Try to decode the given bytes as a multi-address.

Alternative to the corresponding TryFrom impl, accepting an explicit protocol codec registry.

source

pub fn is_empty(&self) -> bool

Does this multi-address contain any protocol components?

source

pub fn len(&self) -> usize

Address length in bytes.

source

pub fn push_back<'a, P: Protocol<'a>>(&mut self, p: P) -> Result<(), Error>

Add a protocol to the end of this address.

source

pub fn push_back_value(&mut self, p: &ProtoValue<'_>) -> Result<(), Error>

Add a protocol value to the end of this address.

source

pub fn push_front<'a, P: Protocol<'a>>(&mut self, p: P) -> Result<(), Error>

Add a protocol to the front of this address.

source

pub fn push_front_value(&mut self, p: &ProtoValue<'_>) -> Result<(), Error>

Add a protocol value to the front of this address.

source

pub fn pop_back<'b>(&mut self) -> Option<ProtoValue<'b>>

Remove and return the last protocol component.

O(n) in the number of protocols.

source

pub fn pop_front(&mut self) -> Option<ProtoValue<'_>>

Remove and return the first protocol component.

source

pub fn drop_first(&mut self)

Remove the first protocol component.

source

pub fn drop_last(&mut self)

Remove the last protocol component.

O(n) in the number of protocols.

source

pub fn first(&self) -> Option<ProtoValue<'_>>

Return a reference to the first protocol component.

source

pub fn last(&self) -> Option<ProtoValue<'_>>

Return a reference to the last protocol component.

O(n) in the number of protocols.

source

pub fn iter(&self) -> ProtoIter<'_>

Get an iterator over the protocol components.

source

pub fn shrink_to_fit(&mut self)

Drop any excess capacity.

source

pub fn try_extend<'a, T>(&mut self, iter: T) -> Result<(), Error>where T: IntoIterator<Item = ProtoValue<'a>>,

Try to extend this multi-address with another sequence of protocols.

source

pub fn try_with<'a, T>(self, iter: T) -> Result<Self, Error>where T: IntoIterator<Item = ProtoValue<'a>>,

Like try_extend but moves Self.

source

pub fn matches<'a, I>(&self, start: usize, codes: I) -> boolwhere I: IntoIterator<Item = &'a Match>, I::IntoIter: ExactSizeIterator,

Check if the protocol codes match the given sequence.

source

pub fn split(&self, at: usize) -> (MultiAddr, MultiAddr)

source

pub fn concat_mut(&mut self, other: &MultiAddr) -> Result<(), Error>

source

pub fn concat(self, other: &MultiAddr) -> Result<MultiAddr, Error>

Trait Implementations§

source§

impl AsRef<[u8]> for MultiAddr

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for MultiAddr

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MultiAddr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MultiAddr

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for MultiAddr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for MultiAddr

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for MultiAddr

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> IntoIterator for &'a MultiAddr

§

type Item = ProtoValue<'a>

The type of the elements being iterated over.
§

type IntoIter = ProtoIter<'a>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq<MultiAddr> for MultiAddr

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<&[u8]> for MultiAddr

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<&str> for MultiAddr

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for MultiAddr

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<D> AsyncTryClone for Dwhere D: Clone + Sync,

source§

fn async_try_clone<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, D: 'async_trait,

Try cloning a object and return an Err in case of failure.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToHex for Twhere T: AsRef<[u8]>,

source§

fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
source§

fn encode_hex_upper<U>(&self) -> Uwhere U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more