pub enum License {
Name(String),
Text(String),
Named(String, String),
}Expand description
A license, which can be just a name, a text or a named license.
Variants§
Name(String)
A license with just a name.
Text(String)
A license with just a text.
Named(String, String)
A license with a name and a text.
Implementations§
Source§impl License
impl License
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the name of the license, if any.
Note that this may be a license expression containing multiple licenses
combined with or, and, or with. Use License::expr to parse
the expression into a structured LicenseExpr.
Sourcepub fn expr(&self) -> Option<LicenseExpr>
pub fn expr(&self) -> Option<LicenseExpr>
Parse the license name as a structured expression.
Returns None if the license has no name (i.e. is a Text variant).
§Examples
use debian_copyright::{License, LicenseExpr};
let license = License::Name("GPL-2+ or MIT".to_string());
assert_eq!(
license.expr(),
Some(LicenseExpr::Or(vec![
LicenseExpr::Name("GPL-2+".to_string()),
LicenseExpr::Name("MIT".to_string()),
])),
);Trait Implementations§
Source§impl From<LicenseParagraph> for License
impl From<LicenseParagraph> for License
Source§fn from(p: LicenseParagraph) -> Self
fn from(p: LicenseParagraph) -> Self
Converts to this type from the input type.
impl Eq for License
impl StructuralPartialEq for License
Auto Trait Implementations§
impl Freeze for License
impl RefUnwindSafe for License
impl Send for License
impl Sync for License
impl Unpin for License
impl UnsafeUnpin for License
impl UnwindSafe for License
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