Expand description
#CycloneDx-Rust
CycloneDx-Rust is a Crate library for encoding and decoding CycloneDx files in both XML and JSON format to the 1.2 spec
To encode the CycloneDx you cab=n either build up the structure using the provided
use cyclonedx_rust::CycloneDX;
CycloneDX::new(None, None, None, None);
can be built as follows:
use cyclonedx_rust::CycloneDXBuilder;
CycloneDXBuilder::default()
.metadata(None)
.components(None)
.services(None)
.dependencies(None)
.build();
§Encoding
An example of how to encode a CycloneDX BoM to a file:
use cyclonedx_rust::{CycloneDX, CycloneDXFormatType};
use std::io::BufWriter;
use std::fs::File;
let mut buffer = BufWriter::new(File::create("foo.txt").unwrap());
let cyclone_dx = CycloneDX::new(None, None, None, None);
CycloneDX::encode(&mut buffer, cyclone_dx, CycloneDXFormatType::XML);
§Decoding
An example of how to decode a CycloneDX BoM:
use cyclonedx_rust::{CycloneDX, CycloneDXFormatType};
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
let mut test_folder = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_folder.push("resources/test/bom-1.2.xml");
let file = File::open(test_folder);
let mut reader = BufReader::new(file.unwrap());
let result: CycloneDX = CycloneDX::decode(reader, CycloneDXFormatType::XML).unwrap();