Struct jomini::BinaryTape
source · pub struct BinaryTape<'a> { /* private fields */ }
Expand description
Houses the tape of tokens that is extracted from binary data
Implementations§
source§impl<'a> BinaryTape<'a>
impl<'a> BinaryTape<'a>
sourcepub fn from_slice(data: &[u8]) -> Result<BinaryTape<'_>, Error>
pub fn from_slice(data: &[u8]) -> Result<BinaryTape<'_>, Error>
Convenience method for creating a binary parser and parsing the given input
Examples found in repository?
src/binary/de.rs (line 119)
110 111 112 113 114 115 116 117 118 119 120 121
pub fn from_slice<'a, 'b, 'res: 'a, RES, T>(
&'b self,
data: &'a [u8],
resolver: &'res RES,
) -> Result<T, Error>
where
T: Deserialize<'a>,
RES: TokenResolver,
{
let tape = BinaryTape::from_slice(data)?;
self.from_tape(&tape, resolver)
}
sourcepub fn tokens(&self) -> &[BinaryToken<'a>]
pub fn tokens(&self) -> &[BinaryToken<'a>]
Return the parsed tokens
Examples found in repository?
src/binary/de.rs (line 140)
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
pub fn from_tape<'a, 'b, 'c, 'res: 'a, RES, T>(
&'b self,
tape: &'c BinaryTape<'a>,
resolver: &'res RES,
) -> Result<T, Error>
where
T: Deserialize<'a>,
RES: TokenResolver,
{
let config = BinaryConfig {
resolver,
failed_resolve_strategy: self.failed_resolve_strategy,
encoding: &self.flavor,
};
let deserializer = RootDeserializer {
tokens: tape.tokens(),
config: &config,
};
Ok(T::deserialize(deserializer)?)
}
Trait Implementations§
source§impl<'a> Debug for BinaryTape<'a>
impl<'a> Debug for BinaryTape<'a>
source§impl<'a> Default for BinaryTape<'a>
impl<'a> Default for BinaryTape<'a>
source§fn default() -> BinaryTape<'a>
fn default() -> BinaryTape<'a>
Returns the “default value” for a type. Read more