Skip to main content

Module leaf_serialization

Module leaf_serialization 

Source
Expand description

Type-level lists for deserializing type-erased leaf configs at replay time.

During recording, leaf element configs (text, images, custom widgets) are serialized into LeafConfigData blobs without preserving their Rust type. At replay, the LeafConfigList chain tells the interpreter which concrete types to try, in order.

§Building a leaf type list

Start with LeafConfigListNil (the empty list) and extend it using LeafConfigList::new or LeafConfigList::extend:

use cotis_modules_debug::serialize_targets::leaf_serialization::{LeafConfigList, LeafConfigListNil};

// Single leaf type:
type Leafs = LeafConfigList<TextElementConfig<'static>, LeafConfigListNil>;
let leafs = Leafs::new();

// Multiple leaf types (order matters — see below):
type Leafs = LeafConfigList<
    TextElementConfig<'static>,
    LeafConfigList<ImageElementConfig<'static>, LeafConfigListNil>,
>;
let leafs = LeafConfigList::<TextElementConfig<'static>, _>::extend();

§Deserialization order

When replaying a LeafConfig instruction, the list tries to deserialize the JSON blob as the head type first. If that fails, it recurses to the tail. Put more specific leaf types before more general ones to avoid ambiguous matches.

Structs§

LeafConfigData
Type-erased JSON storage for a leaf element config recorded during stage 1.
LeafConfigList
A type-level cons-list of leaf config types used for replay deserialization.
LeafConfigListNil
Terminal node of a LeafConfigList chain (empty list).

Traits§

LeafConfigListCompatible
Type-level dispatch for replaying LeafConfigData against open elements.