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§
Implementations§
source§impl EndpointID
impl EndpointID
sourcepub fn new() -> EndpointID
pub fn new() -> EndpointID
Default returns a dtn:none
endpoint
sourcepub fn with_dtn(host_with_endpoint: &str) -> Result<EndpointID, EndpointIdError>
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
sourcepub const fn none() -> EndpointID
pub const fn none() -> EndpointID
Create a new ‘dtn:none’ endpoint
This is the same as DTN_NONE
sourcepub fn with_ipn(host: u64, endpoint: u64) -> Result<EndpointID, EndpointIdError>
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
sourcepub fn new_endpoint(&self, ep: &str) -> Result<EndpointID, EndpointIdError>
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());
pub fn scheme(&self) -> String
pub fn scheme_specific_part_dtn(&self) -> Option<String>
pub fn scheme_specific_part_ipn(&self) -> Option<IpnAddress>
source§impl EndpointID
impl EndpointID
pub fn is_node_id(&self) -> bool
pub fn service_name(&self) -> Option<String>
sourcepub fn is_non_singleton(&self) -> bool
pub fn is_non_singleton(&self) -> bool
Check whether the EndpointID service name starts with ‘~’
pub fn validate(&self) -> Result<(), EndpointIdError>
Trait Implementations§
source§impl Clone for EndpointID
impl Clone for EndpointID
source§fn clone(&self) -> EndpointID
fn clone(&self) -> EndpointID
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EndpointID
impl Debug for EndpointID
source§impl Default for EndpointID
impl Default for EndpointID
source§impl<'de> Deserialize<'de> for EndpointID
impl<'de> Deserialize<'de> for EndpointID
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Display for EndpointID
impl Display for EndpointID
source§impl Hash for EndpointID
impl Hash for EndpointID
source§impl PartialEq for EndpointID
impl PartialEq for EndpointID
source§fn eq(&self, other: &EndpointID) -> bool
fn eq(&self, other: &EndpointID) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for EndpointID
impl Serialize for EndpointID
source§impl TryFrom<&str> for EndpointID
impl TryFrom<&str> for EndpointID
Load EndpointID from URL string.
Support for ipn and dtn schemes.