systemprompt_models/artifacts/traits.rs
1//! Traits artifacts implement to expose their type, schema, and JSON form.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::Serialize;
7use serde_json::Value as JsonValue;
8
9use super::types::ArtifactType;
10
11pub trait Artifact: Serialize {
12 fn artifact_type(&self) -> ArtifactType;
13 // JSON: JSON Schema document describing the artifact for the model.
14 fn to_schema(&self) -> JsonValue;
15
16 // JSON: Artifact rendered as the A2A `DataPart.data` object.
17 fn to_json_value(&self) -> Result<JsonValue, serde_json::Error> {
18 serde_json::to_value(self)
19 }
20}
21
22pub trait ArtifactSchema {
23 // JSON: JSON Schema document describing the artifact for the model.
24 fn generate_schema(&self) -> JsonValue;
25}