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
sourceimpl 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());
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
pub fn scheme_specific_part_dtn(&self) -> Option<String>
pub fn scheme_specific_part_ipn(&self) -> Option<IpnAddress>
sourceimpl 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
sourceimpl Clone for EndpointID
impl Clone for EndpointID
sourcefn clone(&self) -> EndpointID
fn clone(&self) -> EndpointID
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EndpointID
impl Debug for EndpointID
sourceimpl Default for EndpointID
impl Default for EndpointID
sourceimpl<'de> Deserialize<'de> for EndpointID
impl<'de> Deserialize<'de> for EndpointID
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for EndpointID
impl Display for EndpointID
sourceimpl Hash for EndpointID
impl Hash for EndpointID
sourceimpl PartialEq<EndpointID> for EndpointID
impl PartialEq<EndpointID> for EndpointID
sourcefn eq(&self, other: &EndpointID) -> bool
fn eq(&self, other: &EndpointID) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &EndpointID) -> bool
fn ne(&self, other: &EndpointID) -> bool
This method tests for !=
.
sourceimpl Serialize for EndpointID
impl Serialize for EndpointID
sourceimpl TryFrom<&'_ str> for EndpointID
impl TryFrom<&'_ str> for EndpointID
Load EndpointID from URL string.
Support for ipn and dtn schemes.
sourceimpl TryFrom<IpnAddress> for EndpointID
impl TryFrom<IpnAddress> for EndpointID
type Error = EndpointIdError
type Error = EndpointIdError
The type returned in the event of a conversion error.
sourcefn try_from(item: IpnAddress) -> Result<Self, Self::Error>
fn try_from(item: IpnAddress) -> Result<Self, Self::Error>
Performs the conversion.
sourceimpl TryFrom<String> for EndpointID
impl TryFrom<String> for EndpointID
impl Eq for EndpointID
impl StructuralEq for EndpointID
impl StructuralPartialEq for EndpointID
Auto Trait Implementations
impl RefUnwindSafe for EndpointID
impl Send for EndpointID
impl Sync for EndpointID
impl Unpin for EndpointID
impl UnwindSafe for EndpointID
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more