Struct spdx::lexer::ParseMode

source ·
pub struct ParseMode {
    pub allow_lower_case_operators: bool,
    pub allow_slash_as_or_operator: bool,
    pub allow_imprecise_license_names: bool,
    pub allow_postfix_plus_on_gpl: bool,
}
Expand description

Parsing configuration for SPDX expression

Fields§

§allow_lower_case_operators: bool

The AND, OR, and WITH operators are required to be uppercase in the SPDX spec, but enabling this option allows them to be lowercased

§allow_slash_as_or_operator: bool

Allows the use of / as a synonym for the OR operator.

This also allows for not having whitespace between the / and the terms on either side

§allow_imprecise_license_names: bool

Allows some invalid/imprecise identifiers as synonyms for an actual license identifier.

See IMPRECISE_NAMES for a list of the current synonyms. Note that this list is not comprehensive but can be expanded upon when invalid identifiers are found in the wild.

§allow_postfix_plus_on_gpl: bool

The various GPL licenses diverge from every other license in the SPDX license list by having an -or-later variant that is used as a suffix on a base license (eg. GPL-3.0-or-later) rather than the canonical GPL-3.0+.

This option just allows GPL licenses to be treated similarly to all of the other SPDX licenses.

Implementations§

source§

impl ParseMode

source

pub const STRICT: Self = _

Strict, specification compliant SPDX parsing.

  1. Only license identifiers in the SPDX license list, or Document/LicenseRef, are allowed. The license identifiers are also case-sensitive.
  2. WITH, AND, and OR are the only valid operators
source

pub const LAX: Self = _

Allow non-conforming syntax for crates-io compatibility

  1. Additional, invalid, identifiers are accepted and mapped to a correct SPDX license identifier. See IMPRECISE_NAMES for the list of additionally accepted identifiers and the license they correspond to.
  2. / can by used as a synonym for OR, and doesn’t need to be separated by whitespace from the terms it combines

Trait Implementations§

source§

impl Clone for ParseMode

source§

fn clone(&self) -> ParseMode

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 Default for ParseMode

source§

fn default() -> ParseMode

Returns the “default value” for a type. Read more
source§

impl Copy for ParseMode

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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.