Skip to main content

ScanResult

Struct ScanResult 

Source
pub struct ScanResult<'a, T: ContentType, M: FindingMetadata = NoMetadata> { /* private fields */ }
Expand description

The outcome of a Scanner::scan call.

A ScanResult gives read-only access to:

The M type parameter is the FindingMetadata stored on each finding. It defaults to NoMetadata.

The result borrows immutably from the scanner. Copy anything you need to keep out of the result before starting another scan.

Implementations§

Source§

impl<'a, T: ContentType, M: FindingMetadata> ScanResult<'a, T, M>

Source

pub fn global(&self) -> &VarMap

Returns the VarMap populated by analyzers during the scan.

This is the read-only counterpart of Context::global.

Source

pub fn objects_scanned(&self) -> u32

Returns the total number of content objects visited by the scan (including the root).

Source

pub fn root(&self) -> Option<ScanContentHandle>

Returns a handle to the root content object.

Returns None if the scan visited no objects (for instance because the top-level content was rejected by the Filter).

Source

pub fn parent(&self, handle: ScanContentHandle) -> Option<ScanContentHandle>

Returns the parent of handle, if any.

Returns None for the root or for an invalid/detached handle.

Source

pub fn next_sibling( &self, handle: ScanContentHandle, ) -> Option<ScanContentHandle>

Returns the next sibling of handle (same parent, extracted after handle), if any.

Combined with child, this lets you walk all children of a given object:

ⓘ
let mut c = res.child(parent);
while let Some(h) = c {
    // ...visit h...
    c = res.next_sibling(h);
}
Source

pub fn child(&self, handle: ScanContentHandle) -> Option<ScanContentHandle>

Returns a handle to the first child of handle, if any.

Iterate the remaining children with next_sibling.

Source

pub fn local(&self, handle: ScanContentHandle) -> Option<&VarMap>

Returns the per-object VarMap populated by analyzers.

Returns None if the object never touched Context::local (its map was never allocated) or if the handle is invalid.

Source

pub fn path(&self, handle: ScanContentHandle) -> Option<&str>

Returns the path stored for the object referenced by handle.

This is the interned printable view of Content::path at the moment the object was scanned (see ContentPath::as_printable_string). For a live content object, prefer ContentPath::as_printable_string (display) or ContentPath::as_path (filesystem). Returns None for an invalid handle.

Source

pub fn content_type(&self, handle: ScanContentHandle) -> Option<T>

Returns the identified ContentType of handle, if any.

Returns None when the scanner was unable to identify the object’s type (no matching identifier or all identifiers rejected it), or for an invalid handle.

Source

pub fn findings(&self) -> FindigsIterator<'a, T, M> ⓘ

Iterates every Finding recorded during the scan, in emission order.

Analyzers add findings with Context::add_finding. Each finding is linked to the object that was current at the time, so Finding::path / Finding::content_type resolve against this result’s object tree.

ⓘ
for f in res.findings() {
    println!("{}  {}", f.finding(), f.path().unwrap_or("?"));
}

Auto Trait Implementations§

§

impl<'a, T, M = NoMetadata> !RefUnwindSafe for ScanResult<'a, T, M>

§

impl<'a, T, M = NoMetadata> !Send for ScanResult<'a, T, M>

§

impl<'a, T, M = NoMetadata> !Sync for ScanResult<'a, T, M>

§

impl<'a, T, M = NoMetadata> !UnwindSafe for ScanResult<'a, T, M>

§

impl<'a, T, M> Freeze for ScanResult<'a, T, M>
where &'a Context<T, M>: Freeze, PhantomData<(T, M)>: Freeze,

§

impl<'a, T, M> Unpin for ScanResult<'a, T, M>
where &'a Context<T, M>: Unpin, PhantomData<(T, M)>: Unpin,

§

impl<'a, T, M> UnsafeUnpin for ScanResult<'a, T, M>

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.