pub fn run(config: Config) -> Result<(), Vex2PdfError>Expand description
Processes CycloneDX VEX documents according to the provided configuration.
This function serves as the main entry point for the library’s functionality. It finds and processes both JSON and XML files as specified in the configuration, converting them to PDF format with embedded fonts.
§Arguments
config- Configuration settings that control processing behavior
§Returns
Result<(), Vex2PdfError>- Success (Ok) if processing completes without errors, or an error (Err) if something goes wrong
§Behavior
The function performs these operations in sequence:
- Finds JSON and XML files according to the configuration
- Processes found files to generate PDFs
Processing Mode:
- With
concurrencyfeature (default): Files are processed concurrently using a threadpool. The number of concurrent jobs is controlled byConfig::max_jobs(defaults to system CPU count). - Without
concurrencyfeature: Files are processed sequentially in the main thread.
§Fonts
Liberation Sans fonts are embedded in the generated PDFs, eliminating the need for font installation on the system viewing the PDFs.
§Environment Variables
Various aspects of PDF generation can be controlled through environment variables:
VEX2PDF_NOVULNS_MSG: Controls whether to show a message when no vulnerabilities existVEX2PDF_REPORT_TITLE: Sets a custom title for the reportVEX2PDF_PDF_META_NAME: Sets the PDF metadata nameVEX2PDF_MAX_JOBS: Controls concurrent processing (requiresconcurrencyfeature)
For CLI usage, see Config::build_from_env_cli() which parses command-line arguments.
§Example
use vex2pdf::lib_utils::config::Config;
use vex2pdf::run;
use std::env;
// Create config using builder pattern
let config = Config::default()
.working_path(env::current_dir().unwrap())
.output_dir(env::current_dir().unwrap());
if let Err(e) = vex2pdf::run(config) {
eprintln!("Application error: {e}");
}