pub struct CucTime {
pub config: CucConfig,
pub coarse: u32,
pub fine: u32,
}Expand description
A CUC timestamp value.
Fields§
§config: CucConfigConfiguration describing the encoding format.
coarse: u32Coarse time: whole seconds since epoch.
fine: u32Fine time: fractional seconds (interpretation depends on
config.fine_len).
Implementations§
Source§impl CucTime
impl CucTime
Sourcepub const fn new(config: CucConfig, coarse: u32, fine: u32) -> Self
pub const fn new(config: CucConfig, coarse: u32, fine: u32) -> Self
Creates a new CUC timestamp from coarse and fine values.
Sourcepub fn from_seconds(config: CucConfig, seconds: f64) -> Self
pub fn from_seconds(config: CucConfig, seconds: f64) -> Self
Creates a CUC timestamp from a floating-point seconds value.
The integer part becomes the coarse time; the fractional part
is quantized into config.fine_len bytes of resolution.
Sourcepub fn to_seconds(&self) -> f64
pub fn to_seconds(&self) -> f64
Converts this timestamp to a floating-point seconds value.
Sourcepub fn resolution(&self) -> f64
pub fn resolution(&self) -> f64
Returns the fractional-second resolution in seconds.
Sourcepub fn encode(&self, buf: &mut [u8]) -> Result<usize, Error>
pub fn encode(&self, buf: &mut [u8]) -> Result<usize, Error>
Encodes this timestamp into a byte buffer (P-field + T-field).
Returns the number of bytes written.
Sourcepub fn encode_t_field(&self, buf: &mut [u8]) -> Result<usize, Error>
pub fn encode_t_field(&self, buf: &mut [u8]) -> Result<usize, Error>
Encodes only the T-field (no P-field) into a buffer.
Useful when the P-field is implicit.
Trait Implementations§
impl Copy for CucTime
impl Eq for CucTime
impl StructuralPartialEq for CucTime
Auto Trait Implementations§
impl Freeze for CucTime
impl RefUnwindSafe for CucTime
impl Send for CucTime
impl Sync for CucTime
impl Unpin for CucTime
impl UnsafeUnpin for CucTime
impl UnwindSafe for CucTime
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