stix_rs/observables/
windows_registry_key.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct WindowsRegistryKey {
6 pub key: Option<String>,
7 pub values: Option<std::collections::HashMap<String, String>>,
8 #[serde(flatten)]
9 pub custom_properties: std::collections::HashMap<String, serde_json::Value>,
10}
11
12impl WindowsRegistryKey {
13 pub fn builder() -> WindowsRegistryKeyBuilder {
14 WindowsRegistryKeyBuilder::default()
15 }
16}
17
18#[derive(Debug, Default)]
19pub struct WindowsRegistryKeyBuilder {
20 key: Option<String>,
21 values: Option<std::collections::HashMap<String, String>>,
22 custom_properties: std::collections::HashMap<String, serde_json::Value>,
23}
24
25impl WindowsRegistryKeyBuilder {
26 pub fn key(mut self, k: impl Into<String>) -> Self {
27 self.key = Some(k.into());
28 self
29 }
30 pub fn values(mut self, v: std::collections::HashMap<String, String>) -> Self {
31 self.values = Some(v);
32 self
33 }
34 pub fn property(mut self, k: impl Into<String>, v: impl Into<serde_json::Value>) -> Self {
35 self.custom_properties.insert(k.into(), v.into());
36 self
37 }
38 pub fn build(self) -> WindowsRegistryKey {
39 WindowsRegistryKey {
40 key: self.key,
41 values: self.values,
42 custom_properties: self.custom_properties,
43 }
44 }
45}
46
47impl From<WindowsRegistryKey> for crate::StixObjectEnum {
48 fn from(w: WindowsRegistryKey) -> Self {
49 crate::StixObjectEnum::WindowsRegistryKey(w)
50 }
51}