Struct sc_service::config::Multiaddr[]

pub struct Multiaddr { /* fields omitted */ }
Expand description

Representation of a Multiaddr.

Implementations

Create a new, empty multiaddress.

Create a new, empty multiaddress with the given capacity.

Return the length in bytes of this multiaddress.

Returns true if the length of this multiaddress is 0.

Return a copy of this Multiaddr’s byte representation.

Adds an already-parsed address component to the end of this multiaddr.

Examples

use parity_multiaddr::{Multiaddr, Protocol};

let mut address: Multiaddr = "/ip4/127.0.0.1".parse().unwrap();
address.push(Protocol::Tcp(10000));
assert_eq!(address, "/ip4/127.0.0.1/tcp/10000".parse().unwrap());

Pops the last Protocol of this multiaddr, or None if the multiaddr is empty.

use parity_multiaddr::{Multiaddr, Protocol};

let mut address: Multiaddr = "/ip4/127.0.0.1/udt/sctp/5678".parse().unwrap();

assert_eq!(address.pop().unwrap(), Protocol::Sctp(5678));
assert_eq!(address.pop().unwrap(), Protocol::Udt);

Like Multiaddr::push but consumes self.

Returns the components of this multiaddress.

Example

use std::net::Ipv4Addr;
use parity_multiaddr::{Multiaddr, Protocol};

let address: Multiaddr = "/ip4/127.0.0.1/udt/sctp/5678".parse().unwrap();

let components = address.iter().collect::<Vec<_>>();
assert_eq!(components[0], Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1)));
assert_eq!(components[1], Protocol::Udt);
assert_eq!(components[2], Protocol::Sctp(5678));

Replace a [Protocol] at some position in this Multiaddr.

The parameter at denotes the index of the protocol at which the function by will be applied to the current protocol, returning an optional replacement.

If at is out of bounds or by does not yield a replacement value, None will be returned. Otherwise a copy of this Multiaddr with the updated Protocol at position at will be returned.

Checks whether the given Multiaddr is a suffix of this Multiaddr.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Convert a Multiaddr to a string

Example

use parity_multiaddr::Multiaddr;

let address: Multiaddr = "/ip4/127.0.0.1/udt".parse().unwrap();
assert_eq!(address.to_string(), "/ip4/127.0.0.1/udt");

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. Read more

The associated error which can be returned from parsing.

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

Feeds this value into the given Hasher. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

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

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

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

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

Performs the conversion.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The protocol name as bytes. Transmitted on the network. Read more

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

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

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.

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

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