Struct tentacle_multiaddr::Multiaddr [−][src]
pub struct Multiaddr { /* fields omitted */ }Representation of a Multiaddr.
Implementations
impl Multiaddr[src]
impl Multiaddr[src]pub fn push(&mut self, p: Protocol<'_>)[src]
pub fn push(&mut self, p: Protocol<'_>)[src]Adds an already-parsed address component to the end of this multiaddr.
Examples
use tentacle_multiaddr::{Multiaddr, Protocol}; let mut address: Multiaddr = "/ip4/127.0.0.1".parse().unwrap(); address.push(Protocol::Tcp(10000)); println!("{}", address); assert_eq!(address, "/ip4/127.0.0.1/tcp/10000".parse().unwrap());
pub fn pop<'a>(&mut self) -> Option<Protocol<'a>>[src]
pub fn pop<'a>(&mut self) -> Option<Protocol<'a>>[src]Pops the last Protocol of this multiaddr, or None if the multiaddr is empty.
use std::net::Ipv4Addr; use tentacle_multiaddr::{Multiaddr, Protocol}; let mut address: Multiaddr = "/ip4/127.0.0.1/tcp/5678".parse().unwrap(); assert_eq!(address.pop().unwrap(), Protocol::Tcp(5678)); assert_eq!(address.pop().unwrap(), Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1)));
pub fn iter(&self) -> Iter<'_>ⓘ[src]
pub fn iter(&self) -> Iter<'_>ⓘ[src]Returns the components of this multiaddress.
use std::net::Ipv4Addr; use tentacle_multiaddr::{Multiaddr, Protocol}; let address: Multiaddr = "/ip4/127.0.0.1/tcp/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::Tcp(5678));
pub fn replace<'a, F>(&self, at: usize, by: F) -> Option<Multiaddr> where
F: FnOnce(&Protocol<'_>) -> Option<Protocol<'a>>, [src]
pub fn replace<'a, F>(&self, at: usize, by: F) -> Option<Multiaddr> where
F: FnOnce(&Protocol<'_>) -> Option<Protocol<'a>>, [src]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[src]
impl<'de> Deserialize<'de> for Multiaddr[src]fn deserialize<D>(deserializer: D) -> StdResult<Self, D::Error> where
D: Deserializer<'de>, [src]
fn deserialize<D>(deserializer: D) -> StdResult<Self, D::Error> where
D: Deserializer<'de>, [src]Deserialize this value from the given Serde deserializer. Read more
impl<'a> FromIterator<Protocol<'a>> for Multiaddr[src]
impl<'a> FromIterator<Protocol<'a>> for Multiaddr[src]fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Protocol<'a>>, [src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = Protocol<'a>>, [src]Creates a value from an iterator. Read more
impl<'a> IntoIterator for &'a Multiaddr[src]
impl<'a> IntoIterator for &'a Multiaddr[src]impl Eq for Multiaddr[src]
impl StructuralEq for Multiaddr[src]
impl StructuralPartialEq for Multiaddr[src]
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> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, [src]type Owned = T
type Owned = TThe resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn to_owned(&self) -> T[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)[src]
pub fn clone_into(&self, target: &mut T)[src]🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,