Skip to main content

stix_rs/observables/
ipv4_addr.rs

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