cached-path 0.1.0

Download and cache HTTP resources.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use std::time::SystemTime;

pub(crate) fn hash_str(s: &str) -> String {
    let mut hasher = Sha256::new();
    hasher.input_str(s);
    hasher.result_str()
}

pub(crate) fn now() -> f64 {
    // Safe to unwrap unless the system time is seriously screwed up.
    SystemTime::now()
        .duration_since(SystemTime::UNIX_EPOCH)
        .unwrap()
        .as_secs_f64()
}