Struct jomini::BinaryTape

source ·
pub struct BinaryTape<'a> { /* private fields */ }
Expand description

Houses the tape of tokens that is extracted from binary data

Implementations§

Creates an empty tape

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)
    }

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§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.