Add an UnknownEnum error type, make KaitaiStruct optional for parents

This commit is contained in:
Bradlee Speice 2019-04-22 12:01:01 -04:00
parent 7d297b884a
commit f9ae7b76cb

View File

@ -4,6 +4,7 @@ use std::io;
pub enum KaitaiError<'a> { pub enum KaitaiError<'a> {
InvalidContents { actual: &'a [u8] }, InvalidContents { actual: &'a [u8] },
IoError(io::Error), IoError(io::Error),
UnknownEnum(u64),
} }
impl<'a> From<io::Error> for KaitaiError<'a> { impl<'a> From<io::Error> for KaitaiError<'a> {
@ -15,7 +16,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>;
/// Create a new instance of this struct; if we are the root node, /// Create a new instance of this struct; if we are the root node,