complete base rewrite

This commit is contained in:
ppc
2026-01-05 21:32:38 +00:00
parent 96a9e2a498
commit 2125753e37
10 changed files with 315 additions and 283 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
pub (in crate) fn format_hex_bytes(bytes: &[u8]) -> String {
pub (crate) fn format_hex_bytes(bytes: &[u8]) -> String {
bytes.chunks(2)
.map(|chunk| chunk.iter().map(|b| format!("{:02X}", b)).collect::<String>())
.collect::<Vec<_>>()
.join(" ")
}
pub (in crate) fn parse_access_code(code: &String) -> Option<[u8; 10]> {
pub (crate) fn parse_access_code(code: &String) -> Option<[u8; 10]> {
let matrix_code = format!("{:0>20}", code.replace(" ", ""));
let mut bytes: [u8; 10] = [0; 10];
@@ -19,7 +19,7 @@ pub (in crate) fn parse_access_code(code: &String) -> Option<[u8; 10]> {
Some(bytes)
}
pub (in crate) fn parse_idm_hex(idm_hex: &String) -> Option<[u8; 8]> {
pub (crate) fn parse_idm_hex(idm_hex: &String) -> Option<[u8; 8]> {
if idm_hex.len() > 16 || !idm_hex.chars().all(|c| c.is_ascii_hexdigit()) {
return None;
}