pub enum Timestamp {
Relative(TimeUnits),
Absolute(TimeUnits),
}Expand description
Reference time at which the data contained in the PDU was generated.
Time is represented as TimeUnits elapsed since the beginning of the current hour in the selected time reference.
Variants§
Relative(TimeUnits)
Time is relative to the simulation application issuing the PDU.
A relative timestamp should be used when host clocks are not synchronized.
Absolute(TimeUnits)
Time is absolute to the simulation time.
An absolute timestamp should be used when host clocks are synchronized.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const RELATIVE_BIT: u32 = 0b0
pub const RELATIVE_BIT: u32 = 0b0
Bit indicating a relative timestamp.
Sourcepub const ABSOLUTE_BIT: u32 = 0b1
pub const ABSOLUTE_BIT: u32 = 0b1
Bit indicating an absolute timestamp.
Sourcepub const fn new(value: u32) -> Self
pub const fn new(value: u32) -> Self
Constructs a new Timestamp from value.
§Examples
let timestamp = Timestamp::new(20);
assert_eq!(timestamp, Timestamp::Relative(TimeUnits::new(10).unwrap()));
let timestamp = Timestamp::new(21);
assert_eq!(timestamp, Timestamp::Absolute(TimeUnits::new(10).unwrap()));Sourcepub const fn time_units(self) -> TimeUnits
pub const fn time_units(self) -> TimeUnits
Sourcepub const fn is_relative(self) -> bool
pub const fn is_relative(self) -> bool
Returns true if this Timestamp is relative.
§Examples
let timestamp = Timestamp::Relative(TimeUnits::new(10).unwrap());
assert!(timestamp.is_relative());Sourcepub const fn is_absolute(self) -> bool
pub const fn is_absolute(self) -> bool
Returns true if this Timestamp is absolute.
§Examples
let timestamp = Timestamp::Absolute(TimeUnits::new(10).unwrap());
assert!(timestamp.is_absolute());Sourcepub fn to_duration(self) -> Duration
pub fn to_duration(self) -> Duration
Converts this Timestamp into a Duration.
§Examples
let timestamp = Timestamp::Relative(TimeUnits::new(1_073_741_824).unwrap());
assert_eq!(timestamp.to_duration(), Duration::from_mins(30));
let timestamp = Timestamp::Absolute(TimeUnits::new(1_073_741_824).unwrap());
assert_eq!(timestamp.to_duration(), Duration::from_mins(30));Trait Implementations§
Source§impl PartialOrd<Timestamp> for u32
impl PartialOrd<Timestamp> for u32
Source§impl PartialOrd<u32> for Timestamp
impl PartialOrd<u32> for Timestamp
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnsafeUnpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more