br-hid 0.2.1

This is an Bluetooth HID
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::hash::{DefaultHasher, Hash, Hasher};

pub(crate) fn calculate_hash<T: Hash>(value: &T) -> u64 {
    let mut hasher = DefaultHasher::new();
    value.hash(&mut hasher);
    hasher.finish()
}

pub(crate) fn u64_to_mac(val: u64) -> String {
    let bytes = val.to_be_bytes(); // 转成大端 8 字节
    let mac_bytes = &bytes[2..];   // MAC 只有后 6 字节
    mac_bytes.iter().map(|b| format!("{:02x}", b)).collect::<Vec<_>>().join(":")
}