Expand description
Converts bhtune-core’s serde-tagged enums to/from the plain TEXT values SQLite stores
them as.
bhtune-core deliberately has zero non-serde dependencies (see its crate docs), so it
cannot derive sqlx::Type itself, and Rust’s orphan rules mean bhtune-db cannot
implement a foreign trait (sqlx::Type) for a foreign type (e.g.
bhtune_core::ProcessType) either. Rather than defining a parallel sqlx-aware enum for
every bhtune-core enum (eight of them, and rising), enum_to_text and
text_to_enum reuse each enum’s existing #[serde(rename_all = "snake_case")]
implementation as the single source of truth for its wire form — the same string a
ProcessType would serialize to over the CLI’s --output json or the web GUI’s HTTP API
already matches what gets stored in a TEXT column.
Functions§
- enum_
to_ text - Encodes a fieldless,
serde-tagged enum as the bare string SQLite stores it as. - text_
to_ enum - Decodes a value read from
columnback into a fieldless,serde-tagged enum.