Skip to main content

stix_rs/observables/
mutex.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct Mutex {
6    pub name: Option<String>,
7    pub currently_owned: Option<bool>,
8    #[serde(flatten)]
9    pub custom_properties: std::collections::HashMap<String, serde_json::Value>,
10}
11
12impl Mutex { pub fn builder() -> MutexBuilder { MutexBuilder::default() } }
13
14#[derive(Debug, Default)]
15pub struct MutexBuilder { name: Option<String>, currently_owned: Option<bool>, custom_properties: std::collections::HashMap<String, serde_json::Value> }
16
17impl MutexBuilder {
18    pub fn name(mut self, n: impl Into<String>) -> Self { self.name = Some(n.into()); self }
19    pub fn currently_owned(mut self, v: bool) -> Self { self.currently_owned = Some(v); 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) -> Mutex { Mutex { name: self.name, currently_owned: self.currently_owned, custom_properties: self.custom_properties } }
22}
23
24impl From<Mutex> for crate::StixObjectEnum { fn from(m: Mutex) -> Self { crate::StixObjectEnum::Mutex(m) } }