Skip to main content

stix_rs/observables/
ipv6_addr.rs

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