• Home
Name Date Size #Lines LOC

..--

src/04-Jul-2025-52,48335,603

.android-checksum.jsonD04-Jul-202575.7 KiB11

.cargo-checksum.jsonD04-Jul-202575.4 KiB11

Android.bpD04-Jul-2025859 3329

Cargo.tomlD04-Jul-20251.4 KiB6154

LICENSED04-Jul-202510.6 KiB202169

LICENSE-APACHED04-Jul-202510.6 KiB202169

METADATAD04-Jul-2025360 1817

MODULE_LICENSE_APACHE2D04-Jul-20250

README.mdD04-Jul-20253.1 KiB7952

cargo_embargo.jsonD04-Jul-202529 33

README.md

1<!-- markdownlint-disable no-inline-html first-line-heading -->
2
3<div align="center">
4
5# `�� spdx`
6
7**Helper crate for [SPDX](https://spdx.org/about) [license expressions](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60)**
8
9[![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev)
10[![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS)
11[![Crates.io](https://img.shields.io/crates/v/spdx.svg)](https://crates.io/crates/spdx)
12[![Docs](https://docs.rs/spdx/badge.svg)](https://docs.rs/spdx)
13[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust-1.65.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html)
14[![SPDX Version](https://img.shields.io/badge/SPDX%20Version-3.26.0-blue.svg)](https://spdx.org/licenses/)
15[![dependency status](https://deps.rs/repo/github/EmbarkStudios/spdx/status.svg)](https://deps.rs/repo/github/EmbarkStudios/spdx)
16[![Build Status](https://github.com/EmbarkStudios/spdx/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/spdx/actions?workflow=CI)
17
18</div>
19
20## Usage
21
22```rust
23use spdx::Expression;
24
25fn main() {
26    let this_is_fine = Expression::parse("MIT OR Apache-2.0").unwrap();
27
28    assert!(this_is_fine.evaluate(|req| {
29        if let spdx::LicenseItem::Spdx { id, .. } = req.license {
30            // Both MIT and Apache-2.0 are OSI approved, so this expression
31            // evaluates to true
32            return id.is_osi_approved();
33        }
34
35        false
36    }));
37
38    assert!(!this_is_fine.evaluate(|req| {
39        if let spdx::LicenseItem::Spdx { id, .. } = req.license {
40            // This is saying we don't accept any licenses that are OSI approved
41            // so the expression will evaluate to false as both sides of the OR
42            // are now rejected
43            return !id.is_osi_approved();
44        }
45
46        false
47    }));
48
49    // `NOPE` is not a valid SPDX license identifier, so this expression
50    // will fail to parse
51    let _this_is_not = Expression::parse("MIT OR NOPE").unwrap_err();
52}
53```
54
55## Updating SPDX list
56
57You can update the list of SPDX identifiers for licenses and exceptions by running the update program `cargo run --manifest-path=update/Cargo.toml -- v3.6` where `v3.6` is the tag in the [SPDX data repo](https://github.com/spdx/license-list-data).
58
59## Contributing
60
61[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](CODE_OF_CONDUCT.md)
62
63We welcome community contributions to this project.
64
65Please read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started.
66
67## License
68
69Licensed under either of
70
71* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
72* MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
73
74at your option.
75
76### Contribution
77
78Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
79