1use serde::{Deserialize, Serialize};
2use stix_rs::{CommonProperties, StixObject};
3use crate::domain::AttackObject;
4
5#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct Matrix {
11 #[serde(flatten)]
12 pub common: CommonProperties,
13
14 pub name: String,
15 pub description: Option<String>,
16
17 #[serde(default)]
19 pub tactic_refs: Vec<String>,
20
21 #[serde(default, rename = "x_mitre_version")]
23 pub version: Option<String>,
24
25 #[serde(default, rename = "x_mitre_domains")]
26 pub domains: Vec<String>,
27}
28
29impl StixObject for Matrix {
30 fn id(&self) -> &str {
31 &self.common.id
32 }
33
34 fn type_(&self) -> &str {
35 &self.common.r#type
36 }
37
38 fn created(&self) -> chrono::DateTime<chrono::Utc> {
39 self.common.created
40 }
41}
42
43impl AttackObject for Matrix {
44 fn name(&self) -> &str {
45 &self.name
46 }
47
48 fn description(&self) -> Option<&str> {
49 self.description.as_deref()
50 }
51
52 fn revoked(&self) -> bool {
53 self.common.revoked.unwrap_or(false)
54 }
55
56 fn deprecated(&self) -> bool {
57 self.common.custom_properties.get("x_mitre_deprecated").and_then(|v| v.as_bool()).unwrap_or(false)
58 }
59}