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 ofrefresh_bundled_vocabulary.
Functions§
- fetch_
all - Downloads the latest SPDX license list from
SPDX_DOWNLOAD_URLand parses it, without touching the bundled snapshot used bysearch. Mirrors Go’sspdx.FetchAll. - from_id
- Builds a
crate::data::Licensefrom an SPDX license id, filling in the canonical URL (firstseeAlsoentry) and title when recognized. Falls back to the given id verbatim when it isn’t found. - from_
url - Builds a
crate::data::Licensefrom a license URL, filling in the SPDXidandtitle(license name) when recognized. Theurlfield 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’sspdx.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.