Struct q_compress::data_types::TimestampNanos
source · [−]pub struct TimestampNanos(_);
Expand description
A nanosecond-precise, timezone-naive timestamp.
All q_compress
timestamps use a signed 64 bit integer for the number of
seconds since the Unix Epoch, which is a range of about +/- 500 million
years.
This is (generally) the most generous timestamp range standard used by
other major tools today.
TimestampNanos
in particular have fine enough granularity to losslessly
convert timestamps for any operating system or (generally) major tool.
Implementations
sourceimpl TimestampNanos
impl TimestampNanos
sourcepub fn new(parts: i128) -> QCompressResult<Self>
pub fn new(parts: i128) -> QCompressResult<Self>
Returns a timestamp with the corresponding parts
since the Unix
Epoch. Will return an error if outside the bounds of a 64-bit signed
integer for seconds and 32-bit unsigned integer for
fractional parts.
sourcepub fn from_secs_and_nanos(seconds: i64, subsec_nanos: u32) -> Self
pub fn from_secs_and_nanos(seconds: i64, subsec_nanos: u32) -> Self
Returns a timestamp with the corresponding seconds and fractional nanoseconds since the Unix Epoch.
sourcepub fn to_secs_and_nanos(self) -> (i64, u32)
pub fn to_secs_and_nanos(self) -> (i64, u32)
Returns the (seconds, subsec_nanos)
since the Unix Epoch.
sourcepub fn to_total_parts(self) -> i128
pub fn to_total_parts(self) -> i128
Returns the total number of parts
(e.g. microseconds or
nanoseconds) since the Unix Epoch.
sourcepub fn validate(&self) -> QCompressResult<()>
pub fn validate(&self) -> QCompressResult<()>
Return an error if the timestamp is out of range.
Valid timestamps fit into a 64-bit signed integer
for seconds and 32-bit unsigned integer for the fractional part
of the second. However, the in-memory representation uses a 128-bit
signed integer for the total number of fractional parts.
It is theoretically possible for a corrupt delta-encoded file to
cause a decompressor to return invalid timestamps.
If you are concerned about a data corruption affecting such a case
without being noticed, you may want to .validate()
every returned
timestamp. Otherwise, it is possible that a panic occurs when you try
to use the corrupt timestamps.
Trait Implementations
sourceimpl Clone for TimestampNanos
impl Clone for TimestampNanos
sourcefn clone(&self) -> TimestampNanos
fn clone(&self) -> TimestampNanos
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TimestampNanos
impl Debug for TimestampNanos
sourceimpl Default for TimestampNanos
impl Default for TimestampNanos
sourcefn default() -> TimestampNanos
fn default() -> TimestampNanos
Returns the “default value” for a type. Read more
sourceimpl Display for TimestampNanos
impl Display for TimestampNanos
sourceimpl From<SystemTime> for TimestampNanos
impl From<SystemTime> for TimestampNanos
sourcefn from(system_time: SystemTime) -> Self
fn from(system_time: SystemTime) -> Self
Performs the conversion.
sourceimpl From<TimestampNanos> for SystemTime
impl From<TimestampNanos> for SystemTime
sourcefn from(value: TimestampNanos) -> SystemTime
fn from(value: TimestampNanos) -> SystemTime
Performs the conversion.
sourceimpl NumberLike for TimestampNanos
impl NumberLike for TimestampNanos
sourceconst HEADER_BYTE: u8
const HEADER_BYTE: u8
A number from 0-255 that corresponds to the number’s data type. Read more
sourceconst PHYSICAL_BITS: usize
const PHYSICAL_BITS: usize
The number of bits in the number’s uncompressed representation.
This must match the number of bytes in the to_bytes
and from_bytes
implementations.
Note that booleans have 8 physical bits (not 1)
and timestamps have 96 (not 128). Read more
type Signed = i128
type Signed = i128
The signed integer this type can convert between to do wrapped
subtraction and addition for delta encoding/decoding.
Must be another NumberLike
with the same Signed
and Unsigned
as
this type; in this way, if we take 7th order deltas, they are ensured to
have the same type as 1st order deltas. Read more
type Unsigned = u128
type Unsigned = u128
The unsigned integer this type can convert between to do bitwise logic and such. Read more
sourcefn to_unsigned(self) -> u128
fn to_unsigned(self) -> u128
Used during compression to convert to an unsigned integer.
sourcefn from_unsigned(off: u128) -> Self
fn from_unsigned(off: u128) -> Self
Used during decompression to convert back from an unsigned integer.
sourcefn from_signed(signed: i128) -> Self
fn from_signed(signed: i128) -> Self
Used during delta decoding to convert back from a signed integer.
sourcefn from_bytes(bytes: Vec<u8>) -> QCompressResult<Self>
fn from_bytes(bytes: Vec<u8>) -> QCompressResult<Self>
Creates a number from an uncompressed representation.
sourcefn num_eq(&self, other: &Self) -> bool
fn num_eq(&self, other: &Self) -> bool
Lossless check for bit-exact equality. This is important because not all data types support full ordering: https://stackoverflow.com/questions/26489701/why-does-rust-not-implement-total-ordering-via-the-ord-trait-for-f64-and-f32. Read more
sourcefn read_from(reader: &mut BitReader<'_>) -> QCompressResult<Self>
fn read_from(reader: &mut BitReader<'_>) -> QCompressResult<Self>
Parses an uncompressed representation of the number from the
BitReader
. Read more
sourceimpl PartialEq<TimestampNanos> for TimestampNanos
impl PartialEq<TimestampNanos> for TimestampNanos
sourcefn eq(&self, other: &TimestampNanos) -> bool
fn eq(&self, other: &TimestampNanos) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TimestampNanos) -> bool
fn ne(&self, other: &TimestampNanos) -> bool
This method tests for !=
.
impl Copy for TimestampNanos
impl Eq for TimestampNanos
impl StructuralEq for TimestampNanos
impl StructuralPartialEq for TimestampNanos
Auto Trait Implementations
impl RefUnwindSafe for TimestampNanos
impl Send for TimestampNanos
impl Sync for TimestampNanos
impl Unpin for TimestampNanos
impl UnwindSafe for TimestampNanos
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more