Lines
100 %
Functions
33.33 %
Branches
//! Auto-generated from doc/scripting/entity_registry.org.
//! Do not edit manually — edit the org file + cargo build.
//!
//! Name-bearing entity field layout for the host value decoder.
//! Field ORDER matches the wasm struct slot order in `ENTITY_SPECS`
//! (accessor rows, then struct-only extras), so a field's position
//! here is its `struct.get` index.
use crate::ast::EntityKind;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EntityFieldKind {
String,
Ratio,
I32,
Pair,
}
#[derive(Debug, Clone, Copy)]
pub struct EntityFieldLayout {
pub name: &'static str,
pub kind: EntityFieldKind,
pub struct EntityLayout {
pub kind: EntityKind,
pub label: &'static str,
pub fields: &'static [EntityFieldLayout],
pub const ENTITY_LAYOUTS: &[EntityLayout] = &[
EntityLayout {
kind: EntityKind::Account,
label: "account",
fields: &[
EntityFieldLayout {
name: "id",
kind: EntityFieldKind::String,
},
name: "name",
name: "parent",
name: "type",
],
kind: EntityKind::Commodity,
label: "commodity",
name: "symbol",
kind: EntityKind::Transaction,
label: "transaction",
name: "note",
name: "amount",
name: "post-date",
kind: EntityKind::Split,
label: "split",
name: "account-id",
name: "commodity-id",
name: "value",
kind: EntityFieldKind::Ratio,
kind: EntityKind::Tag,
label: "tag",
kind: EntityKind::Price,
label: "price",
name: "currency-id",
name: "price-date",
kind: EntityKind::SshKey,
label: "sshkey",
name: "fingerprint",
name: "key-type",
name: "created-at",
name: "last-used-at",
];
/// The decode layout for `kind`, or `None` for kinds with no field
/// layout (e.g. `Condition`, which isn't a server entity).
#[must_use]
pub fn entity_layout(kind: EntityKind) -> Option<&'static EntityLayout> {
ENTITY_LAYOUTS.iter().find(|l| l.kind == kind)