pub struct PtpTimestamp {
pub seconds: u64,
pub nanoseconds: u32,
}Expand description
PTP uses an 80-bit timestamp: 48-bit seconds + 32-bit nanoseconds.
Fields§
§seconds: u64Seconds since PTP epoch (TAI, 1970-01-01). Only lower 48 bits used on wire.
nanoseconds: u32Nanoseconds [0, 999_999_999].
Implementations§
Source§impl PtpTimestamp
impl PtpTimestamp
pub const ZERO: Self
pub fn new(seconds: u64, nanoseconds: u32) -> Self
Sourcepub fn to_ntp_timestamp(self) -> NtpTimestamp
pub fn to_ntp_timestamp(self) -> NtpTimestamp
Convert to NtpTimestamp (approximate, ignores TAI-UTC offset).
Sourcepub fn to_bytes(self) -> [u8; 10]
pub fn to_bytes(self) -> [u8; 10]
Serialize the 10-byte wire format (6 bytes seconds + 4 bytes nanos).
Sourcepub fn from_bytes(bytes: [u8; 10]) -> Self
pub fn from_bytes(bytes: [u8; 10]) -> Self
Deserialize from 10-byte wire format.
Trait Implementations§
Source§impl Clone for PtpTimestamp
impl Clone for PtpTimestamp
Source§fn clone(&self) -> PtpTimestamp
fn clone(&self) -> PtpTimestamp
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PtpTimestamp
Source§impl Debug for PtpTimestamp
impl Debug for PtpTimestamp
Source§impl Default for PtpTimestamp
impl Default for PtpTimestamp
Source§fn default() -> PtpTimestamp
fn default() -> PtpTimestamp
Returns the “default value” for a type. Read more
Source§impl Display for PtpTimestamp
impl Display for PtpTimestamp
impl Eq for PtpTimestamp
Source§impl Hash for PtpTimestamp
impl Hash for PtpTimestamp
Source§impl Ord for PtpTimestamp
impl Ord for PtpTimestamp
Source§fn cmp(&self, other: &PtpTimestamp) -> Ordering
fn cmp(&self, other: &PtpTimestamp) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PtpTimestamp
impl PartialEq for PtpTimestamp
Source§fn eq(&self, other: &PtpTimestamp) -> bool
fn eq(&self, other: &PtpTimestamp) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PtpTimestamp
impl PartialOrd for PtpTimestamp
impl StructuralPartialEq for PtpTimestamp
Auto Trait Implementations§
impl Freeze for PtpTimestamp
impl RefUnwindSafe for PtpTimestamp
impl Send for PtpTimestamp
impl Sync for PtpTimestamp
impl Unpin for PtpTimestamp
impl UnsafeUnpin for PtpTimestamp
impl UnwindSafe for PtpTimestamp
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