pub enum LicenseExpr {
Name(String),
WithException(String, String),
And(Vec<LicenseExpr>),
Or(Vec<LicenseExpr>),
}Expand description
A parsed license expression from a DEP-5 copyright file.
Variants§
Name(String)
A single license name, e.g. MIT.
WithException(String, String)
A license with an exception, e.g. GPL-2+ with OpenSSL-exception.
And(Vec<LicenseExpr>)
All of these licenses apply simultaneously.
Or(Vec<LicenseExpr>)
Any one of these licenses may be chosen.
Implementations§
Source§impl LicenseExpr
impl LicenseExpr
Sourcepub fn parse(input: &str) -> Self
pub fn parse(input: &str) -> Self
Parse a license expression string.
§Examples
use debian_copyright::LicenseExpr;
let expr = LicenseExpr::parse("GPL-2+ or MIT");
assert_eq!(expr, LicenseExpr::Or(vec![
LicenseExpr::Name("GPL-2+".to_string()),
LicenseExpr::Name("MIT".to_string()),
]));
let expr = LicenseExpr::parse("GPL-2+ with OpenSSL-exception");
assert_eq!(expr, LicenseExpr::WithException(
"GPL-2+".to_string(),
"OpenSSL-exception".to_string(),
));Sourcepub fn license_names(&self) -> Vec<&str>
pub fn license_names(&self) -> Vec<&str>
Returns the individual license names contained in this expression.
For WithException variants, only the license name is returned,
not the exception name.
Trait Implementations§
Source§impl Clone for LicenseExpr
impl Clone for LicenseExpr
Source§fn clone(&self) -> LicenseExpr
fn clone(&self) -> LicenseExpr
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LicenseExpr
impl Debug for LicenseExpr
Source§impl Display for LicenseExpr
impl Display for LicenseExpr
Source§impl PartialEq for LicenseExpr
impl PartialEq for LicenseExpr
impl Eq for LicenseExpr
impl StructuralPartialEq for LicenseExpr
Auto Trait Implementations§
impl Freeze for LicenseExpr
impl RefUnwindSafe for LicenseExpr
impl Send for LicenseExpr
impl Sync for LicenseExpr
impl Unpin for LicenseExpr
impl UnsafeUnpin for LicenseExpr
impl UnwindSafe for LicenseExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more