r-packages-parser
Lossless, failure-tolerant parsing, validation, building, and editing of R
repository PACKAGES indexes.
crates.io | API documentation | repository
The package name is r-packages-parser; the Rust library name is r_packages.
use Packages;
let packages = parse;
assert_eq!;
assert_eq!;
assert_eq!;
Every record remains accessible even when its DCF structure or typed fields are malformed. The API provides record-scoped immutable edits, canonical builders, typed field parsing, and index validation while preserving untouched source text exactly.
See the workspace overview for the lower-level syntax and semantic-value crates.
Converting individual records
Conversions with r_description::Description support both borrowed and owned
values:
use Description;
use ;
let packages = parse;
let record = packages.record.unwrap;
let description = from;
let round_trip = try_from.unwrap;
assert_eq!;
Add r-description-parser as a dependency to use Description directly.
Conversion preserves every field, including custom fields and duplicate
declarations, in source order. Lookups remain case-sensitive and use the last
declaration. Missing metadata is never filled in, and invalid semantic values or
malformed DCF lines are retained without panicking or requiring validation.
Record-local text is preserved exactly: spacing, continuation indentation, line endings, and final-newline presence. Surrounding blank lines and PACKAGES record separators belong to the document and are excluded. DESCRIPTION syntax diagnostics are recomputed relative to the standalone record.
PackageRecord::try_from requires exactly one DESCRIPTION record. Empty or
blank-only documents return RecordConversionError::NoRecords; multiple records
return RecordConversionError::MultipleRecords. A single malformed record is
accepted. These conversions do not generate a filtered repository index.
License
MIT