Enum bp7::eid::EndpointID

source ·
pub enum EndpointID {
    Dtn(u8, DtnAddress),
    DtnNone(u8, u8),
    Ipn(u8, IpnAddress),
}
Expand description

Represents an endpoint in various addressing schemes.

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

Variants§

§

Dtn(u8, DtnAddress)

§

DtnNone(u8, u8)

§

Ipn(u8, IpnAddress)

Implementations§

source§

impl EndpointID

source

pub fn new() -> EndpointID

Default returns a dtn:none endpoint

source

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

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

source

pub const fn none() -> EndpointID

Create a new ‘dtn:none’ endpoint

This is the same as DTN_NONE

source

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

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

source

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

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());
assert_eq!(ipn_addr_1.node_id(), Some("ipn:23.0".to_string()));

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());
assert_eq!(dtn_addr_1.node_id(), Some("dtn://node1/".to_string()));

// For non endpoint this is not possible

let dtn_addr_none = EndpointID::none();    

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

pub fn scheme(&self) -> String

source

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

source

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

source§

impl EndpointID

source

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

Returns the plain node name without URL scheme

source

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

Returns the node name including URL scheme

source

pub fn is_node_id(&self) -> bool

source

pub fn service_name(&self) -> Option<String>

source

pub fn is_non_singleton(&self) -> bool

Check whether the EndpointID service name starts with ‘~’

source

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

Trait Implementations§

source§

impl Clone for EndpointID

source§

fn clone(&self) -> EndpointID

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EndpointID

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for EndpointID

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for EndpointID

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for EndpointID

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for EndpointID

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl PartialEq for EndpointID

source§

fn eq(&self, other: &EndpointID) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for EndpointID

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<&str> for EndpointID

Load EndpointID from URL string.

Support for ipn and dtn schemes.

§

type Error = EndpointIdError

The type returned in the event of a conversion error.
source§

fn try_from(item: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<IpnAddress> for EndpointID

§

type Error = EndpointIdError

The type returned in the event of a conversion error.
source§

fn try_from(item: IpnAddress) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for EndpointID

§

type Error = EndpointIdError

The type returned in the event of a conversion error.
source§

fn try_from(item: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for EndpointID

source§

impl StructuralEq for EndpointID

source§

impl StructuralPartialEq for EndpointID

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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