co-didcomm 0.8.0

COKIT fork of didcomm-rs — DIDComm messaging v2 implementation with modern crypto and WASM support.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/// Returns the current time as seconds since Unix epoch, or `None` on failure.
///
/// On WASM with the `wasm_js` feature, uses `js_sys::Date::now()`.
/// On native platforms, uses `std::time::SystemTime`.
pub(crate) fn now_epoch_secs() -> Option<u64> {
    #[cfg(feature = "wasm_js")]
    {
        Some((js_sys::Date::now() / 1000.0) as u64)
    }
    #[cfg(not(feature = "wasm_js"))]
    {
        std::time::SystemTime::now()
            .duration_since(std::time::SystemTime::UNIX_EPOCH)
            .ok()
            .map(|d| d.as_secs())
    }
}