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 std::fs;
use alphadb::verification::AlphaDBVerification;
use alphadb::engine::verification::MySQLVerificationEngine;
let version_source_str = fs::read_to_string("path/to/version_source.json")
.expect("Failed to read version source file");
let mut engine = MySQLVerificationEngine::new();
let mut verification = AlphaDBVerification::with_engine(engine, version_source_str)
.expect("Failed to create verification instance");
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.to_vec().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.