follow masque interface

This commit is contained in:
Jan Petykiewicz 2026-04-02 20:35:31 -07:00
commit d3bf15f47a

View file

@ -15,15 +15,15 @@ pub enum ErrType {
Failed(String),
}
pub fn fail<O>(input: &[u8], msg: String) -> IResult<O> {
pub fn fail<O>(input: &[u8], msg: String) -> IResult<'_, O> {
Err((input, ErrType::Failed(msg)))
}
pub fn incomplete<O>(input: &[u8], size: Option<usize>) -> IResult<O> {
pub fn incomplete<O>(input: &[u8], size: Option<usize>) -> IResult<'_, O> {
Err((input, ErrType::Incomplete(size)))
}
pub fn take_bytes<CC: Into<usize>>(input: &[u8], count: CC) -> IResult<&[u8]> {
pub fn take_bytes<CC: Into<usize>>(input: &[u8], count: CC) -> IResult<'_, &[u8]> {
let cc = count.into();
if input.len() < cc {
incomplete(input, Some(cc))
@ -37,19 +37,19 @@ pub fn take_bytes<CC: Into<usize>>(input: &[u8], count: CC) -> IResult<&[u8]> {
/*
* Parse functions
*/
pub fn parse_u16(input: &[u8]) -> IResult<u16> {
pub fn parse_u16(input: &[u8]) -> IResult<'_, u16> {
let (input, buf) = take_bytes(input, 2_usize)?;
let val = BigEndian::read_u16(buf);
Ok((input, val))
}
pub fn parse_int2(input: &[u8]) -> IResult<i16> {
pub fn parse_int2(input: &[u8]) -> IResult<'_, i16> {
let (input, buf) = take_bytes(input, 2_usize)?;
let val = BigEndian::read_i16(buf);
Ok((input, val))
}
pub fn parse_int4(input: &[u8]) -> IResult<i32> {
pub fn parse_int4(input: &[u8]) -> IResult<'_, i32> {
let (input, buf) = take_bytes(input, 4_usize)?;
let val = BigEndian::read_i32(buf);
Ok((input, val))
@ -67,14 +67,14 @@ pub fn decode_real8(int: u64) -> f64 {
mant * 2_f64.powi(exp2)
}
pub fn parse_real8(input: &[u8]) -> IResult<f64> {
pub fn parse_real8(input: &[u8]) -> IResult<'_, f64> {
let (input, buf) = take_bytes(input, 8_usize)?;
let data = BigEndian::read_u64(buf);
Ok((input, decode_real8(data)))
}
pub fn parse_datetime(input: &[u8]) -> IResult<[i16; 6]> {
pub fn parse_datetime(input: &[u8]) -> IResult<'_, [i16; 6]> {
let mut buf = [0_i16; 6];
let mut input = input;
for bb in &mut buf {
@ -85,7 +85,7 @@ pub fn parse_datetime(input: &[u8]) -> IResult<[i16; 6]> {
}
pub fn parse_bitarray(input: &[u8]) -> IResult<[bool; 16]> {
pub fn parse_bitarray(input: &[u8]) -> IResult<'_, [bool; 16]> {
let mut bits = [false; 16];
let (input, val) = parse_int2(input)?;
for (ii, bit) in bits.iter_mut().enumerate() {
@ -95,7 +95,7 @@ pub fn parse_bitarray(input: &[u8]) -> IResult<[bool; 16]> {
}
pub fn parse_ascii(input: &[u8], length: u16) -> IResult<Vec<u8>> {
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];