pub trait AiJsonTemplate:
Clone
+ Debug
+ LoadFromFile
+ SaveToFile<Error = SaveLoadError>
+ Serialize
+ for<'a> Deserialize<'a> {
// Required method
fn to_template() -> Value;
}
Expand description
The derived code implements AiJsonTemplate
for each struct, letting you
call MyStruct::to_template()
to get a JSON “schema” describing how the
AI should produce data that matches this layout.
Required Methods§
Sourcefn to_template() -> Value
fn to_template() -> Value
Return a JSON template describing how the AI’s output should be structured. This might include doc comments or other instructions for each field.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl AiJsonTemplate for String
impl AiJsonTemplate for String
fn to_template() -> Value
Source§impl<K, V> AiJsonTemplate for HashMap<K, V>where
K: Send + Sync + AiJsonTemplate + Eq + Hash + 'static,
V: Send + Sync + AiJsonTemplate + 'static,
Provides a blanket AiJsonTemplate implementation for HashMap<K, V>,
so long as K and V each implement AiJsonTemplate (and K also implements Eq + Hash).
impl<K, V> AiJsonTemplate for HashMap<K, V>where
K: Send + Sync + AiJsonTemplate + Eq + Hash + 'static,
V: Send + Sync + AiJsonTemplate + 'static,
Provides a blanket AiJsonTemplate implementation for HashMap<K, V>, so long as K and V each implement AiJsonTemplate (and K also implements Eq + Hash).
fn to_template() -> Value
Source§impl<T> AiJsonTemplate for Vec<T>
Blanket impl for Vec<T>
if T: AiJsonTemplate
.
impl<T> AiJsonTemplate for Vec<T>
Blanket impl for Vec<T>
if T: AiJsonTemplate
.
This treats the field as "array_of"
in the JSON schema, referencing
T::to_template()
for the item template. We add disclaimers saying we
expect a top-level JSON array, not item-level justification.