Struct askalono::Store [] [src]

pub struct Store { /* fields omitted */ }

A representation of a collection of known licenses.

This struct is generally what you want to start with if you're looking to match text against a database of licenses. Load a cache from disk using from_cache, then use the analyze function to determine what a text most closely matches.

Examples

use askalono::{Store, TextData};

let store = Store::from_cache(File::open("askalono-cache.bin.gz")?)?;
let result = store.analyze(&TextData::from("what's this"))?;

Methods

impl Store
[src]

[src]

Compare the given TextData against all licenses in the Store.

This parallelizes the search as much as it can to find the best match. Once a match is obtained, it can be optimized further; see methods on TextData for more information.

impl Store
[src]

[src]

Create a new Store.

More often, you probably want to use from_cache instead of creating an empty store.

[src]

Get the number of licenses in the store.

This only counts licenses by name -- headers, aliases, and alternates aren't included in the count.

impl Store
[src]

[src]

Create a store from a cache file.

This method is highly useful for quickly loading a cache, as creating one from text data is rather slow. This method can typically load the full SPDX set from disk in 200-300 ms. The cache will be sanity-checked to ensure it was generated with a similar version of askalono.

[src]

Serialize the current store.

The output will be a MessagePack'd gzip'd binary stream that should be written to disk.

impl Store
[src]

[src]

Fill the store with SPDX JSON data.

This function is very specific to the format of SPDX's license-list-data repository. It reads all JSON files in the json/details directory and creates entries inside the store for matching.

This is intended to be used during build of askalono, so it's not available unless the spdx feature is enabled.

include_texts, if true, will keep normalized license text data inside the store. This yields a larger store when serialized, but has the benefit of allowing you to diff your result against what askalono has stored.

Trait Implementations

impl Default for Store
[src]

[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations

impl Send for Store

impl Sync for Store