Add a unit type for KStruct

master
Bradlee Speice 2019-04-23 13:17:42 -04:00
parent a079b75c6e
commit 10b7219633
1 changed files with 15 additions and 0 deletions

View File

@ -28,6 +28,21 @@ pub trait KStruct<'a> {
fn read<S: KStream>(&mut self, stream: &mut S) -> KResult<'a, ()>;
}
pub struct KStructUnit<'a>;
impl<'a> KStruct<'a> for KStructUnit<'a> {
type Parent = KStructUnit<'a>;
type Root = KStructUnit<'a>;
fn new(_parent: Option<&'a Self::Parent>, _root: Option<&'a Self::Root>) -> Result<Self, KError<'a>> where
Self: Sized {
Ok(KStructUnit)
}
fn read<S: KStream>(&mut self, stream: &mut S) -> Result<(), KError<'a>> {
Ok(())
}
}
pub trait KStream {
fn is_eof(&self) -> io::Result<bool>;
fn seek(&mut self, position: u64) -> io::Result<()>;