Skip to main content

BinaryFormat

Trait BinaryFormat 

Source
pub trait BinaryFormat: Sized {
Show 17 methods // Required methods fn decode_scalar<'a>(&self, data: &'a [u8]) -> Cow<'a, str>; fn skip_value( cx: &mut BinaryFormatContext<'_, '_, Self>, ) -> Result<(), Error>; fn deserialize_any<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de>; // Provided methods fn on_key(&mut self, _id: LexemeId) { ... } fn on_open(&mut self) { ... } fn on_equal(&mut self) { ... } fn on_close(&mut self) { ... } fn deserialize_i32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_u32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_i64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_u64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_f32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_f64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_bool<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_str<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_bytes<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... } fn deserialize_identifier<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error> where V: PdxVisitor<'de> { ... }
}
Expand description

Semantic decoding for a game-specific binary format.

A BinaryFormat is the extension point for deserializing the binary formats of individual games and patches. The BinaryFormatDeserializer handles structural traversal (maps, sequences, enums, and the {, }, = delimiters) while the format decodes the value and identifier lexemes.

Implementations receive a BinaryFormatContext, which exposes source access and the format state while keeping deserializer traversal internals private.

Structural delimiters ({, }, =) are coordinated with the deserializer. Formats that consume OPEN should call BinaryFormatContext::visit_open_seq after advancing the source so the deserializer can drive container traversal. EQUAL and CLOSE remain part of map and sequence traversal.

Required Methods§

Source

fn decode_scalar<'a>(&self, data: &'a [u8]) -> Cow<'a, str>

Decode raw scalar bytes into text.

Source

fn skip_value(cx: &mut BinaryFormatContext<'_, '_, Self>) -> Result<(), Error>

Skip the next semantic value without decoding it.

Source

fn deserialize_any<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Deserialize the next value without a type hint.

Provided Methods§

Source

fn on_key(&mut self, _id: LexemeId)

Reports a map key’s lexeme id, letting a stateful format remember the previous field so later values can be decoded accordingly.

Called before the key is consumed, so do not advance the source. The id is the raw token for token keys, or QUOTED/UNQUOTED for string keys.

Source

fn on_open(&mut self)

Called after the deserializer consumes a structural opening delimiter.

Source

fn on_equal(&mut self)

Called after the deserializer consumes a structural =.

Source

fn on_close(&mut self)

Called after the deserializer consumes a structural closing delimiter.

Source

fn deserialize_i32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as i32.

Source

fn deserialize_u32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as u32.

Source

fn deserialize_i64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as i64.

Source

fn deserialize_u64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as u64.

Source

fn deserialize_f32<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as f32.

Source

fn deserialize_f64<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as f64.

Source

fn deserialize_bool<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as bool.

Source

fn deserialize_str<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as a string-like scalar.

Source

fn deserialize_bytes<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as raw bytes.

Source

fn deserialize_identifier<'de, V>( cx: &mut BinaryFormatContext<'_, 'de, Self>, visitor: V, ) -> Result<V::Value, Error>
where V: PdxVisitor<'de>,

Attempt to deserialize the next value as an identifier.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§