Skip to main content

LoadedLicense

Struct LoadedLicense 

Source
pub struct LoadedLicense {
Show 29 fields pub key: String, pub short_name: Option<String>, pub name: String, pub language: Option<String>, pub spdx_license_key: Option<String>, pub other_spdx_license_keys: Vec<String>, pub category: Option<String>, pub owner: Option<String>, pub homepage_url: Option<String>, pub text: String, pub reference_urls: Vec<String>, pub osi_license_key: Option<String>, pub text_urls: Vec<String>, pub osi_url: Option<String>, pub faq_url: Option<String>, pub other_urls: Vec<String>, pub notes: Option<String>, pub is_deprecated: bool, pub is_exception: bool, pub is_unknown: bool, pub is_generic: bool, pub replaced_by: Vec<String>, pub minimum_coverage: Option<u8>, pub standard_notice: Option<String>, pub ignorable_copyrights: Option<Vec<String>>, pub ignorable_holders: Option<Vec<String>>, pub ignorable_authors: Option<Vec<String>>, pub ignorable_urls: Option<Vec<String>>, pub ignorable_emails: Option<Vec<String>>,
}
Expand description

Loader-stage representation of a license.

This struct contains parsed and normalized data from a .LICENSE file. It is serialized at build time and deserialized at runtime, then converted to a runtime License during the build stage.

Fields§

§key: String§short_name: Option<String>§name: String§language: Option<String>§spdx_license_key: Option<String>§other_spdx_license_keys: Vec<String>§category: Option<String>§owner: Option<String>§homepage_url: Option<String>§text: String§reference_urls: Vec<String>§osi_license_key: Option<String>§text_urls: Vec<String>§osi_url: Option<String>§faq_url: Option<String>§other_urls: Vec<String>§notes: Option<String>§is_deprecated: bool§is_exception: bool§is_unknown: bool§is_generic: bool§replaced_by: Vec<String>§minimum_coverage: Option<u8>§standard_notice: Option<String>§ignorable_copyrights: Option<Vec<String>>§ignorable_holders: Option<Vec<String>>§ignorable_authors: Option<Vec<String>>§ignorable_urls: Option<Vec<String>>§ignorable_emails: Option<Vec<String>>

Implementations§

Source§

impl LoadedLicense

Loader-stage normalization functions for license data.

Source

pub fn derive_key(path: &Path) -> Result<String, LicenseKeyError>

Derive key from filename.

Returns the file stem (filename without extension) as the key. This should match the key field in the frontmatter.

Source

pub fn validate_key_match( filename_key: &str, frontmatter_key: Option<&str>, ) -> Result<(), LicenseKeyError>

Validate that the frontmatter key matches the filename key.

Source

pub fn derive_name( name: Option<&str>, short_name: Option<&str>, key: &str, ) -> String

Derive name using the fallback chain.

Priority order:

  1. name field
  2. short_name field
  3. key as fallback
Source

pub fn merge_reference_urls( text_urls: Option<&[String]>, other_urls: Option<&[String]>, osi_url: Option<&str>, faq_url: Option<&str>, homepage_url: Option<&str>, ) -> Vec<String>

Merge reference URLs from multiple source fields.

Collects URLs in this order:

  1. text_urls
  2. other_urls
  3. osi_url
  4. faq_url
  5. homepage_url
Source

pub fn normalize_optional_string(s: Option<&str>) -> Option<String>

Normalize optional string field.

Returns None for empty strings, Some(trimmed) otherwise.

Source

pub fn normalize_optional_list(list: Option<&[String]>) -> Option<Vec<String>>

Normalize optional string list.

Returns None for empty lists, Some(list) with trimmed strings otherwise.

Source

pub fn validate_text_content( text: &str, is_deprecated: bool, is_unknown: bool, is_generic: bool, ) -> Result<(), LicenseTextError>

Validate that a non-deprecated, non-unknown, non-generic license has text content.

Trait Implementations§

Source§

impl Clone for LoadedLicense

Source§

fn clone(&self) -> LoadedLicense

Returns a duplicate 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 Debug for LoadedLicense

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LoadedLicense

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for LoadedLicense

Source§

fn eq(&self, other: &LoadedLicense) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for LoadedLicense

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for LoadedLicense

Source§

impl StructuralPartialEq for LoadedLicense

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,