Skip to main content

Identifier

Struct Identifier 

Source
pub struct Identifier { /* private fields */ }
Expand description

A STIX 2.1 compliant identifier that uniquely identifies a STIX Object.

It consists of two parts, the object-type and a UUID. The object type must exactly match the type property of the object being identified or referenced. The UUID is either an RFC 9562 compliant UUIDv4 or UUIDv5. The latter is used only for Cyber-observable objects. Other objects SHOULD use UUIDv4.

Identifier impl’s Display and FromStr, and its String representation is {object-type}–{UUID}

For more information see https://docs.oasis-open.org/cti/stix/v2.1/os/stix-v2.1-os.html#_64yvzeku5a5c

Implementations§

Source§

impl Identifier

Source

pub fn new(object_type: &str) -> Result<Self, Error>

Create a UUIDv4 identifier, used for any Stix Object that is not a Cyber-observable object. For SCOs, generates a UUIDv5 with empty properties as a fallback (legacy behavior for test IDs and refs). The builder path uses UUIDv4 when no contributing properties exist, per STIX 2.1 spec section 2.9.

Source

pub fn new_v4(object_type: &str) -> Result<Self, Error>

Create a UUIDv4 identifier. For SCOs, this is the spec-compliant fallback when no ID contributing properties are present (STIX 2.1 spec section 2.9).

Source

pub fn new_v5<T: Serialize>( object_type: &str, contributing_properties: &HashMap<String, T>, ) -> Result<Self, Error>

Create a UUIDv5 identifier using the STIX 2.1 preferred namespace, used ONLY for Cyber-observable Objects The value of the name portion should be the list of “ID Contributing Properties” (property-name and property value pairs), as defined on each object.

Source

pub fn get_type(&self) -> &str

Returns the object-type of the identifier

Trait Implementations§

Source§

impl Clone for Identifier

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Identifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Identifier

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Identifier
where Self: FromStr, <Self as FromStr>::Err: Display,

Source§

fn deserialize<__D>(deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Identifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Identifier

Source§

impl FromStr for Identifier

Source§

type Err = StixError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Identifier

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Identifier
where Self: Display,

Source§

fn serialize<__S>(&self, serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Stix for Identifier

Source§

fn check(&self, ctx: &mut CheckContext) -> Result<(), Error>

Ensures that all fields in the object or property conform to STIX 2.1. Read more
Source§

fn stix_check(&self) -> Result<(), Error>

Compatibility wrapper that runs Stix::check and discards warnings.
Source§

fn outcome(&self) -> Outcome<()>

Runs Stix::check and returns the collected warnings alongside the pass/fail result.
Source§

impl StructuralPartialEq for Identifier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.