pub struct SpdxMapping { /* private fields */ }Expand description
Mapping between ScanCode and SPDX license keys.
This structure enables conversion of license expressions from ScanCode-specific license keys (lowercase, e.g., “mit”, “gpl-2.0-plus”) to SPDX license identifiers (case-sensitive, e.g., “MIT”, “GPL-2.0-or-later”) and vice versa.
Implementations§
Source§impl SpdxMapping
impl SpdxMapping
Sourcepub fn build_from_licenses(licenses: &[License]) -> Self
pub fn build_from_licenses(licenses: &[License]) -> Self
Build an SPDX mapping from a slice of License objects.
This function extracts the spdx_license_key field from each License
and builds the two-way mapping. For licenses without an SPDX equivalent,
they are mapped to LicenseRef-scancode-<key> format.
§Arguments
licenses- Slice of License objects to build mapping from
§Returns
A SpdxMapping with populated mappings
Sourcepub fn scancode_to_spdx(&self, scancode_key: &str) -> Option<String>
pub fn scancode_to_spdx(&self, scancode_key: &str) -> Option<String>
Sourcepub fn expression_scancode_to_spdx(
&self,
scancode_expr: &str,
) -> Result<String, String>
pub fn expression_scancode_to_spdx( &self, scancode_expr: &str, ) -> Result<String, String>
Convert a license expression from ScanCode keys to SPDX keys.
This function parses the expression, replaces each license key with its SPDX equivalent, and serializes the result back to a string.
§Arguments
scancode_expr- License expression string with ScanCode keys
§Returns
String containing the expression with SPDX keys, or parse error
Example: if mit maps to SPDX MIT and gpl-2.0-plus has no SPDX key,
then mit OR gpl-2.0-plus becomes
LicenseRef-scancode-gpl-2.0-plus OR MIT.
Trait Implementations§
Source§impl Clone for SpdxMapping
impl Clone for SpdxMapping
Source§fn clone(&self) -> SpdxMapping
fn clone(&self) -> SpdxMapping
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpdxMapping
impl RefUnwindSafe for SpdxMapping
impl Send for SpdxMapping
impl Sync for SpdxMapping
impl Unpin for SpdxMapping
impl UnsafeUnpin for SpdxMapping
impl UnwindSafe for SpdxMapping
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.