Struct sc_service::config::Multiaddr
pub struct Multiaddr { /* private fields */ }
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 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());
pub fn pop<'a>(&mut self) -> Option<Protocol<'a>>
pub fn pop<'a>(&mut self) -> Option<Protocol<'a>>
Pops the last Protocol
of this multiaddr, or None
if the multiaddr is empty.
use 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);
pub fn with(self, p: Protocol<'_>) -> Multiaddr
pub fn with(self, p: Protocol<'_>) -> Multiaddr
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 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));
pub fn replace<'a, F>(&self, at: usize, by: F) -> Option<Multiaddr>where
F: FnOnce(&Protocol<'_>) -> Option<Protocol<'a>>,
pub fn replace<'a, F>(&self, at: usize, by: F) -> Option<Multiaddr>where F: FnOnce(&Protocol<'_>) -> Option<Protocol<'a>>,
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.
pub fn ends_with(&self, other: &Multiaddr) -> bool
pub fn ends_with(&self, other: &Multiaddr) -> bool
Checks whether the given Multiaddr
is a suffix of this Multiaddr
.
pub fn protocol_stack(&self) -> ProtoStackIter<'_>
pub fn protocol_stack(&self) -> ProtoStackIter<'_>
Returns &str identifiers for the protocol names themselves.
This omits specific info like addresses, ports, peer IDs, and the like.
Example: "/ip4/127.0.0.1/tcp/5001"
would return ["ip4", "tcp"]
Trait Implementations§
§impl<'de> Deserialize<'de> for Multiaddr
impl<'de> Deserialize<'de> for Multiaddr
§fn deserialize<D>(
deserializer: D
) -> Result<Multiaddr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>( deserializer: D ) -> Result<Multiaddr, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
§impl<'a> FromIterator<Protocol<'a>> for Multiaddr
impl<'a> FromIterator<Protocol<'a>> for Multiaddr
§fn from_iter<T>(iter: T) -> Multiaddrwhere
T: IntoIterator<Item = Protocol<'a>>,
fn from_iter<T>(iter: T) -> Multiaddrwhere T: IntoIterator<Item = Protocol<'a>>,
§impl<'a> IntoIterator for &'a Multiaddr
impl<'a> IntoIterator for &'a Multiaddr
§impl Ord for Multiaddr
impl Ord for Multiaddr
§impl PartialOrd<Multiaddr> for Multiaddr
impl PartialOrd<Multiaddr> for Multiaddr
§fn partial_cmp(&self, other: &Multiaddr) -> Option<Ordering>
fn partial_cmp(&self, other: &Multiaddr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl Serialize for Multiaddr
impl Serialize for Multiaddr
§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
impl Eq for Multiaddr
impl StructuralEq for Multiaddr
impl StructuralPartialEq for Multiaddr
Auto Trait Implementations§
impl RefUnwindSafe for Multiaddr
impl Send for Multiaddr
impl Sync for Multiaddr
impl Unpin for Multiaddr
impl UnwindSafe for Multiaddr
Blanket Implementations§
§impl<T, U> AsByteSlice<T> for Uwhere
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
impl<T, U> AsByteSlice<T> for Uwhere T: ToByteSlice, U: AsRef<[T]> + ?Sized,
fn as_byte_slice(&self) -> &[u8] ⓘ
§impl<U> AsSliceOf for Uwhere
U: AsRef<[u8]> + ?Sized,
impl<U> AsSliceOf for Uwhere U: AsRef<[u8]> + ?Sized,
fn as_slice_of<T>(&self) -> Result<&[T], Error>where T: FromByteSlice,
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ProtocolName for Twhere
T: AsRef<[u8]>,
impl<T> ProtocolName for Twhere T: AsRef<[u8]>,
§fn protocol_name(&self) -> &[u8] ⓘ
fn protocol_name(&self) -> &[u8] ⓘ
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere T: AsRef<[u8]>,
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.