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§
Sourcefn decode_scalar<'a>(&self, data: &'a [u8]) -> Cow<'a, str>
fn decode_scalar<'a>(&self, data: &'a [u8]) -> Cow<'a, str>
Decode raw scalar bytes into text.
Sourcefn skip_value(cx: &mut BinaryFormatContext<'_, '_, Self>) -> Result<(), Error>
fn skip_value(cx: &mut BinaryFormatContext<'_, '_, Self>) -> Result<(), Error>
Skip the next semantic value without decoding it.
Sourcefn deserialize_any<'de, V>(
cx: &mut BinaryFormatContext<'_, 'de, Self>,
visitor: V,
) -> Result<V::Value, Error>where
V: PdxVisitor<'de>,
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§
Sourcefn on_key(&mut self, _id: LexemeId)
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.
Sourcefn deserialize_i32<'de, V>(
cx: &mut BinaryFormatContext<'_, 'de, Self>,
visitor: V,
) -> Result<V::Value, Error>where
V: PdxVisitor<'de>,
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.
Sourcefn deserialize_u32<'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>,
Attempt to deserialize the next value as u32.
Sourcefn deserialize_i64<'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>,
Attempt to deserialize the next value as i64.
Sourcefn deserialize_u64<'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>,
Attempt to deserialize the next value as u64.
Sourcefn deserialize_f32<'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>,
Attempt to deserialize the next value as f32.
Sourcefn deserialize_f64<'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>,
Attempt to deserialize the next value as f64.
Sourcefn deserialize_bool<'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>,
Attempt to deserialize the next value as bool.
Sourcefn deserialize_str<'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>,
Attempt to deserialize the next value as a string-like scalar.
Sourcefn deserialize_bytes<'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>,
Attempt to deserialize the next value as raw bytes.
Sourcefn deserialize_identifier<'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>,
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".