use cbor4ii::core::{dec, error::Len};
use super::error::DecodeError;
#[allow(dead_code)]
pub(crate) mod marker {
pub const START: u8 = 0x1f;
pub const FALSE: u8 = 0xf4; pub const TRUE: u8 = 0xf5; pub const NULL: u8 = 0xf6; pub const UNDEFINED: u8 = 0xf7; pub const F16: u8 = 0xf9;
pub const F32: u8 = 0xfa;
pub const F64: u8 = 0xfb;
pub const BREAK: u8 = 0xff;
}
#[inline]
pub(crate) fn peek_one<'a, R: dec::Read<'a>>(
name: &'static str,
reader: &mut R,
) -> Result<u8, DecodeError<R::Error>> {
let buf = match reader.fill(1)? {
dec::Reference::Long(buf) => buf,
dec::Reference::Short(buf) => buf,
};
let byte = buf.first().copied().ok_or(DecodeError::Eof {
name,
expect: Len::new(1),
})?;
Ok(byte)
}
#[inline]
pub(crate) fn pull_one<'a, R: dec::Read<'a>>(
name: &'static str,
reader: &mut R,
) -> Result<u8, DecodeError<R::Error>> {
let byte = peek_one(name, reader)?;
reader.advance(1);
Ok(byte)
}