sqlite-decoder 0.1.1

SQLite WAL and database formats decoder
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::IResult;
use nom::bytes::complete::take;

pub(crate) fn read_u32(input: &[u8]) -> IResult<&[u8], u32> {
    let (input, value) = take(4usize)(input)?;
    Ok((input, u32::from_be_bytes(value.try_into().unwrap())))
}

pub(crate) fn read_u16(input: &[u8]) -> IResult<&[u8], u16> {
    let (input, value) = take(2usize)(input)?;
    Ok((input, u16::from_be_bytes(value.try_into().unwrap())))
}

pub(crate) fn read_u8(input: &[u8]) -> IResult<&[u8], u8> {
    let (input, value) = take(1usize)(input)?;
    Ok((input, u8::from_be_bytes(value.try_into().unwrap())))
}