htl_core/teal.rs
1//! Rust <-> Teal type bridge used by `#[derive(TealRecord)]` and `#[host_module]`.
2//!
3//! The macros map Rust types to Teal type names *syntactically* at expansion time
4//! (`f64 -> number`, `String -> string`, `Vec<T> -> {T}`, ...). This module holds the
5//! runtime-side traits the generated code implements.
6
7/// A Rust struct mirrored as a Teal `record` (plain table with named fields).
8pub trait TealRecord {
9 /// Teal record name (also the module name of its `.d.tl`).
10 const NAME: &'static str;
11 /// Full `.d.tl` text: `local record NAME ... end return NAME`.
12 const DECL: &'static str;
13}
14
15/// A Rust type exposed to Teal as a userdata module via `#[host_module]`.
16pub trait HostModule {
17 /// Module name used in `require("...")`.
18 const MODULE: &'static str;
19 /// Full `.d.tl` text for the module.
20 const DECL: &'static str;
21}