Skip to main content

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    fn to_schema(&self) -> JsonValue;
14
15    fn to_json_value(&self) -> Result<JsonValue, serde_json::Error> {
16        serde_json::to_value(self)
17    }
18}
19
20pub trait ArtifactSchema {
21    fn generate_schema(&self) -> JsonValue;
22}