Skip to main content

DateTime

Trait DateTime 

Source
pub trait DateTime {
    const DATE_SIZE_HINT: usize = DATE_VALUE_LENGTH;

    // Required methods
    fn with_date<F, O>(&self, f: F) -> O
       where F: FnOnce(&[u8]) -> O;
    fn with_date_header<F, O>(&self, f: F) -> O
       where F: FnOnce(&HeaderValue) -> O;
    fn now(&self) -> Instant;
}
Expand description

Trait for getting current date/time.

This is usually used by a low resolution of timer to reduce frequent syscall to OS.

Provided Associated Constants§

Source

const DATE_SIZE_HINT: usize = DATE_VALUE_LENGTH

The size hint of slice by Self::date method.

Required Methods§

Source

fn with_date<F, O>(&self, f: F) -> O
where F: FnOnce(&[u8]) -> O,

closure would receive byte slice representation of HttpDate.

Source

fn with_date_header<F, O>(&self, f: F) -> O
where F: FnOnce(&HeaderValue) -> O,

Source

fn now(&self) -> Instant

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl DateTime for RefCell<DateTimeState>

Source§

fn with_date<F, O>(&self, f: F) -> O
where F: FnOnce(&[u8]) -> O,

Source§

fn with_date_header<F, O>(&self, f: F) -> O
where F: FnOnce(&HeaderValue) -> O,

Source§

fn now(&self) -> Instant

Implementors§