Expand description
§HOI4 Save
HOI4 Save is a library to ergonomically work with Hearts of Iron IV saves (plaintext + binary).
ⓘ
use std::collections::HashMap;
use hoi4save::{Hoi4File, Encoding, models::Hoi4Save};
let data = std::fs::read("assets/saves/1.10-normal-text.hoi4")?;
let file = Hoi4File::from_slice(&data)?;
let parsed_file = file.parse()?;
let resolver = HashMap::<u16, &str>::new();
let save: Hoi4Save = parsed_file.deserializer().build(&resolver)?;
assert_eq!(file.encoding(), Encoding::Plaintext);
assert_eq!(save.player, String::from("FRA"));
The HOI4 binary format can be converted to plaintext
ⓘ
use std::collections::HashMap;
use hoi4save::{Hoi4File, EnvTokens};
let data = std::fs::read("assets/saves/1.10-ironman.hoi4")?;
let file = Hoi4File::from_slice(&data)?;
let parsed_file = file.parse()?;
let binary = parsed_file.as_binary().unwrap();
let out = binary
.melter()
.on_failed_resolve(hoi4save::FailedResolveStrategy::Stringify)
.melt(&EnvTokens)?;
§Binary Saves
Binary saves are supported, but not by default, as the token resolver can’t be distributed, per PDS counsel.
Modules§
Structs§
- Basic
Token Resolver - A basic token resolver that facilitates loading tokens from an external source.
- Country
Tag - Wrapper around a Country’s unique three byte tag
- Hoi4
Date - A date with an hour component
- Hoi4
Error - A Hoi4 Error
- Hoi4
File - Entrypoint for parsing HOI4 saves
- Melt
Options - Melted
Document - Output from melting a binary save to plaintext
Enums§
- Encoding
- Describes the format of the save before decoding
- Failed
Resolve Strategy - Customize how the deserializer reacts when a token can’t be resolved
- Hoi4
Error Kind - Specific type of error
Traits§
- PdsDate
- Common set of methods between all the date components