Attribute Macro stix::custom_properties [−][src]
#[custom_properties]
Make a container for custom properties on a STIX object.
The STIX specification allows namespaced custom properties, which should be named as
x_$NAMESPACE_$PROPERTY_NAME
. This macro handles the renaming of all the struct’s fields
for deserialization.
Example
ⓘ
use std::collections::BTreeSet; use serde::Deserialize; use stix::CommonProperties; // These are the additional properties MITRE defines. This struct is public so that // other STIX crates can include it as a member in their final `AttackPattern` struct. #[stix::custom_properties(namespace = "mitre")] #[derive(Default, Deserialize)] #[serde(default)] pub struct MitreMalware { // This will deserialize from `x_mitre_aliases` pub aliases: BTreeSet<String>, pub platforms: BTreeSet<String>, } // This is the combination of the standards-defined properties and the MITRE properties. // This is exposed as `AttackPattern` so that `attck::AttackPattern` is immediately usable // for working with STIX data. #[derive(Deserialize, stix::TypedObject)] pub struct Malware { // Both declarations are marked flatten here so they merge. #[serde(flatten)] pub base: stix::Malware, #[serde(flatten)] pub mitre: MitreMalware, }