Struct spdx::Licensee[][src]

pub struct Licensee { /* fields omitted */ }
Expand description

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

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

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();

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

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.