fix(writer): serialize complete records with correctly sized buffers

Include record headers in wire lengths, allocate initialized array and padded string buffers, and handle empty strings. Write all bytes to short writers and reject oversized records before writing.
This commit is contained in:
Jan Petykiewicz 2026-11-14 14:37:35 -08:00
commit 3783320f82

View file

@ -98,8 +98,7 @@ pub fn parse_bitarray(input: &[u8]) -> IResult<'_, [bool; 16]> {
pub fn parse_ascii(input: &[u8], length: u16) -> IResult<'_, Vec<u8>> {
let length = length as usize;
let (input, data) = take_bytes(input, length)?;
let last = data[length - 1];
let true_length = if last == 0 { length - 1 } else { length };
let true_length = length - usize::from(data.last() == Some(&0));
let vec = data[..true_length].to_vec();
Ok((input, vec))
}