adf
Lightweight Rust parsing and writing for Auto-lead Data Format (ADF) 1.0 XML leads.
This crate is aimed at low-overhead ADF processing:
- parses XML with
quick-xml - borrows input text where possible through
Cow<'a, str> - exposes a typed ADF model for common lead fields
- keeps unknown XML elements and attributes — on containers and compact elements alike — instead of discarding partner data
- preserves CDATA wrappers and unknown entity references through the typed writer
- can write the original document byte-for-byte when it has not been changed
- can rewrite only dirty prospect spans for localized edits
- keeps ADF-specific validation separate from XML parsing, with optional strict mode plus DTD enum and ISO format checks
Installation
[]
= "0.2"
Example
use parse;
use Cow;
Writing Modes
AdfDocument::to_original_preserving_string() preserves the original XML when the document is clean. If a single prospect is modified through prospect_mut, only that prospect's original byte span is rewritten and the surrounding XML is copied through unchanged.
AdfDocument::to_typed_string() writes normalized ADF XML from the typed model. This is useful when broad structural edits are made through adf_mut, or when normalized output is preferred over preserving original formatting.
Validation
Parsing only requires well-formed XML. ADF-specific checks are available through AdfDocument::validate():
The default validator reports DTD-required elements as warnings, checks DTD enumerated attribute values (prospect@status, vehicle@interest, price@type, etc.), and warns on malformed ISO 8601 dates, ISO 4217 currency codes, and ISO 3166 country codes.
AdfDocument::validate_strict() (or validate_with(adf, ValidationOptions { strict: true })) promotes the "missing required element" warnings to errors, suitable for gating on conformance.
License
Licensed under either of:
- Apache License, Version 2.0
- MIT license
at your option.
Development