stix_rs/observables/
directory.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct Directory {
6 pub path: Option<String>,
7 pub path_enc: Option<String>,
8 #[serde(flatten)]
9 pub custom_properties: std::collections::HashMap<String, serde_json::Value>,
10}
11
12impl Directory { pub fn builder() -> DirectoryBuilder { DirectoryBuilder::default() } }
13
14#[derive(Debug, Default)]
15pub struct DirectoryBuilder { path: Option<String>, path_enc: Option<String>, custom_properties: std::collections::HashMap<String, serde_json::Value> }
16
17impl DirectoryBuilder {
18 pub fn path(mut self, p: impl Into<String>) -> Self { self.path = Some(p.into()); self }
19 pub fn path_enc(mut self, p: impl Into<String>) -> Self { self.path_enc = Some(p.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) -> Directory { Directory { path: self.path, path_enc: self.path_enc, custom_properties: self.custom_properties } }
22}
23
24impl From<Directory> for crate::StixObjectEnum { fn from(d: Directory) -> Self { crate::StixObjectEnum::Directory(d) } }