core_lib/core/
id.rs

1use rand::{RngCore, rngs::OsRng};
2
3pub fn short_id() -> String {
4    let mut bytes = [0u8; 8];
5    OsRng.fill_bytes(&mut bytes);
6    hex::encode(bytes)[..12].to_string()
7}
8
9pub fn format_commit(commit: &str) -> String {
10    if commit.len() > 10 {
11        commit[..10].to_string()
12    } else {
13        commit.to_string()
14    }
15}