pub struct InterfaceTsResolution { /* private fields */ }Expand description
Timestamp resolution of an interface.
Can be either binary (2^-resol)s or decimal (10^-resol)s.
Implementations§
Source§impl InterfaceTsResolution
impl InterfaceTsResolution
Sourcepub fn new(is_bin: bool, resol: u8) -> Result<Self, ContentValidationError>
pub fn new(is_bin: bool, resol: u8) -> Result<Self, ContentValidationError>
Creates a new InterfaceTsResolution.
- If binary, the resolution must be in the range [0-29].
- If decimal, the resolution must be in the range [0-9].
Sourcepub fn from_u8(ts_resol: u8) -> Result<Self, ContentValidationError>
pub fn from_u8(ts_resol: u8) -> Result<Self, ContentValidationError>
Creates a new InterfaceTsResolution from a u8.
- If binary, the resolution must be in the range [0-29].
- If decimal, the resolution must be in the range [0-9].
Sourcepub fn to_u8(self) -> u8
pub fn to_u8(self) -> u8
Encodes the InterfaceTsResolution into a u8 for storage in the file.
Sourcepub fn decode_timestamp(&self, ts_raw: u64) -> Duration
pub fn decode_timestamp(&self, ts_raw: u64) -> Duration
Decode an encoded timestamp using the current resolution.
Sourcepub fn encode_timestamp(
&self,
timestamp: Duration,
) -> Result<u64, ContentValidationError>
pub fn encode_timestamp( &self, timestamp: Duration, ) -> Result<u64, ContentValidationError>
Encode a timestamp with the current resolution.
§Errors
- Timestamp can’t be encoded with the current resolution on a u64
Sourcepub fn resolution(&self) -> u8
pub fn resolution(&self) -> u8
Returns the resolution value.
Trait Implementations§
Source§impl Clone for InterfaceTsResolution
impl Clone for InterfaceTsResolution
impl Copy for InterfaceTsResolution
Source§impl Debug for InterfaceTsResolution
impl Debug for InterfaceTsResolution
Source§impl Default for InterfaceTsResolution
impl Default for InterfaceTsResolution
Source§impl Display for InterfaceTsResolution
impl Display for InterfaceTsResolution
impl Eq for InterfaceTsResolution
Source§impl PartialEq for InterfaceTsResolution
impl PartialEq for InterfaceTsResolution
impl StructuralPartialEq for InterfaceTsResolution
Auto Trait Implementations§
impl Forget for InterfaceTsResolution
impl Freeze for InterfaceTsResolution
impl Move for InterfaceTsResolution
impl RefUnwindSafe for InterfaceTsResolution
impl Send for InterfaceTsResolution
impl Sync for InterfaceTsResolution
impl Unpin for InterfaceTsResolution
impl UnsafeUnpin for InterfaceTsResolution
impl UnwindSafe for InterfaceTsResolution
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