sim_table_lazy/citizen.rs
1//! Citizen descriptor for the lazy table class, mapping forced table entries to
2//! and from their serialized expression form via [`lazy_table_class_symbol`]
3//! and [`LazyTableDescriptor`].
4
5use sim_citizen_derive::Citizen;
6use sim_kernel::{Expr, Symbol};
7
8/// Serialized form of a [`LazyTable`](crate::LazyTable): the citizen descriptor
9/// holding the table's (forced) entries as key/expression pairs.
10///
11/// Produced when a lazy table is encoded -- which forces every loader -- and
12/// read back when a `table/LazyTable` constructor is decoded.
13#[derive(Clone, Debug, Default, PartialEq, Citizen)]
14#[citizen(symbol = "table/LazyTable", version = 0)]
15pub struct LazyTableDescriptor {
16 /// Forced table entries as key/expression pairs, serialized via the shared
17 /// `sim_table_core::citizen_fields::entries` codec.
18 #[citizen(with = "sim_table_core::citizen_fields::entries")]
19 pub entries: Vec<(Symbol, Expr)>,
20}
21
22/// The fully qualified class symbol (`table/LazyTable`) for the lazy table
23/// citizen.
24pub fn lazy_table_class_symbol() -> Symbol {
25 Symbol::qualified("table", "LazyTable")
26}