Skip to main content

stix_rs/observables/
mac_addr.rs

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