Struct sc_service::config::Multiaddr [−]
pub struct Multiaddr { /* fields omitted */ }
Expand description
Representation of a Multiaddr.
Implementations
impl Multiaddr
impl Multiaddr
pub fn with_capacity(n: usize) -> Multiaddr
pub fn with_capacity(n: usize) -> Multiaddr
Create a new, empty multiaddress with the given capacity.
pub fn push(&mut self, p: Protocol<'_>)
pub fn push(&mut self, p: Protocol<'_>)
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
.
pub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
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.
Trait Implementations
impl<'de> Deserialize<'de> for Multiaddr
impl<'de> Deserialize<'de> for Multiaddr
pub fn deserialize<D>(
deserializer: D
) -> Result<Multiaddr, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<Multiaddr, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a> FromIterator<Protocol<'a>> for Multiaddr
impl<'a> FromIterator<Protocol<'a>> for Multiaddr
pub fn from_iter<T>(iter: T) -> Multiaddr where
T: IntoIterator<Item = Protocol<'a>>,
pub fn from_iter<T>(iter: T) -> Multiaddr where
T: IntoIterator<Item = Protocol<'a>>,
Creates a value from an iterator. Read more
impl<'a> IntoIterator for &'a Multiaddr
impl<'a> IntoIterator for &'a Multiaddr
impl PartialOrd<Multiaddr> for Multiaddr
impl PartialOrd<Multiaddr> for Multiaddr
pub fn partial_cmp(&self, other: &Multiaddr) -> Option<Ordering>
pub fn partial_cmp(&self, other: &Multiaddr) -> Option<Ordering>
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
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralEq for Multiaddr
impl StructuralPartialEq for Multiaddr
Auto Trait Implementations
impl RefUnwindSafe for Multiaddr
impl UnwindSafe for Multiaddr
Blanket Implementations
pub fn as_byte_slice(&self) -> &[u8]
pub fn as_slice_of<T>(&self) -> Result<&[T], Error> where
T: FromByteSlice,
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
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
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn protocol_name(&self) -> &[u8]
pub fn protocol_name(&self) -> &[u8]
The protocol name as bytes. Transmitted on the network. Read more
type Output = T
type Output = T
Should always be Self
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
pub fn vzip(self) -> V
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
impl<T> MaybeDebug for T where
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,