use crate::Error;
pub mod decodable;
pub mod encodable;
mod impls;
pub trait SizeHint {
fn size_hint(data: &[u8], offset: usize) -> Result<usize, Error>;
fn size_hint_(&self, data: &[u8], offset: usize) -> Result<usize, Error>;
}
pub trait GetSize {
fn get_size(&self) -> usize;
}
pub trait Fixed {
const SIZE: usize;
}
pub trait Variable {
const HEADER_SIZE: usize;
const MAX_SIZE: usize;
fn inner_size(&self) -> usize;
fn get_header(&self) -> Vec<u8>;
}
impl<T: Fixed> SizeHint for T {
fn size_hint(_data: &[u8], _offset: usize) -> Result<usize, Error> {
Ok(Self::SIZE)
}
fn size_hint_(&self, _: &[u8], _offset: usize) -> Result<usize, Error> {
Ok(Self::SIZE)
}
}
impl<T: Fixed> GetSize for T {
fn get_size(&self) -> usize {
Self::SIZE
}
}