Enum bp7::eid::EndpointID[][src]

pub enum EndpointID {
    Dtn(u8DtnAddress),
    DtnNone(u8u8),
    Ipn(u8IpnAddress),
}

Represents an endpoint in various addressing schemes.

Either the none endpoint, a dtn one or an ipn endpoint.

Variants

Dtn(u8DtnAddress)
DtnNone(u8u8)
Ipn(u8IpnAddress)

Implementations

impl EndpointID[src]

pub fn new() -> EndpointID[src]

Default returns a dtn:none endpoint

pub fn with_dtn(host_with_endpoint: &str) -> Result<EndpointID, EndpointIdError>[src]

Create a new EndpointID with dtn addressing scheme

This can either be a host id such as dtn://node1/ or include an application agents endpoint, e.g., dtn://node1/endpoint1 or for non-singletons dtn://group1/~endpoint1

pub const fn none() -> EndpointID[src]

Create a new 'dtn:none' endpoint

This is the same as DTN_NONE

pub fn with_ipn(host: u64, endpoint: u64) -> Result<EndpointID, EndpointIdError>[src]

Create a new EndpointID with ipn addressing scheme

This can either be a host id such as 'ipn:23.0' or include an application agents endpoint, e.g., 'ipn:23.42'

host must be > 0

pub fn new_endpoint(&self, ep: &str) -> Result<EndpointID, EndpointIdError>[src]

Generate a new Endpoint ID from existing one with a specific service endpoint

Keeps scheme and host specific parts from original eid.

Examples

use bp7::eid::*;

// For ipn addresses

let ipn_addr_1 = EndpointID::with_ipn(23, 42).unwrap();
let ipn_addr_2 = EndpointID::with_ipn(23, 7).unwrap();

assert_eq!(ipn_addr_1, ipn_addr_2.new_endpoint("42").unwrap());

let ipn_addr_1 = EndpointID::with_ipn(23, 42).unwrap();    

assert!(ipn_addr_1.new_endpoint("-42").is_err());    

// For dtn addresses
let dtn_addr_1 = EndpointID::with_dtn( "//node1/incoming").unwrap();
let dtn_addr_2 = EndpointID::with_dtn( "//node1/inbox").unwrap();

assert_eq!(dtn_addr_1, dtn_addr_2.new_endpoint("incoming").unwrap());

// For non endpoint this is not possible

let dtn_addr_none = EndpointID::none();    

assert!(dtn_addr_none.new_endpoint("incoming").is_err());    
    

pub fn scheme(&self) -> String[src]

pub fn scheme_specific_part_dtn(&self) -> Option<String>[src]

pub fn scheme_specific_part_ipn(&self) -> Option<IpnAddress>[src]

impl EndpointID[src]

pub fn node(&self) -> Option<String>[src]

Returns the plain node name without URL scheme

pub fn node_id(&self) -> Option<String>[src]

Returns the node name including URL scheme

pub fn is_node_id(&self) -> bool[src]

pub fn validate(&self) -> Result<(), EndpointIdError>[src]

Trait Implementations

impl Clone for EndpointID[src]

impl Debug for EndpointID[src]

impl Default for EndpointID[src]

impl<'de> Deserialize<'de> for EndpointID[src]

impl Display for EndpointID[src]

impl Eq for EndpointID[src]

impl Hash for EndpointID[src]

impl PartialEq<EndpointID> for EndpointID[src]

impl Serialize for EndpointID[src]

impl StructuralEq for EndpointID[src]

impl StructuralPartialEq for EndpointID[src]

impl TryFrom<&'_ str> for EndpointID[src]

type Error = EndpointIdError

The type returned in the event of a conversion error.

impl TryFrom<IpnAddress> for EndpointID[src]

type Error = EndpointIdError

The type returned in the event of a conversion error.

impl TryFrom<String> for EndpointID[src]

Load EndpointID from URL string.

Support for ipn and dtn schemes.

type Error = EndpointIdError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.