Expand description
§vastlint-core
A zero-I/O VAST XML validation library. Takes a VAST XML
string and returns a structured ValidationResult listing every issue
found, the detected VAST version, and a summary of error/warning/info counts.
The entire public surface is two functions and a handful of types:
validate– validate with default settings (most callers want this)validate_with_context– validate with rule overrides or wrapper depthfix– fix deterministic issues and return repaired XMLfix_with_context– fix with rule overrides or wrapper depthall_rules– list the full 118-rule catalog
§Performance — allocator recommendation
vastlint-core builds an owned document tree on every call (one heap
allocation per XML element, attribute, and text node). Under concurrent
load the system allocator becomes a bottleneck because all threads compete
for a shared free-list lock.
Switching to mimalloc in your binary
crate eliminates this contention and gives dramatically better throughput
at high concurrency, especially for larger documents:
# Cargo.toml (your binary, not a library crate)
[dependencies]
mimalloc = { version = "0.1", default-features = false }// src/main.rs
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;Measured on Apple M4 (10 threads, production-realistic VAST tags):
| Allocator | 17 KB tag | 44 KB tag |
|---|---|---|
| system (default) | 1,847 tags/s · 541 µs | 328 tags/s · 3,048 µs |
| mimalloc | 15,760 tags/s · 63 µs | 2,635 tags/s · 380 µs |
mimalloc: ~8× throughput improvement on multi-threaded workloads.
⚠️ Do not set a global allocator in a library crate — it would override the allocator for any host process that links you (Go, Python, Ruby runtimes, etc.), which can cause heap corruption.
§Quick start
let xml = r#"<VAST version="2.0">
<Ad><InLine>
<AdSystem>Demo</AdSystem>
<AdTitle>Ad</AdTitle>
<Impression>https://t.example.com/imp</Impression>
<Creatives>
<Creative>
<Linear>
<Duration>00:00:15</Duration>
<MediaFiles>
<MediaFile delivery="progressive" type="video/mp4"
width="640" height="360">
https://cdn.example.com/ad.mp4
</MediaFile>
</MediaFiles>
</Linear>
</Creative>
</Creatives>
</InLine></Ad>
</VAST>"#;
let result = vastlint_core::validate(xml);
assert_eq!(result.summary.errors, 0);§Design constraints
The library has no I/O, no logging, no global state, and no async runtime. It can be embedded in a CLI, HTTP server, WASM module, or FFI binding without pulling in any platform-specific dependencies.
Three crate dependencies: quick-xml (XML parsing), url (RFC 3986),
and phf (compile-time hash maps).
Structs§
- Applied
Fix - A single fix that was successfully applied to the document.
- FixResult
- The result of a
fixorfix_with_contextcall. - Issue
- A single validation finding.
- Rule
Meta - Metadata about a single rule, as exposed by the public catalog.
- Summary
- Counts of issues by severity.
- Validation
Context - Context passed to validate_with_context. All fields have safe defaults.
- Validation
Result - The full result of validating a VAST document.
Enums§
- Detected
Version - How the version was determined.
- Rule
Level - Per-rule severity override. Mirrors Severity but adds Off.
- Rule
Source - The external standard or authority that a rule is derived from.
- Severity
- Issue severity, based strictly on spec language.
- Vast
Version - The VAST version as declared in the
versionattribute or inferred from document structure.
Functions§
- all_
rules - Returns the full catalog of known rules in definition order.
- fix
- Fix a VAST XML string using default settings.
- fix_
with_ context - Fix a VAST XML string with caller-supplied context.
- validate
- Validate a VAST XML string using default settings.
- validate_
with_ context - Validate a VAST XML string with caller-supplied context.