keyvalues-parser

keyvalues-parser uses pest to parse VDF text v1 and v2 files to an untyped Rust structure to ease manipulation and navigation. The parser provides an untyped Vdf representation as well as a linear TokenStream

The library is primarily used in conjunction with keyvalues-serde which provides a more ergonommic (yet more limiting) means of dealing with VDF text

Installation

Note: this requires at least Rust 1.42.0

Just add the library to your Cargo.toml

toml [dependencies] keyvalues-parser = "0.1.0"

Usage

There is documentation available here and there are examples available in the examples directory

Quickstart

loginusers.vdf

text "users" { "12345678901234567" { "AccountName" "ACCOUNT_NAME" "PersonaName" "PERSONA_NAME" "RememberPassword" "1" "MostRecent" "1" "Timestamp" "1234567890" } }

main.rs

```rust use keyvalues_parser::Vdf;

fn main() -> Result<(), Box> { let vdftext = std::fs::readtostring("loginusers.vdf")?; let vdf = Vdf::parse(&vdftext)?; assert_eq!(Some("12345678901234567"), vdf.value.keys().next());

Ok(())

} ```

Limitations

VDF text is drastically underspecified. This leads to the following liberties being taken

Benchmarks

A set of basic benchmarks can be found in the benches directory

These just test timing and throughput for both parsing and rendering of a fairly typical VDF file

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.