Skip to main content

TimeDelta

Struct TimeDelta 

Source
pub struct TimeDelta { /* private fields */ }

Implementations§

Source§

impl TimeDelta

Source

pub fn from_now() -> TimeDelta

This has to be called inside a critical section

Source

pub const fn is_extended(&self) -> bool

Returns true if the TimeDelta requires extended format (4 bytes), false if it can be represented in single format (2 bytes).

Source

pub fn write_bytes(&self, writer: &mut BufferWriter)

Write the TimeDelta into the provided writer. It will use either 2 or 4 bytes depending on the size:

  • If the delta is less than 2^15, it will be written as a 2-byte value with the highest bit set to 0.
  • If the delta is 2^15 or more, it will be written as a 4-byte value with the highest bit set to 1. If the delta exceeds 2^31 - 1, it will be capped to that value.
Source

pub fn write_bytes_mut(&self, writer: &mut [u8]) -> usize

Source

pub fn read_bytes( reader: &mut BufferReader<'_>, ) -> Result<TimeDelta, ReadTracingError>

Reads a TimeDelta from the provided reader. Returns None if reading fails. It automatically detects whether the format is single (2 bytes) or extended (4 bytes) based on the highest bit. This method can only “fail” if there is not enough data in the reader.

Source

pub fn delta(&self) -> u32

Returns the delta in microseconds

Trait Implementations§

Source§

impl Clone for TimeDelta

Source§

fn clone(&self) -> TimeDelta

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeDelta

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TimeDelta

Source§

fn eq(&self, other: &TimeDelta) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TimeDelta

Source§

impl Eq for TimeDelta

Source§

impl StructuralPartialEq for TimeDelta

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.