Crate ssbh_data

source ·
Expand description

§ssbh_data

ssbh_data provides a more intuitive and minimal API built on ssbh_lib.

§Features

The high level nature of ssbh_data makes it easier to integrate with application code than ssbh_lib. Python bindings are also available with ssbh_data_py.

  • Automatic decoding and encoding of buffers and compressed data
  • Usage of standard Rust types like Vec and String
  • Support for converting files to and from supported versions
  • Simpler output when serializing and deserializing
  • Errors for invalid data such as out of bounds vertex indices
  • Modifications are less likely to produce an invalid file due to reduced dependencies between fields

§Getting Started

The easiest way to access important items like MeshData is to import the prelude. For additional reading and writing options, see the SsbhData trait.

use ssbh_data::prelude::*;

// Read the file from disk.
let mut data = MeshData::from_file("model.numshb")?;

// Make some edits.
data.objects[0].name = "firstMesh".to_string();

// Save the changes.
data.write_to_file("model_new.numshb")?;

§File Differences

The reduction in dependencies between fields and decoding and encoding of buffer data means that ssbh_data does not guarantee an unmodified file to be binary identical after saving. Examples include floating point rounding errors, larger file sizes due to different compression settings, or default values used for unresearched flag values. See the module level documentation for each format for details.

These differences are minor in practice but may cause issues for some applications. Applications needing a stronger guarantee that all data will be preserved should use ssbh_lib.

Modules§

Structs§

  • A null terminated string with a specified alignment. The empty string is represented as N null bytes.
  • 4 contiguous floats for encoding RGBA data.
  • 3 contiguous floats for encoding XYZ or RGB data.
  • 4 contiguous floats for encoding XYZW or RGBA data.

Traits§

  • Functions for reading and writing supported formats.