pub struct Store { /* private fields */ }
Expand description

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.zstd")?)?;
let result = store.analyze(&TextData::from("what's this"));

Implementations

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.

Create a new Store.

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

Get the number of licenses in the store.

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

Check if the store is empty.

Get all licenses by name via iterator.

Get a license’s standard TextData by name.

Add a single license to the store.

If the license with the given name already existed, it and all of its variants will be replaced.

Add a variant (a header or alternate formatting) of a given license to the store.

The license must already exist. This function cannot be used to replace the original/canonical text of the license.

Get the list of aliases for a given license.

Set the list of aliases for a given license.

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.

Serialize the current store.

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

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

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

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

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.