Struct Ref

Source
pub struct Ref<'id, 'collection: 'id, D> { /* private fields */ }
Expand description

An ID for a resource that may be in the backing collection.

Ref is used to allow exploration of STIX collections when not every object referenced is present in-memory.

Implementations§

Source§

impl<'id, 'collection: 'id, D> Ref<'id, 'collection, D>

Source

pub fn id(&self) -> &'id Id

The ID the Ref will look up in the collection.

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Declaration>

The ID of a STIX object of some type which may be present in the collection.

Source

pub fn downcast<D: TypedObject>(self) -> Option<Ref<'id, 'collection, D>>

Narrow the type of the reference so that it can be resolved to a Node. This requires knowing the concrete type of the data associated with the ID.

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, AttackPattern>

Source

pub fn resolve(self) -> Option<Node<'collection, AttackPattern>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, CourseOfAction>

Source

pub fn resolve(self) -> Option<Node<'collection, CourseOfAction>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Malware>

Source

pub fn resolve(self) -> Option<Node<'collection, Malware>>

Examples found in repository?
examples/actor_lookup.rs (line 18)
6fn display_actor<'a>(actor: &Node<'a, IntrusionSet>) {
7    println!("{} ({})", actor.name(), actor.id());
8    println!("============");
9
10    if let Some(description) = actor.description() {
11        println!("{}\n", description);
12    }
13
14    let mut malwares = actor.uses_malware().peekable();
15    if malwares.peek().is_some() {
16        println!("Malware:");
17        for malware in malwares {
18            match malware.resolve() {
19                Some(malware) => {
20                    println!("- {} ({})", malware.name(), malware.id());
21                }
22                None => {
23                    println!("- Unknown Malware");
24                }
25            }
26        }
27    }
28
29    let mut tools = actor.uses_tools().peekable();
30    if tools.peek().is_some() {
31        println!("Tools:");
32        for tool in tools {
33            match tool.resolve() {
34                Some(tool) => {
35                    println!("- {} ({})", tool.name(), tool.id());
36                }
37                None => {
38                    println!("- Unknown Tool");
39                }
40            }
41        }
42    }
43}
Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Matrix>

Source

pub fn resolve(self) -> Option<Node<'collection, Matrix>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Tactic>

Source

pub fn resolve(self) -> Option<Node<'collection, Tactic>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Tool>

Source

pub fn resolve(self) -> Option<Node<'collection, Tool>>

Examples found in repository?
examples/actor_lookup.rs (line 33)
6fn display_actor<'a>(actor: &Node<'a, IntrusionSet>) {
7    println!("{} ({})", actor.name(), actor.id());
8    println!("============");
9
10    if let Some(description) = actor.description() {
11        println!("{}\n", description);
12    }
13
14    let mut malwares = actor.uses_malware().peekable();
15    if malwares.peek().is_some() {
16        println!("Malware:");
17        for malware in malwares {
18            match malware.resolve() {
19                Some(malware) => {
20                    println!("- {} ({})", malware.name(), malware.id());
21                }
22                None => {
23                    println!("- Unknown Malware");
24                }
25            }
26        }
27    }
28
29    let mut tools = actor.uses_tools().peekable();
30    if tools.peek().is_some() {
31        println!("Tools:");
32        for tool in tools {
33            match tool.resolve() {
34                Some(tool) => {
35                    println!("- {} ({})", tool.name(), tool.id());
36                }
37                None => {
38                    println!("- Unknown Tool");
39                }
40            }
41        }
42    }
43}
Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Campaign>

Source

pub fn resolve(self) -> Option<Node<'collection, Campaign>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Identity>

Source

pub fn resolve(self) -> Option<Node<'collection, Identity>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, IntrusionSet>

Source

pub fn resolve(self) -> Option<Node<'collection, IntrusionSet>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Infrastructure>

Source

pub fn resolve(self) -> Option<Node<'collection, Infrastructure>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Location>

Source

pub fn resolve(self) -> Option<Node<'collection, Location>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, MarkingDefinition>

Source

pub fn resolve(self) -> Option<Node<'collection, MarkingDefinition>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Relationship>

Source

pub fn resolve(self) -> Option<Node<'collection, Relationship>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, ThreatActor>

Source

pub fn resolve(self) -> Option<Node<'collection, ThreatActor>>

Source§

impl<'id, 'collection: 'id> Ref<'id, 'collection, Vulnerability>

Source

pub fn resolve(self) -> Option<Node<'collection, Vulnerability>>

Trait Implementations§

Source§

impl<'id, 'collection: 'id, D> Clone for Ref<'id, 'collection, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<D> Display for Ref<'_, '_, D>

Source§

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

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

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, AttackPattern>

Source§

type Output = Node<'collection, AttackPattern>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Campaign>

Source§

type Output = Node<'collection, Campaign>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, CourseOfAction>

Source§

type Output = Node<'collection, CourseOfAction>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Identity>

Source§

type Output = Node<'collection, Identity>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Infrastructure>

Source§

type Output = Node<'collection, Infrastructure>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, IntrusionSet>

Source§

type Output = Node<'collection, IntrusionSet>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Location>

Source§

type Output = Node<'collection, Location>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Malware>

Source§

type Output = Node<'collection, Malware>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, MarkingDefinition>

Source§

type Output = Node<'collection, MarkingDefinition>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Matrix>

Source§

type Output = Node<'collection, Matrix>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Relationship>

Source§

type Output = Node<'collection, Relationship>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Tactic>

Source§

type Output = Node<'collection, Tactic>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, ThreatActor>

Source§

type Output = Node<'collection, ThreatActor>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Tool>

Source§

type Output = Node<'collection, Tool>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.
Source§

impl<'id, 'collection: 'id> Resolve for Ref<'id, 'collection, Vulnerability>

Source§

type Output = Node<'collection, Vulnerability>

The node type, containing a reference to the data and the backing collection.
Source§

fn resolve(self) -> Option<Self::Output>

Produce a collection-attached node for the object identified by the ID.

Auto Trait Implementations§

§

impl<'id, 'collection, D> Freeze for Ref<'id, 'collection, D>

§

impl<'id, 'collection, D> RefUnwindSafe for Ref<'id, 'collection, D>
where D: RefUnwindSafe,

§

impl<'id, 'collection, D> Send for Ref<'id, 'collection, D>
where D: Send,

§

impl<'id, 'collection, D> Sync for Ref<'id, 'collection, D>
where D: Sync,

§

impl<'id, 'collection, D> Unpin for Ref<'id, 'collection, D>
where D: Unpin,

§

impl<'id, 'collection, D> UnwindSafe for Ref<'id, 'collection, D>
where D: UnwindSafe,

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<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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.