elemental-core 0.1.0

Core library for Elemental, providing common utilities and abstractions used across the project.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use sha1_smol::Sha1;
use std::{fs::read, io::Result, path::Path};

#[inline]
pub fn sha1<D: AsRef<[u8]>>(data: D) -> String {
    Sha1::from(data).digest().to_string()
}

#[inline]
pub fn file_sha1<P: AsRef<Path>>(path: P) -> Result<String> {
    Ok(sha1(read(path)?))
}

#[inline]
pub async fn async_file_sha1<P: AsRef<Path>>(path: P) -> Result<String> {
    Ok(sha1(tokio::fs::read(path).await?))
}