pub struct ScanStrategy<'a> { /* private fields */ }
Expand description

A ScanStrategy can be used as a high-level wrapped over a Store’s analysis logic.

A strategy configured here can be run repeatedly to scan a document for multiple licenses, or to automatically optimize to locate texts within a larger text.

Examples

use askalono::{ScanStrategy, Store};

let store = Store::new();
// [...]
let strategy = ScanStrategy::new(&store)
    .confidence_threshold(0.9)
    .optimize(true);
let results = strategy.scan(&"my text to scan".into())?;

Implementations

Construct a new scanning strategy tied to the given Store.

By default, the strategy has conservative defaults and won’t perform any deeper investigaton into the contents of files.

Set the scanning mode.

See ScanMode for a description of options. The default mode is Elimination, which is a fast, good general-purpose matcher.

Set the confidence threshold for this strategy.

The overall license match must meet this number in order to be reported. Additionally, if contained licenses are reported in the scan (when optimize is enabled), they’ll also need to meet this bar.

Set this to 1.0 for only exact matches, and 0.0 to report even the weakest match.

Set a fast-exit parameter that allows the strategy to skip the rest of a scan for strong matches.

This should be set higher than the confidence threshold; ideally close to 1.0. If the overall match score is above this limit, the scanner will return early and not bother performing deeper checks.

This is really only useful in conjunction with optimize. A value of 0.0 will fast-return on any match meeting the confidence threshold, while a value of 1.0 will only stop on a perfect match.

Indicate whether a deeper scan should be performed.

This is ignored if the shallow limit is met. It’s not enabled by default, however, so if you want deeper results you should set shallow_limit fairly high and enable this.

The maximum number of identifications to perform before exiting a scan of a single text.

This is largely to prevent misconfigurations and infinite loop scenarios, but if you have a document with a large number of licenses then you may want to tune this to a value above the number of licenses you expect to be identified.

Configure the scanning interval (in lines) for TopDown mode.

A smaller step size will be more accurate at a significant cost of speed.

Scan the given text content using this strategy’s configured preferences.

Returns a ScanResult containing all discovered information.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.