ddsavelib

Crates.ioddsavelib
lib.rsddsavelib
version0.1.1
sourcesrc
created_at2020-07-20 19:55:16.947698
updated_at2020-07-20 20:11:08.513837
descriptionLibrary for reading/writing Darkest Dungeon save files.
homepagehttps://github.com/robojumper/DarkestDungeonSaveEditor
repositoryhttps://github.com/robojumper/DarkestDungeonSaveEditor
max_upload_size
id267364
size86,537
(robojumper)

documentation

https://docs.rs/ddsavelib

README

ddsavelib

crates_io_badge docs_rs_badge

A nightly-rust library to decode and encode the binary Darkest Dungeon save file format.

Documentation

docs.rs/ddsavelib

Usage

Cargo.toml

[dependencies]
ddsavelib = "0.1"

Example:

use ddsavelib::{File, Unhasher};

let json = r#"{ "__revision_dont_touch": 12345,
                "base_root": { "soldier_class": -2101527251 }
           }"#;

// Read the JSON file
let file1 = File::try_from_json(&mut json.as_bytes()).unwrap();

// Convert to binary
let mut bin_data = Vec::new();
file1.write_to_bin(&mut bin_data).unwrap();

// Realize we know Jester is a class
let mut unhash = Unhasher::empty();
unhash.offer_name("jester");

// Convert to JSON
let mut json_data = Vec::new();
let file2 = File::try_from_bin(&mut &*bin_data).unwrap();
file2.write_to_json(&mut json_data, true, &unhash).unwrap();
let output_str = std::str::from_utf8(&json_data).unwrap().replace(" ", "").replace("\n", "");

// We even managed to unhash Jester!
assert_eq!(&*output_str,
  r####"{"__revision_dont_touch":12345,"base_root":{"soldier_class":"###jester"}}"####);

// The library performs verification of the input and doesn't panic.
let mut garbage_data: &[u8] = &[0u8, 50u8, 145u8, 2u8];
assert!(File::try_from_bin(&mut garbage_data).is_err());
Commit count: 155

cargo fmt