Struct spdx::Licensee [−][src]
A convenience wrapper for a license and optional exception that can be checked against a license requirement to see if it satisfies the requirement placed by a license holder
let licensee = spdx::Licensee::parse("GPL-2.0").unwrap(); assert!(licensee.satisfies(&spdx::LicenseReq::from(spdx::license_id("GPL-2.0-only").unwrap())));
Implementations
impl Licensee
[src]
pub fn new(license: LicenseItem, exception: Option<ExceptionId>) -> Self
[src]
Creates a licensee from its component parts. Note that use of SPDX’s
or_later
is completely ignored for licensees as it only applies
to the license holder(s) not the licensee
pub fn parse(original: &str) -> Result<Self, ParseError<'_>>
[src]
Parses an simplified version of an SPDX license expression that can contain at most 1 valid SDPX license with an optional exception joined by a WITH.
use spdx::Licensee; // Normal single license Licensee::parse("MIT").unwrap(); // SPDX allows license identifiers outside of the official license list // via the LicenseRef- prefix Licensee::parse("LicenseRef-My-Super-Extra-Special-License").unwrap(); // License and exception Licensee::parse("Apache-2.0 WITH LLVM-exception").unwrap(); // `+` is only allowed to be used by license requirements from the license holder Licensee::parse("Apache-2.0+").unwrap_err(); Licensee::parse("GPL-2.0").unwrap(); // GNU suffix license (GPL, AGPL, LGPL, GFDL) must not contain the suffix Licensee::parse("GPL-3.0-or-later").unwrap_err();
pub fn satisfies(&self, req: &LicenseReq) -> bool
[src]
Determines whether the specified license requirement is satisfied by this license (+exception)
let licensee = spdx::Licensee::parse("Apache-2.0 WITH LLVM-exception").unwrap(); assert!(licensee.satisfies(&spdx::LicenseReq { license: spdx::LicenseItem::Spdx { id: spdx::license_id("Apache-2.0").unwrap(), // Means the license holder is fine with Apache-2.0 or higher or_later: true, }, exception: spdx::exception_id("LLVM-exception"), }));
Trait Implementations
impl Debug for Licensee
[src]
impl Display for Licensee
[src]
impl Eq for Licensee
[src]
impl Ord for Licensee
[src]
fn cmp(&self, other: &Licensee) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<LicenseReq> for Licensee
[src]
impl PartialEq<Licensee> for Licensee
[src]
impl PartialOrd<LicenseReq> for Licensee
[src]
fn partial_cmp(&self, o: &LicenseReq) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Licensee> for Licensee
[src]
fn partial_cmp(&self, other: &Licensee) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Licensee
[src]
impl StructuralPartialEq for Licensee
[src]
Auto Trait Implementations
impl RefUnwindSafe for Licensee
impl Send for Licensee
impl Sync for Licensee
impl Unpin for Licensee
impl UnwindSafe for Licensee
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,