pub struct License {
pub extensions: Extensions,
/* private fields */
}Expand description
License information for the exposed API.
Every version of the specification makes identifier and url mutually
exclusive, and makes both optional beside a required name. This type holds
at most one of the two, so the three states the specification allows are the
three a program can build — and a document setting both cannot be
constructed, nor parsed, nor emitted.
Reach for spdx in preference to
with_url: an SPDX expression is machine-readable and a
URL is not. Both are permitted, which is why both are here.
Fields§
§extensions: ExtensionsSpecification extensions.
Implementations§
Source§impl License
impl License
Sourcepub fn named(name: impl Into<String>) -> Self
pub fn named(name: impl Into<String>) -> Self
Creates a license identified by name alone.
Valid, and the weakest of the three: a consumer gets something to show a human and nothing to resolve.
Sourcepub fn spdx(name: impl Into<String>, identifier: impl Into<String>) -> Self
pub fn spdx(name: impl Into<String>, identifier: impl Into<String>) -> Self
Creates a license identified by an SPDX expression.
This is preferred over License::with_url: an SPDX identifier is
machine-readable, a URL is not.
Sourcepub fn with_url(name: impl Into<String>, url: impl Into<String>) -> Self
pub fn with_url(name: impl Into<String>, url: impl Into<String>) -> Self
Creates a license identified by a URL.
Sourcepub fn identifier(&self) -> Option<&str>
pub fn identifier(&self) -> Option<&str>
The SPDX license expression, when this license carries one.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for License
impl<'de> Deserialize<'de> for License
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.