Skip to main content

Licensing

Struct Licensing 

Source
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>

Source

pub fn from_ids(ids: &'a BTreeSet<String>) -> Self

builds a licensing view from a flat identifier set.

Source

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"));
Source

pub fn requirements(&self) -> BTreeSet<LicenseRequirement>

returns every requirement the licensing mentions, whether or not a consumer must accept it.

Trait Implementations§

Source§

impl<'a> Clone for Licensing<'a>

Source§

fn clone(&self) -> Licensing<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Licensing<'a>

Source§

impl<'a> Debug for Licensing<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Licensing<'a>

Source§

impl<'a> PartialEq for Licensing<'a>

Source§

fn eq(&self, other: &Licensing<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.