Struct spdx_expression::SPDXExpression
source · [−]pub struct SPDXExpression { /* private fields */ }Expand description
Main struct for SPDX License Expressions.
Implementations
sourceimpl SPDXExpression
impl SPDXExpression
sourcepub fn parse(expression: &str) -> Result<Self, SpdxExpressionError>
pub fn parse(expression: &str) -> Result<Self, SpdxExpressionError>
Parse Self from a string. The input expression needs to be a syntactically valid SPDX
expression, NONE or NOASSERTION. The parser accepts license identifiers that are not
valid SPDX.
Examples
let expression = SPDXExpression::parse("MIT")?;License expressions need to be syntactically valid, but they can include license
identifiers not on the SPDX license list or not specified with LicenseRef.
let expression = SPDXExpression::parse("MIT OR InvalidLicenseId")?;Errors
Returns SpdxExpressionError if the license expression is not syntactically valid.
sourcepub fn licenses(&self) -> Vec<String>
pub fn licenses(&self) -> Vec<String>
Get all license and exception identifiers from the SPDXExpression. Returns the licenses
alphabetically sorted and deduped.
Examples
let expression = SPDXExpression::parse("MIT OR Apache-2.0")?;
let licenses = expression.licenses();
assert_eq!(licenses, vec!["Apache-2.0".to_string(), "MIT".to_string()]);Trait Implementations
sourceimpl Clone for SPDXExpression
impl Clone for SPDXExpression
sourcefn clone(&self) -> SPDXExpression
fn clone(&self) -> SPDXExpression
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for SPDXExpression
impl Debug for SPDXExpression
sourceimpl Display for SPDXExpression
impl Display for SPDXExpression
sourceimpl PartialEq<SPDXExpression> for SPDXExpression
impl PartialEq<SPDXExpression> for SPDXExpression
sourcefn eq(&self, other: &SPDXExpression) -> bool
fn eq(&self, other: &SPDXExpression) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &SPDXExpression) -> bool
fn ne(&self, other: &SPDXExpression) -> bool
This method tests for !=.
impl Eq for SPDXExpression
impl StructuralEq for SPDXExpression
impl StructuralPartialEq for SPDXExpression
Auto Trait Implementations
impl RefUnwindSafe for SPDXExpression
impl Send for SPDXExpression
impl Sync for SPDXExpression
impl Unpin for SPDXExpression
impl UnwindSafe for SPDXExpression
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more