yoagent_state/
artifact.rs1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value as JsonValue};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct ArtifactRef {
6 pub kind: String,
7 pub uri: String,
8 pub hash: Option<String>,
9 pub summary: Option<String>,
10 pub metadata: JsonValue,
11}
12
13impl ArtifactRef {
14 pub fn new(kind: impl Into<String>, uri: impl Into<String>) -> Self {
15 Self {
16 kind: kind.into(),
17 uri: uri.into(),
18 hash: None,
19 summary: None,
20 metadata: JsonValue::Object(Map::new()),
21 }
22 }
23
24 pub fn with_hash(mut self, hash: impl Into<String>) -> Self {
25 self.hash = Some(hash.into());
26 self
27 }
28
29 pub fn with_summary(mut self, summary: impl Into<String>) -> Self {
30 self.summary = Some(summary.into());
31 self
32 }
33
34 pub fn with_metadata(mut self, metadata: JsonValue) -> Self {
35 self.metadata = metadata;
36 self
37 }
38}