14 breaking releases

0.19.0 Jul 23, 2024
0.18.0 Feb 26, 2024
0.17.0 May 8, 2023
0.16.0 Mar 8, 2023
0.10.1 Jul 24, 2021

#51 in Games

Download history 2/week @ 2024-08-30 8/week @ 2024-09-13 3/week @ 2024-09-20 13/week @ 2024-09-27 3/week @ 2024-10-04 1/week @ 2024-10-11

796 downloads per month
Used in ssbh_data

MIT license

205KB
4K SLoC

ssbh_lib Latest Version docs.rs

ssbh_lib is a Rust library for reading and writing SSBH binary files. Each SSBH format has a major and minor version. All versions used by Smash Ultimate are supported.

Format Supported Versions (major.minor)
Hlpb (.nuhlpb) 1.1
Matl (.numatb) 1.5, 1.6
Modl (.numdlb,.nusrcmdlb) 1.7
Mesh (.numshb) 1.8, 1.9, 1.10
Skel (.nusktb) 1.0
Anim (.nuanmb) 1.2, 2.0, 2.1
Nlst (.nulstb) 1.0
Nrpd (.nurpdb) 1.6
Nufx (.nufxlb) 1.0, 1.1
Shdr (.nushdb) 1.2

Example

A traditional struct definition for SSBH data may look like the following.

struct FileData {
    name: u64,
    name_offset: u64,
    values_offset: u64,
    values_count: u64
}

The FileData struct has the correct size to represent the data on disk but has a number of issues. The values array doesn't capture the fact that SSBH arrays are strongly typed. It's not clear if the name_offset is an offset relative to the current position or some other buffer stored elsewhere in the file.

#[derive(BinRead, SsbhWrite)]
struct FileData {
    name: SsbhString,
    name_offset: RelPtr64<SsbhString>,
    values: SsbhArray<u32>    
}

Composing a combination of predefined SSBH types such as SsbhString with additional types implementing SsbhWrite and BinRead improves the amount of type information for the data and makes the usage of offsets less ambiguous. The code to read and write the data from the raw binary data is handled entirely by deriving BinRead and SsbhWrite.

Dependencies

~0.7–1.3MB
~26K SLoC