title: “Verify a Version Source (Rust)” description: “Check a version source for errors from Rust with AlphaDBVerification, and handle the returned verification issues and their priority levels.”
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, create an AlphaDBVerification instance from a version source string, then call the verify method. The engine rules (PostgreSQL or MySQL) are picked from the version source’s engine field, so make sure the matching crate feature (postgres or mysql) is enabled.
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;
let version_source_str = fs::read_to_string("path/to/version_source.json")
.expect("Failed to read version source file");
let mut verification = AlphaDBVerification::new(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.