pub struct Timestamp(/* private fields */);
Expand description
A timestamp produced by the PTP periperhal
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn new(negative: bool, seconds: u32, subseconds: Subseconds) -> Self
pub const fn new(negative: bool, seconds: u32, subseconds: Subseconds) -> Self
Create a new Timestamp
Sourcepub const fn is_negative(&self) -> bool
pub const fn is_negative(&self) -> bool
Check whether this timestamp is negative or not.
Sourcepub const fn is_positive(&self) -> bool
pub const fn is_positive(&self) -> bool
Check whether this timestamp is positive or not.
Sourcepub const fn subseconds(&self) -> Subseconds
pub const fn subseconds(&self) -> Subseconds
Get the raw subsecond value of this timestamp.
Sourcepub const fn subseconds_signed(&self) -> u32
pub const fn subseconds_signed(&self) -> u32
Get the signed subsecond value of this timestamp.
Note that this is not an i32: it is, technically, a u31 with a leading sign bit.
Sourcepub const fn total_nanos(&self) -> i64
pub const fn total_nanos(&self) -> i64
Get the total amount of nanoseconds in this Timestamp
.
Example:
let timestamp = Timestamp::new(false, 500, Subseconds::new_from_nanos(500_000).unwrap());
assert_eq!(timestamp.total_nanos(), 500 * 1_000_000_000 + 500_000);
let timestamp_neg = Timestamp::new(true, 500, Subseconds::new_from_nanos(500_000).unwrap());
assert_eq!(timestamp_neg.total_nanos(), -1 * (500 * 1_000_000_000 + 500_000));
Sourcepub const fn from_parts(high: u32, low: u32) -> Timestamp
pub const fn from_parts(high: u32, low: u32) -> Timestamp
Create a new timestamp from the provided register values.
Sourcepub fn from_descriptor(desc: &Descriptor) -> Option<Self>
pub fn from_descriptor(desc: &Descriptor) -> Option<Self>
Create a timestamp from the given descriptor
Trait Implementations§
Source§impl AddAssign for Timestamp
impl AddAssign for Timestamp
Source§fn add_assign(&mut self, rhs: Timestamp)
fn add_assign(&mut self, rhs: Timestamp)
Performs the
+=
operation. Read moreSource§impl SubAssign for Timestamp
impl SubAssign for Timestamp
Source§fn sub_assign(&mut self, rhs: Timestamp)
fn sub_assign(&mut self, rhs: Timestamp)
Performs the
-=
operation. Read moreimpl 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 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