Crate rstb[][src]

Expand description

A quick and easy library for manipulating the resource size table (RSTB) from The Legend of Zelda: Breath of the Wild in Rust. Can edit an RSTB directly or convert to and from a JSON representation.

Basic usage to manipulate an RSTB file:

use rstb::{ResourceSizeTable, Endian};
let buf: Vec<u8> = std::fs::read("test/ResourceSizeTable.product.rsizetable")?;
// Read RSTB from data, can automatically decompress if yaz0 compressed
// (requires `yaz0` feature)
let mut table: ResourceSizeTable = ResourceSizeTable::from_binary(buf)?;
// Set the size for a resource
table.set("Map/MainField/A-1/A-1_Dynamic.mubin", 777);
// Check the size
assert_eq!(
    table.get("Map/MainField/A-1/A-1_Dynamic.mubin").unwrap(),
    777
);
// Dump to JSON, if `json` feature enabled
#[cfg(feature = "json")]
{
    let json_table = table.to_text();
    // From JSON back to RSTB
    let new_table = ResourceSizeTable::from_text(&json_table)?;
}
// Write new binary copy, and we'll yaz0 compress it
#[cfg(feature = "yaz0")]
let out_buf: Vec<u8> = table.to_compressed_binary(Endian::Big);

Modules

This module handles calculating RSTB values. It can be used for exact calculations on many filetypes or estimations on certain others. The most important distinction is between the calc and estimate functions. The calc functions only attempt infallible calculations on types where this is supported, and otherwise always return None. By contrast, the estimate functions will perform an infallible calculation on supported types or attempt estimates on supported BFRES and AAMP files.

Structs

Represents a Breath of the Wild resource size table

Enums

An enum representing RSTB endianness. Note that it also serves as shorthand for Wii U (Big) or Switch (Little) more broadly. So if you are performing an RSTB value calculation or generating a stock RSTB, always use Endian::Big for Wii U and Endian::Little for Switch.

An enum representing the possible keys into an RSTB, whether as CRC hashes or resource names.

Represents an error when serializing or deserializing an RSTB

Type Definitions