🛠️ This documentation is still under construction
Rust API
Version Source Verification

Version Source Verification (Rust)

ℹ️ See the global version source verification documentation for a full explanation of what is checked and why.

The AlphaDB Rust API provides the VersionSourceVerification struct to allow you to manually check a version source for errors before applying it.

Usage

To verify a version source, you first create a VersionSourceVerification instance from a version source string. Then, you call the verify method.

The verify method returns a Result<(), Vec<VerificationIssue>>:

  • Ok(()): The version source is valid with no issues.
  • Err(Vec<VerificationIssue>): The verifier found one or more issues.
use alphadb::version_source_verification::VersionSourceVerification;
use std::fs;
 
let version_source_str = fs::read_to_string("path/to/version_source.json")
    .expect("Failed to read version source file");
 
let mut verification = VersionSourceVerification::new(version_source_str)
    .expect("Failed to create verifier");
 
match verification.verify() {
    Ok(_) => {
        println!("Version source is valid!");
    }
    Err(issues) => {
        println!("Verification found issues:");
        for issue in issues {
            println!(
                "- [{:?}] {} (at: {})",
                issue.level,
                issue.message,
                issue.version_trace.join(" > ")
            );
        }
    }
}

This example reads a version source from a file, runs verification, and prints a success message or details for each issue found, including its priority level, message, and location within the version source.