pub struct SPDX {
pub document_creation_information: DocumentCreationInformation,
pub package_information: Vec<PackageInformation>,
pub other_licensing_information_detected: Vec<OtherLicensingInformationDetected>,
pub file_information: Vec<FileInformation>,
pub snippet_information: Vec<Snippet>,
pub relationships: Vec<Relationship>,
pub annotations: Vec<Annotation>,
pub spdx_ref_counter: i32,
}
Expand description
A representation of an SPDX Document
This is the main struct of this crate. The struct implements Serialize
and Deserialize
to allow it to be serialized into and deserialized from any data format supported by Serde.
SPDX specification version
The crate has been developed around SPDX version 2.2.1. Fields deprecated in 2.2.1, like review information are not supported. The plan is to support newer versions as they are released.
Data formats
The crate has been developed for usage with JSON SPDX documents. The naming of the fields should conform to the spec for at least JSON. Other formats, like YAML may work, but no guarantees are made.
The crate also allows for deserializing the struct from SPDX documents in tag-value format
with crate::parsers::spdx_from_tag_value
.
Fields
document_creation_information: DocumentCreationInformation
package_information: Vec<PackageInformation>
other_licensing_information_detected: Vec<OtherLicensingInformationDetected>
file_information: Vec<FileInformation>
snippet_information: Vec<Snippet>
relationships: Vec<Relationship>
annotations: Vec<Annotation>
spdx_ref_counter: i32
Counter for creating SPDXRefs. Is not part of the spec, so don’t serialize.
Implementations
sourceimpl SPDX
impl SPDX
sourcepub fn get_unique_hashes(&self, algorithm: Algorithm) -> HashSet<String>
pub fn get_unique_hashes(&self, algorithm: Algorithm) -> HashSet<String>
Get unique hashes for all files the SPDX.
sourcepub fn get_files_for_package(
&self,
package_spdx_id: &str
) -> Vec<(&FileInformation, &Relationship)>
pub fn get_files_for_package(
&self,
package_spdx_id: &str
) -> Vec<(&FileInformation, &Relationship)>
Find related files of the package with the provided id.
sourcepub fn get_license_ids(&self) -> HashSet<String>
pub fn get_license_ids(&self) -> HashSet<String>
Get all license identifiers from the SPDX.
Errors
Returns [SpdxError
] if parsing of the expressions fails.
sourcepub fn relationships_for_spdx_id(&self, spdx_id: &str) -> Vec<&Relationship>
pub fn relationships_for_spdx_id(&self, spdx_id: &str) -> Vec<&Relationship>
Get all relationships where the given SPDX ID is the SPDX element id.
Get all relationships where the given SPDX ID is the related SPDX element id.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for SPDX
impl<'de> Deserialize<'de> for SPDX
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for SPDX
Auto Trait Implementations
impl RefUnwindSafe for SPDX
impl Send for SPDX
impl Sync for SPDX
impl Unpin for SPDX
impl UnwindSafe for SPDX
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more