diff --git a/src/headlenpow.rs b/src/headlenpow.rs index f2f975f..fcafdb7 100644 --- a/src/headlenpow.rs +++ b/src/headlenpow.rs @@ -47,7 +47,7 @@ fn decimal(s: &str) -> Option { fn slack_count(s: &str, body: &[u8]) -> Option { match s { "char/utf8" => Some(std::str::from_utf8(body).ok()?.chars().count() as u64), - "byte" => Some(body.len() as u64), + "uint8" => Some(body.len() as u64), "char/ascii" if body.is_ascii() => Some(body.len() as u64), "char/utf32" if body.len() % 4 == 0 => { for chunk in body.chunks_exact(4) { @@ -241,7 +241,7 @@ pub fn reserve(flags: u8, langtype: &str, content: usize, cap: usize) -> Option< || decimal(&langtype[1..end]).is_none() || !matches!( &langtype[end + 1..], - "char/utf8" | "byte" | "char/utf32" | "char/ascii" + "char/utf8" | "uint8" | "char/utf32" | "char/ascii" ) { return None; diff --git a/src/metadata.rs b/src/metadata.rs index 5568462..e2f6104 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -40,7 +40,7 @@ pub fn encode(ro: bool, vid: u32) -> Option> { let mut body = [0u8; 5]; body[0] = u8::from(ro); body[1..].copy_from_slice(&vid.to_le_bytes()); - headlenpow::encode(6, 1, 5, 5, "[5]byte", &body, 5) + headlenpow::encode(6, 1, 5, 5, "[5]uint8", &body, 5) } pub fn decode(data: &[u8]) -> Option<(bool, u32)> { @@ -49,7 +49,7 @@ pub fn decode(data: &[u8]) -> Option<(bool, u32)> { || h.flags != 1 || h.a != 5 || h.b != 5 - || h.langtype != "[5]byte" + || h.langtype != "[5]uint8" || h.body[0] > 1 { return None; diff --git a/src/xvalue.rs b/src/xvalue.rs index c3a0c0c..5e17e2e 100644 --- a/src/xvalue.rs +++ b/src/xvalue.rs @@ -422,7 +422,7 @@ pub fn encode_head(kind: &str, r#ref: i32, dims: &[i32], raw: &[u8]) -> Vec return Vec::new(); } else if kind.is_empty() || kind == "None" { (5, 0, 0, 0, String::new()) - } else if matches!(kind, "char/utf8" | "char/ascii" | "char/utf32" | "byte") { + } else if matches!(kind, "char/utf8" | "char/ascii" | "char/utf32") { let count = match kind { "char/utf8" => std::str::from_utf8(raw).ok().map(|s| s.chars().count()), "char/ascii" if raw.is_ascii() => Some(raw.len()), @@ -434,7 +434,6 @@ pub fn encode_head(kind: &str, r#ref: i32, dims: &[i32], raw: &[u8]) -> Vec { Some(raw.len() / 4) } - "byte" => Some(raw.len()), _ => None, }; let Some(count) = count else {