Skip to content

CosmicHorrorDev/vdf-rs

Important

Moved to codeberg. Issues still open here for people who want to use them :)

https://codeberg.org/CosmicHarper/vdf-rs


vdf-rs

codecov build status

The vdf-rs project is focused on providing sane methods of dealing with Valve's Data Format v1 (VDF) also known as KeyValues.

Currently the project is composed of

Crates.io Documentation

A lower level parser/render for VDF text files

const LOGIN_USERS_VDF: &str = r#" "users" {  "12345678901234567"  {  "AccountName" "ACCOUNT_NAME"  "PersonaName" "PERSONA_NAME"  "RememberPassword" "1"  "MostRecent" "1"  "Timestamp" "1234567890"  } } "#; let vdf = keyvalues_parser::Vdf::parse(LOGIN_USERS_VDF)?; assert_eq!( "12345678901234567", vdf.value.unwrap_obj().keys().next().unwrap(), );

Crates.io Documentation

VDF text (De)serialization built on the serde framework

use serde::Deserialize; // Contents take from my ~/.data/Steam/steam/games/PlatformMenu.vdf const VDF_TEXT: &str = r##" // this file defines the contents of the platform menu "Platform" {  "Menu"  {  "Games"  {  "dll" "steamui"  "interface" "SteamUIGames001"  "MenuName" "#Steam_Games"  "SteamApp" "1"  }  "Friends"  {  "dll" "bin/friendsui"  "interface" "VGuiModuleTracker001"  "MenuName" "#App_Friends"  }  "Servers"  {  "dll" "bin/serverbrowser"  "interface" "VGuiModuleServerBrowser001"  "MenuName" "#App_Servers"  }  "Settings"  {  "dll" "steamui"  "interface" "VGuiModuleSettings001"  "MenuName" "#App_Settings"  "SteamApp" "1"  }  } } "##; #[derive(Deserialize, Debug)] struct Platform { #[serde(rename = "Menu")] menu: Menu, } #[derive(Deserialize, Debug)] #[serde(rename_all = "PascalCase")] struct Menu { games: MenuModule, friends: MenuModule, servers: MenuModule, settings: MenuModule, } #[derive(Deserialize, Debug)] struct MenuModule { dll: String, interface: String, #[serde(rename = "MenuName")] menu_name: String, #[serde(rename = "SteamApp")] steam_app: Option<bool>, } fn main() -> keyvalues_serde::Result<()> { let platform: Platform = keyvalues_serde::from_str(VDF_TEXT)?; println!("{:#?}", platform); Ok(()) }

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.

About

VDF parsing and (de)serialization for Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages