[−][src]Enum bp7::eid::EndpointID
Examples
use bp7::eid::*; let cbor_eid = [130, 1, 106, 110, 111, 100, 101, 49, 47, 116, 101, 115, 116]; let deserialized: EndpointID = serde_cbor::from_slice(&cbor_eid).unwrap(); assert_eq!(deserialized, EndpointID::Dtn(ENDPOINT_URI_SCHEME_DTN, "node1/test".to_string()))
Variants
Ipn(u8, IpnAddress)
Methods
impl EndpointID
[src]
pub fn new() -> EndpointID
[src]
pub fn with_dtn(addr: &str) -> EndpointID
[src]
Examples
use bp7::eid::*; assert_eq!(EndpointID::with_dtn("node1"),EndpointID::Dtn(ENDPOINT_URI_SCHEME_DTN,"node1".to_string())); assert_eq!(EndpointID::with_dtn("node1/endpoint1"),EndpointID::Dtn(ENDPOINT_URI_SCHEME_DTN,"node1/endpoint1".to_string()));
pub fn with_dtn_none() -> EndpointID
[src]
Examples
use bp7::eid::*; assert_eq!(EndpointID::with_dtn_none(), EndpointID::DtnNone(ENDPOINT_URI_SCHEME_DTN,0)); let encoded_eid = serde_cbor::to_vec(&EndpointID::with_dtn_none()).expect("Error serializing packet as cbor."); println!("{:02x?}", &encoded_eid); assert_eq!(EndpointID::with_dtn_none(), serde_cbor::from_slice(&encoded_eid).expect("Decoding packet failed"));
pub fn with_ipn(addr: IpnAddress) -> EndpointID
[src]
Examples
use bp7::eid::*; assert_eq!(EndpointID::with_ipn( IpnAddress(23, 42) ), EndpointID::Ipn(ENDPOINT_URI_SCHEME_IPN, IpnAddress(23, 42)) ); let ipn_eid = EndpointID::with_ipn(IpnAddress(23, 42)); let encoded_eid = serde_cbor::to_vec(&ipn_eid).expect("Error serializing packet as cbor."); println!("{:02x?}", &encoded_eid); assert_eq!(ipn_eid, serde_cbor::from_slice(&encoded_eid).expect("Decoding packet failed"));
pub fn endpoint(&self, ep: &str) -> Result<EndpointID, Bp7Error>
[src]
Generate a new Endpoint ID with a specific endpoint Keeps scheme and host specific parts
Examples
use bp7::eid::*; let ipn_addr_1 = EndpointID::with_ipn( IpnAddress(23, 42)); let ipn_addr_2 = EndpointID::with_ipn( IpnAddress(23, 7)); assert_eq!(ipn_addr_1, ipn_addr_2.endpoint("42").unwrap()); let ipn_addr_1 = EndpointID::with_ipn( IpnAddress(23, 42)); assert!(ipn_addr_1.endpoint("-42").is_err()); let dtn_addr_1 = EndpointID::with_dtn( "node1/incoming"); let dtn_addr_2 = EndpointID::with_dtn( "node1/inbox"); assert_eq!(dtn_addr_1, dtn_addr_2.endpoint("incoming").unwrap()); let dtn_addr_none = EndpointID::with_dtn_none(); assert!(dtn_addr_none.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_part(&self) -> Option<String>
[src]
Examples
use bp7::eid::*; let eid : EndpointID = "ipn://0.0".to_string().into(); assert_eq!(eid.node_part(),Some("0".to_string())); let eid : EndpointID = "dtn://node1/incoming".to_string().into(); assert_eq!(eid.node_part(),Some("node1".to_string())); let eid : EndpointID = "dtn://node1".to_string().into(); assert_eq!(eid.node_part(),Some("node1".to_string()));
pub fn host_id(&self) -> Option<String>
[src]
Examples
use bp7::eid::*; let eid : EndpointID = "ipn://0.0".to_string().into(); assert_eq!(eid.host_id(),Some("ipn://0".to_string())); let eid : EndpointID = "dtn://node1/incoming".to_string().into(); assert_eq!(eid.host_id(),Some("dtn://node1".to_string())); let eid : EndpointID = "dtn://node1".to_string().into(); assert_eq!(eid.host_id(),Some("dtn://node1".to_string()));
pub fn is_node_id(&self) -> bool
[src]
Examples
use bp7::eid::*; let eid : EndpointID = "ipn://0.0".to_string().into(); assert_eq!(eid.is_node_id(), true); let eid : EndpointID = "ipn://0.1".to_string().into(); assert_eq!(eid.is_node_id(), false); let eid : EndpointID = "dtn://node1/incoming".to_string().into(); assert_eq!(eid.is_node_id(), false); let eid : EndpointID = "dtn://node1".to_string().into(); assert_eq!(eid.is_node_id(), true);
pub fn validation_error(&self) -> Option<Bp7Error>
[src]
Examples
use bp7::eid::*; let eid = EndpointID::DtnNone(1, 0); assert_eq!(eid.validation_error().is_none(), true); // should not fail let eid = EndpointID::DtnNone(0, 0); assert_eq!(eid.validation_error().is_some(), true); // should fail let eid = EndpointID::DtnNone(1, 1); assert_eq!(eid.validation_error().is_some(), true); // should fail let eid = EndpointID::Ipn(2, IpnAddress(23, 42)); assert_eq!(eid.validation_error().is_none(), true); // should not fail let eid = EndpointID::Ipn(1, IpnAddress(23, 42)); assert_eq!(eid.validation_error().is_some(), true); // should fail let eid = EndpointID::Ipn(2, IpnAddress(0, 0)); assert_eq!(eid.validation_error().is_some(), true); // should fail
Trait Implementations
impl Clone for EndpointID
[src]
fn clone(&self) -> EndpointID
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for EndpointID
[src]
impl Default for EndpointID
[src]
impl<'de> Deserialize<'de> for EndpointID
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for EndpointID
[src]
impl Eq for EndpointID
[src]
impl<'_> From<&'_ str> for EndpointID
[src]
impl From<String> for EndpointID
[src]
Load EndpointID from URL string. Support for IPN and dtn schemes.
Examples
use bp7::eid::*; let eid = EndpointID::from("dtn://none".to_string()); assert_eq!(eid, EndpointID::DtnNone(ENDPOINT_URI_SCHEME_DTN, 0)); let eid = EndpointID::from("dtn:none".to_string()); assert_eq!(eid, EndpointID::DtnNone(ENDPOINT_URI_SCHEME_DTN, 0)); let eid = EndpointID::from("dtn://node1/endpoint1".to_string()); assert_eq!(eid, EndpointID::Dtn(ENDPOINT_URI_SCHEME_DTN, "node1/endpoint1".to_string())); let eid = EndpointID::from("dtn:node1/endpoint1".to_string()); assert_eq!(eid, EndpointID::Dtn(ENDPOINT_URI_SCHEME_DTN, "node1/endpoint1".to_string()));
This should panic:
use bp7::eid::*; let eid = EndpointID::from("node1".to_string());
impl Hash for EndpointID
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<EndpointID> for EndpointID
[src]
fn eq(&self, other: &EndpointID) -> bool
[src]
fn ne(&self, other: &EndpointID) -> bool
[src]
impl Serialize for EndpointID
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for EndpointID
[src]
impl StructuralPartialEq for EndpointID
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,