pub trait Parse: Sized {
type Err: From<ShortBuf>;
// Required methods
fn parse(parser: &mut Parser) -> Result<Self, Self::Err>;
fn skip(parser: &mut Parser) -> Result<(), Self::Err>;
}
Expand description
A type that can extract a value from the beginning of a parser.
Types that implement this trait must use an encoding where the end of a
value in the parser can be determined from data read so far. These are
either fixed length types like u32
or types that either contain length
bytes or boundary markers.
Required Associated Types§
Required Methods§
Sourcefn parse(parser: &mut Parser) -> Result<Self, Self::Err>
fn parse(parser: &mut Parser) -> Result<Self, Self::Err>
Extracts a value from the beginning of parser
.
If parsing fails and an error is returned, the parser’s position should be considered to be undefined. If it supposed to be reused in this case, you should store the position before attempting to parse and seek to that position again before continuing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.