run

Function run 

Source
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:

  1. Finds JSON and XML files according to the configuration
  2. Processes found files to generate PDFs

Processing Mode:

  • With concurrency feature (default): Files are processed concurrently using a threadpool. The number of concurrent jobs is controlled by Config::max_jobs (defaults to system CPU count).
  • Without concurrency feature: 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 exist
  • VEX2PDF_REPORT_TITLE: Sets a custom title for the report
  • VEX2PDF_PDF_META_NAME: Sets the PDF metadata name
  • VEX2PDF_MAX_JOBS: Controls concurrent processing (requires concurrency feature)

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}");
}