pub struct Licensing<'a> {
pub expression: Option<&'a str>,
pub ids: &'a BTreeSet<String>,
}Expand description
the licensing a component declares.
carries the SPDX expression when the source document had one, so AND/OR
and WITH survive; otherwise it falls back to the flattened identifier set,
which is read as a conjunction (every identifier applies).
Fields§
§expression: Option<&'a str>the declared SPDX expression, if any.
ids: &'a BTreeSet<String>the flattened license identifiers.
Implementations§
Source§impl<'a> Licensing<'a>
impl<'a> Licensing<'a>
Sourcepub fn from_ids(ids: &'a BTreeSet<String>) -> Self
pub fn from_ids(ids: &'a BTreeSet<String>) -> Self
builds a licensing view from a flat identifier set.
Sourcepub fn satisfiable<F>(&self, acceptable: F) -> bool
pub fn satisfiable<F>(&self, acceptable: F) -> bool
reports whether the licensing can be satisfied by taking on only
requirements acceptable approves of.
OR lets the consumer pick one side, AND demands both. an expression
that fails to parse, or an absent expression, falls back to requiring
every identifier in the flat set.
§Example
use sbom_model::Licensing;
use std::collections::BTreeSet;
let ids: BTreeSet<String> = ["Apache-2.0".into(), "MIT".into()].into();
let choice = Licensing { expression: Some("MIT OR Apache-2.0"), ids: &ids };
assert!(choice.satisfiable(|r| r.license == "MIT"));
let both = Licensing { expression: Some("MIT AND Apache-2.0"), ids: &ids };
assert!(!both.satisfiable(|r| r.license == "MIT"));Sourcepub fn requirements(&self) -> BTreeSet<LicenseRequirement>
pub fn requirements(&self) -> BTreeSet<LicenseRequirement>
returns every requirement the licensing mentions, whether or not a consumer must accept it.
Trait Implementations§
impl<'a> Copy for Licensing<'a>
impl<'a> Eq for Licensing<'a>
impl<'a> StructuralPartialEq for Licensing<'a>
Auto Trait Implementations§
impl<'a> Freeze for Licensing<'a>
impl<'a> RefUnwindSafe for Licensing<'a>
impl<'a> Send for Licensing<'a>
impl<'a> Sync for Licensing<'a>
impl<'a> Unpin for Licensing<'a>
impl<'a> UnsafeUnpin for Licensing<'a>
impl<'a> UnwindSafe for Licensing<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.