master
Bradlee Speice 2019-04-18 11:31:33 -04:00
parent 5c5d84a57b
commit 7d297b884a
1 changed files with 14 additions and 9 deletions

View File

@ -14,8 +14,7 @@ impl<'a> From<io::Error> for KaitaiError<'a> {
pub type Result<'a, T> = std::result::Result<T, KaitaiError<'a>>; pub type Result<'a, T> = std::result::Result<T, KaitaiError<'a>>;
pub trait KaitaiStruct<'a> pub trait KaitaiStruct<'a> {
{
type Parent: KaitaiStruct<'a>; type Parent: KaitaiStruct<'a>;
type Root: KaitaiStruct<'a>; type Root: KaitaiStruct<'a>;
@ -112,23 +111,23 @@ pub trait KaitaiStream {
} }
struct BytesReader<'a> { struct BytesReader<'a> {
bytes: &'a[u8], bytes: &'a [u8],
pos: usize, pos: usize,
bits: u8, bits: u8,
bits_left: u8, bits_left: u8,
} }
impl<'a> BytesReader<'a> { impl<'a> BytesReader<'a> {
fn new(bytes: &'a[u8]) -> Self { fn new(bytes: &'a [u8]) -> Self {
BytesReader { BytesReader {
bytes, bytes,
pos: 0, pos: 0,
bits: 0, bits: 0,
bits_left: 0 bits_left: 0,
} }
} }
} }
impl<'a> From<&'a[u8]> for BytesReader<'a> { impl<'a> From<&'a [u8]> for BytesReader<'a> {
fn from(b: &'a[u8]) -> Self { fn from(b: &'a [u8]) -> Self {
BytesReader::new(b) BytesReader::new(b)
} }
} }
@ -237,7 +236,13 @@ impl<'a> KaitaiStream for BytesReader<'a> {
unimplemented!() unimplemented!()
} }
fn read_bytes_term(&mut self, term: char, include: bool, consume: bool, eos_error: bool) -> io::Result<&[u8]> { fn read_bytes_term(
&mut self,
term: char,
include: bool,
consume: bool,
eos_error: bool,
) -> io::Result<&[u8]> {
unimplemented!() unimplemented!()
} }
} }
@ -253,4 +258,4 @@ mod tests {
assert_eq!([1, 2, 3, 4], c); assert_eq!([1, 2, 3, 4], c);
} }
} }