rust-web-server 16.1.0

Collection of utility functions used to build Rust Web and TLS Server. Can be useful while developing HTTP related functionality
Documentation
use std::time::{SystemTime, UNIX_EPOCH};

#[cfg(test)]
mod tests;

pub struct DateTimeExt;

impl DateTimeExt {
    pub fn _now_unix_epoch_nanos() -> u128 {
        let now = SystemTime::now();
        let nanos = DateTimeExt::_system_time_to_unix_nanos(now);
        nanos
    }

    pub fn _system_time_to_unix_nanos(system_time: SystemTime) -> u128 {
        let boxed_duration = system_time.duration_since(UNIX_EPOCH);
        if boxed_duration.is_err() {
            eprintln!("unable to get duration from system time {}", boxed_duration.err().unwrap());
            let nanos = 0 as u128;
            return nanos
        }

        let nanos = boxed_duration.unwrap().as_nanos();
        nanos
    }

}