shared: add compute_color
This commit is contained in:
parent
a9b8f5a88f
commit
d148f625ac
@ -7,5 +7,6 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
build-info = "0.0.38"
|
build-info = "0.0.38"
|
||||||
|
log = "0.4.22"
|
||||||
notmuch = { path = "../notmuch" }
|
notmuch = { path = "../notmuch" }
|
||||||
serde = { version = "1.0.147", features = ["derive"] }
|
serde = { version = "1.0.147", features = ["derive"] }
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||||
|
|
||||||
use build_info::{BuildInfo, VersionControl};
|
use build_info::{BuildInfo, VersionControl};
|
||||||
|
use log::info;
|
||||||
use notmuch::SearchSummary;
|
use notmuch::SearchSummary;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -49,3 +52,9 @@ pub fn build_version(bi: fn() -> &'static BuildInfo) -> String {
|
|||||||
|
|
||||||
format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string()
|
format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string()
|
||||||
}
|
}
|
||||||
|
pub fn compute_color(data: &str) -> String {
|
||||||
|
info!("compute_color({data})");
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
data.hash(&mut hasher);
|
||||||
|
format!("#{:06x}", hasher.finish() % (1 << 24))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user