OCA SDK
Comprehensive SDK for OCA Bundle management and integration in Rust.
This crate helps you:
- parse OCAfiles,
- build and validate OCA bundles,
- validate captured data against bundles,
- load/serialize bundles and overlays.
Usage (library)
Add to your Cargo.toml:
oca-sdk-rs = "2.0.0-rc.5"
Creating a Bundle from OCAFile
use OverlayLocalRegistry;
use parse_from_string;
use from_ast;
let overlay_registry = from_dir?;
let ocafile_str = read_to_string?;
let oca_ast = parse_from_string?;
let oca_bundle = from_ast?.oca_bundle;
Validating Bundle Semantics
use ;
let status = validate_semantics?;
assert!;
Validating Captured Data
use validate_data;
let data = from_str?;
let validation_status = validate_data?;
Accessing Bundle Attributes
use ;
let info = oca_bundle.model.info;
for attr in info.attributes
Converting Bundle to JSON
use ;
let json = oca_bundle.model.get_json_bundle;
println!;
Tests
Integration tests must live directly under tests/ (for example tests/captured_data_validation.rs).
Files placed in subdirectories like tests/assets/ are treated as fixtures/modules and will not be
picked up by Cargo automatically.
Examples
Run any example with:
cargo run --example <name>
Available examples:
build_from_ocafile— parse an ocafile and build a bundlevalidate_semantics— validate semantics for a bundle JSONvalidate_data— validate captured JSON dataload_bundle_json— load an existing bundle JSONgenerate_ocafile— convert a bundle JSON back to ocafile
Notes:
- Examples use fixtures under
tests/assets/(paths are relative to the crate root). - If you run from a different working directory, use absolute paths or
cargo run --example <name> -- <args>.
See docs/quickstart.md for a step-by-step walkthrough with expected inputs/outputs.
License
EUPL 1.2
We have distilled the most crucial license specifics to make your adoption seamless: see here for details.