Struct dtn7::core::peer::DtnPeer [−][src]
pub struct DtnPeer {
pub eid: EndpointID,
pub addr: IpAddr,
pub con_type: PeerType,
pub period: Option<Duration>,
pub cla_list: Vec<(String, Option<u16>)>,
pub services: HashMap<u8, String>,
pub last_contact: u64,
}
Fields
eid: EndpointID
addr: IpAddr
con_type: PeerType
period: Option<Duration>
cla_list: Vec<(String, Option<u16>)>
services: HashMap<u8, String>
last_contact: u64
Implementations
pub fn new(
eid: EndpointID,
addr: IpAddr,
con_type: PeerType,
period: Option<Duration>,
cla_list: Vec<(String, Option<u16>)>,
services: HashMap<u8, String>
) -> DtnPeer
Example
use std::{thread, time};
use dtn7::core::*;
use dtn7::CONFIG;
let mut peer = helpers::rnd_peer();
let original_time = peer.last_contact;
thread::sleep(time::Duration::from_secs(1));
peer.touch();
assert!(original_time < peer.last_contact);
Example
use std::{thread, time::Duration};
use dtn7::core::*;
use dtn7::CONFIG;
(*CONFIG.lock()).peer_timeout = Duration::from_secs(1);
let mut peer = helpers::rnd_peer();
peer.con_type = PeerType::Dynamic;
assert_eq!(peer.still_valid(), true);
thread::sleep(Duration::from_secs(2));
assert_eq!(peer.still_valid(), false);
Trait Implementations
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for DtnPeer
impl UnwindSafe for DtnPeer
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more