pub struct CommonProperties {
pub type: String,
pub id: String,
pub schema_version: Option<String>,
pub created: DateTime<Utc>,
pub modified: DateTime<Utc>,
pub created_by_ref: Option<String>,
pub custom_properties: HashMap<String, Value>,
}Expand description
Common properties shared by MAEC top-level objects
These properties are flattened into each MAEC object type via serde, providing consistent ID generation, timestamping, and metadata.
Fields§
§type: StringThe type of MAEC object (e.g., “package”, “malware-family”)
id: StringUnique identifier for this object (format: “type–uuid”)
schema_version: Option<String>MAEC specification version (should be “5.0”)
created: DateTime<Utc>Timestamp when the object was created
modified: DateTime<Utc>Timestamp when the object was last modified
created_by_ref: Option<String>Reference to the identity that created this object
custom_properties: HashMap<String, Value>Custom properties for extensions
Implementations§
Source§impl CommonProperties
impl CommonProperties
Sourcepub fn new(
object_type: impl Into<String>,
created_by_ref: Option<String>,
) -> Self
pub fn new( object_type: impl Into<String>, created_by_ref: Option<String>, ) -> Self
Creates a new CommonProperties instance
§Arguments
object_type- The MAEC object type (e.g., “package”, “malware-family”)created_by_ref- Optional reference to the creating identity
§Examples
use maec::common::CommonProperties;
let common = CommonProperties::new("malware-family", None);
assert_eq!(common.r#type, "malware-family");
assert_eq!(common.schema_version, Some("5.0".to_string()));Sourcepub fn new_version(&mut self)
pub fn new_version(&mut self)
Creates a new version of this object by updating the modified timestamp
In MAEC (like STIX), when you update an object, you keep the same ID and created timestamp but update the modified timestamp to indicate a new version.
§Examples
use maec::common::CommonProperties;
use std::thread;
use std::time::Duration;
let mut common = CommonProperties::new("malware-family", None);
let original_modified = common.modified;
thread::sleep(Duration::from_millis(10));
common.new_version();
assert!(common.modified > original_modified);
assert_eq!(common.created, original_modified); // created unchangedTrait Implementations§
Source§impl Clone for CommonProperties
impl Clone for CommonProperties
Source§fn clone(&self) -> CommonProperties
fn clone(&self) -> CommonProperties
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more