Struct LicensedComponent

Source
pub struct LicensedComponent { /* private fields */ }
Expand description

Represents a software component with licensing information.

Implementations§

Source§

impl LicensedComponent

Source

pub fn new(flavor: ComponentFlavor, license: LicenseFlavor) -> Self

Construct a new instance from parameters.

Source

pub fn new_spdx(flavor: ComponentFlavor, spdx_expression: &str) -> Result<Self>

Construct a new instance from an SPDX expression.

Source

pub fn flavor(&self) -> &ComponentFlavor

The type of this component.

Source

pub fn license(&self) -> &LicenseFlavor

Obtain the flavor of license for this component.

Source

pub fn spdx_expression(&self) -> Option<&Expression>

Obtain the SPDX expression for this component’s license.

Source

pub fn is_simple_spdx_expression(&self) -> bool

Whether the SPDX expression is simple.

Simple is defined as having at most a single license.

Source

pub fn source_location(&self) -> &SourceLocation

Obtain the location where the source of this component can be obtained.

Source

pub fn set_source_location(&mut self, location: SourceLocation)

Define where source code for this component can be obtained from.

Source

pub fn homepage(&self) -> Option<&str>

Obtain the homepage / URL of this component.

Source

pub fn set_homepage(&mut self, value: impl ToString)

Set the homepage of this component.

Source

pub fn authors(&self) -> &[String]

Obtain the annotated authors of this component.

Source

pub fn add_author(&mut self, value: impl ToString)

Define an author of this component.

Source

pub fn license_texts(&self) -> &Vec<String>

Obtain the explicitly set license texts for this component.

Source

pub fn add_license_text(&mut self, text: impl ToString)

Define the license text for this component.

Source

pub fn is_spdx(&self) -> bool

Returns whether all license identifiers are SPDX.

Source

pub fn all_spdx_licenses(&self) -> BTreeSet<(LicenseId, Option<ExceptionId>)>

Obtain all SPDX licenses referenced by this component.

The first element of the returned tuple is the license identifier. The 2nd is an optional exclusion identifier.

Source

pub fn all_spdx_license_names(&self, full: bool) -> Vec<String>

Obtain all SPDX license names.

Source

pub fn all_spdx_license_ids(&self) -> BTreeSet<LicenseId>

Obtain all the distinct LicenseId in this component.

Unlike Self::all_spdx_licenses(), this returns just the license IDs without exceptions.

Source

pub fn all_spdx_exception_ids(&self) -> BTreeSet<ExceptionId>

Obtain all the ExceptionId present in this component.

Source

pub fn has_copyleft(&self) -> bool

Whether the component has any copyleft licenses.

Source

pub fn is_always_copyleft(&self) -> bool

Whether all licenses are copyleft.

Source

pub fn licensing_summary(&self) -> String

Obtain a textual licensing summary of this component.

Trait Implementations§

Source§

impl Clone for LicensedComponent

Source§

fn clone(&self) -> LicensedComponent

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LicensedComponent

Source§

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

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

impl Ord for LicensedComponent

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for LicensedComponent

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for LicensedComponent

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryInto<LicensedComponent> for PackageLicenseInfo

Source§

type Error = Error

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

fn try_into(self) -> Result<LicensedComponent, Self::Error>

Performs the conversion.
Source§

impl Eq for LicensedComponent

Auto Trait Implementations§

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.