stix_rs/observables/
artifact.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct Artifact {
6 pub value: Option<String>,
7 #[serde(flatten)]
8 pub custom_properties: std::collections::HashMap<String, serde_json::Value>,
9}
10
11impl Artifact {
12 pub fn builder() -> ArtifactBuilder { ArtifactBuilder::default() }
13}
14
15#[derive(Debug, Default)]
16pub struct ArtifactBuilder { value: Option<String>, custom_properties: std::collections::HashMap<String, serde_json::Value> }
17
18impl ArtifactBuilder {
19 pub fn value(mut self, v: impl Into<String>) -> Self { self.value = Some(v.into()); self }
20 pub fn property(mut self, k: impl Into<String>, v: impl Into<serde_json::Value>) -> Self { self.custom_properties.insert(k.into(), v.into()); self }
21 pub fn build(self) -> Artifact { Artifact { value: self.value, custom_properties: self.custom_properties } }
22}
23
24impl From<Artifact> for crate::StixObjectEnum { fn from(a: Artifact) -> Self { crate::StixObjectEnum::Artifact(a) } }