You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User code that wants to serialize their #[BamlType] structs to JSON/disk
Options:
Have #[BamlType] also derive Serialize, Deserialize by default (most user-friendly, slight compile overhead)
Add an opt-in: #[BamlType(serde)] that adds the derives
Leave it to users to derive serde themselves alongside #[BamlType]
Option 1 seems right for a framework crate — users expect their data types to be serializable. The macro already adds #[derive(Facet)]; adding #[derive(Serialize, Deserialize)] is the same pattern.
Activity
darinkishore commentedon Feb 12, 2026
Codebase audit
BamlTypetrait (bamltype/src/lib.rs:99-105):BamlSchemarequiresFacetbut notSerialize/Deserialize. The#[BamlType]macro derivesFacetonly.Where serde would be needed:
CacheEntrystoresPredictionwhich isSerialize + Deserialize)#[BamlType]structs to JSON/diskOptions:
#[BamlType]also deriveSerialize, Deserializeby default (most user-friendly, slight compile overhead)#[BamlType(serde)]that adds the derives#[BamlType]Option 1 seems right for a framework crate — users expect their data types to be serializable. The macro already adds
#[derive(Facet)]; adding#[derive(Serialize, Deserialize)]is the same pattern.