pub fn read_ascii(bytes: &[u8]) -> String {
    std::str::from_utf8(&bytes[..bytes.len()])
        .unwrap_or("")
        .trim_end_matches('\0')
        .to_string()
}

pub fn read_u32_le(bytes: &[u8]) -> u32 {
    if bytes.len() < 4 {
        0
    } else {
        u32::from_le_bytes(bytes[..4].try_into().unwrap())
    }
}

pub fn read_i16_le(bytes: &[u8]) -> i16 {
    if bytes.len() < 2 {
        0
    } else {
        i16::from_le_bytes(bytes[..2].try_into().unwrap())
    }
}
