Skip to main content

Module spdx

Module spdx 

Source
Expand description

SPDX license vocabulary lookup.

Ported from https://github.com/front-matter/commonmeta/blob/main/spdx/reader.go. search/from_url/from_id consume the bundled snapshot in src/vocabularies/licenses.json (see crate::vocabularies); fetch_all/refresh_bundled_vocabulary mirror the Go version’s ability to pull a fresh copy from the upstream SPDX license-list-data repo.

Structs§

License
A single SPDX license entry, as listed in the SPDX license-list-data licenses.json.

Constants§

SPDX_DOWNLOAD_URL
Upstream URL for the canonical SPDX license list, used by fetch_all.
SPDX_FILENAME
Filename the bundled vocabulary is stored under, both in src/vocabularies/ and as the default target of refresh_bundled_vocabulary.

Functions§

fetch_all
Downloads the latest SPDX license list from SPDX_DOWNLOAD_URL and parses it, without touching the bundled snapshot used by search. Mirrors Go’s spdx.FetchAll.
from_id
Builds a crate::data::License from an SPDX license id, filling in the canonical URL (first seeAlso entry) and title when recognized. Falls back to the given id verbatim when it isn’t found.
from_url
Builds a crate::data::License from a license URL, filling in the SPDX id and title (license name) when recognized. The url field is kept as given.
refresh_bundled_vocabulary
Downloads the latest SPDX license list and writes the raw JSON to path (e.g. src/vocabularies/licenses.json), for refreshing the bundled snapshot ahead of a release. Mirrors Go’s spdx.FetchAll, which downloads and writes the file as a side effect of fetching.
search
Searches the bundled SPDX metadata for a given SPDX license id or URL.