Skip to main content

sim_table_hash/
citizen.rs

1//! Citizen descriptor for the hash table class, mapping table entries to and
2//! from their serialized expression form via [`hash_table_class_symbol`] and
3//! [`HashTableDescriptor`].
4
5use sim_citizen_derive::Citizen;
6use sim_kernel::{Expr, Symbol};
7
8/// Serialized form of a [`HashTable`](crate::HashTable): the citizen descriptor
9/// holding the table's entries as key/expression pairs.
10///
11/// Produced when a hash table is encoded and read back when a `table/HashTable`
12/// constructor is decoded.
13#[derive(Clone, Debug, Default, PartialEq, Citizen)]
14#[citizen(symbol = "table/HashTable", version = 0)]
15pub struct HashTableDescriptor {
16    /// 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/HashTable`) for the hash table
23/// citizen.
24pub fn hash_table_class_symbol() -> Symbol {
25    Symbol::qualified("table", "HashTable")
26}