pub trait Combinator: Viewwhere
Self::V: SecureSpecCombinator<SpecResult = <Self::Owned as View>::V>,{
type Result<'a>: View<V = <Self::Owned as View>::V>;
type Owned: View;
// Required methods
fn length(&self) -> Option<usize>;
fn parse<'a>(
&self,
s: &'a [u8],
) -> Result<(usize, Self::Result<'a>), ParseError>;
fn serialize(
&self,
v: Self::Result<'_>,
data: &mut Vec<u8>,
pos: usize,
) -> Result<usize, SerializeError>;
}
Expand description
Implementation for parser and serializer combinators. A combinator’s view must be a
SecureSpecCombinator
.
Required Associated Types§
Sourcetype Result<'a>: View<V = <Self::Owned as View>::V>
type Result<'a>: View<V = <Self::Owned as View>::V>
The result type of parsing and the input type of serialization.
Sourcetype Owned: View
type Owned: View
The owned parsed type. This is currently a hack to avoid lifetime bindings in SpecCombinator::SpecResult
, but it can be useful if we want to have functions that return owned values (e.g. Vec<T>
).
Required Methods§
Sourcefn length(&self) -> Option<usize>
fn length(&self) -> Option<usize>
The length of the output buffer, if known. This can be used to optimize serialization by pre-allocating the buffer.
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.