A parser for VDF
  • Rust 99.6%
  • Nix 0.4%
Find a file
2023-12-21 20:37:24 +01:00
.github/workflows ci 2023-12-15 18:32:20 +01:00
examples serde 2023-12-18 01:49:06 +01:00
src support tagged enums inside tables 2023-12-21 20:37:24 +01:00
tests support tagged enums inside tables 2023-12-21 20:37:24 +01:00
.envrc init 2023-12-15 15:51:53 +01:00
.gitignore statements 2023-12-15 16:26:16 +01:00
Cargo.lock serde for Entry/Table/Statement/Value 2023-12-18 22:49:16 +01:00
Cargo.toml serde for Entry/Table/Statement/Value 2023-12-18 22:49:16 +01:00
flake.lock init 2023-12-15 15:51:53 +01:00
flake.nix init 2023-12-15 15:51:53 +01:00
README.md readme 2023-12-18 18:14:54 +01:00

vdf-reader

A parser for Valve's Data Format v1 (VDF) also known as KeyValues.

The parser focuses on being able to deal with all the various weird forms vdf takes in the wild and providing access to the data stream instead of always requiring parsing the file in full.

Serde

This crate implements a deserializer for serde, but because VDF doesn't map that well only the serde data model not every type might deserialize properly.

Limitations

  • Because the boolean values 0 and 1 can't be distinguished from numbers, it is not possible to use booleans in untagged enums.

  • When deserializing arrays by settings the same key multiple times, the keys have to be consecutive.

    key: 1
    key: 2
    other: 3
    

    will work, but

    key: 1
    other: 3
    key: 2
    

    will not.

Tagged enum root

To help deserialize some common vdf formats, you can use a tagged enum as the root element instead of a struct.

"Variant1" {
    content 1
}

or

"Variant2" {
    other foo
}

can be deserialized into a

enum Data {
    Variant1 {
        content: bool,
    },
    Variant2 {
        other: String,
    }
}