Struct spdx_rs::models::SPDX

source ·
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§

source§

impl SPDX

source

pub fn new(name: &str) -> Self

Create new SPDX struct.

source

pub fn get_unique_hashes(&self, algorithm: Algorithm) -> HashSet<String>

Get unique hashes for all files the SPDX.

source

pub fn get_files_for_package( &self, package_spdx_id: &str ) -> Vec<(&FileInformation, &Relationship)>

Find related files of the package with the provided id.

source

pub fn get_license_ids(&self) -> HashSet<String>

Get all license identifiers from the SPDX.

Errors

Returns [SpdxError] if parsing of the expressions fails.

source

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§

source§

impl Clone for SPDX

source§

fn clone(&self) -> SPDX

Returns a copy 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 SPDX

source§

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

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

impl<'de> Deserialize<'de> for SPDX

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<SPDX> for SPDX

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for SPDX

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 SPDX

source§

impl StructuralEq for SPDX

source§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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 Twhere T: for<'de> Deserialize<'de>,