7 stable releases

2.1.0 Oct 28, 2024
2.0.0 Oct 28, 2024
1.1.3 Oct 27, 2024
1.1.0 Oct 26, 2024
1.0.0 Oct 26, 2024

#2294 in Encoding

Download history 149/week @ 2025-12-24 51/week @ 2025-12-31 128/week @ 2026-01-07 169/week @ 2026-01-14 186/week @ 2026-01-21 163/week @ 2026-01-28 266/week @ 2026-02-04 241/week @ 2026-02-11 15/week @ 2026-02-18 32/week @ 2026-02-25 240/week @ 2026-03-04 68/week @ 2026-03-11 186/week @ 2026-03-18 152/week @ 2026-03-25 59/week @ 2026-04-01 84/week @ 2026-04-08

484 downloads per month

MPL-2.0 license

85KB
3K SLoC

CraftFlow-NBT

docs.rs Crates.io Version

A serde-based implementation of the Minecraft NBT binary format.

Serde deriving

  • Tagged enums not supported
  • Untagged enums: the default implementation of Deserialize derived by serde macros does some crazy stuff with types, so if you have multiple variants with differrent "flavors" of the same base type (integers: byte, short, int, long, or lists: list, byte array, int array, long array) serde will automatically convert it the value that is first defined in the enum. For example:
    #[derive(serde::Deserialize)]
    #[serde(untagged)]
    enum Example {
      First(u32),
      Second(u64),
    }
    
    Using the code above, even if you encounter a value that is encoded as a Long in NBT, serde will still always give you Example::First, except for when the number is big enough that it can't fit in a u32. This is very inconsistent and therefore if you need this functionality, consider implementing Deserialize manually. See the implementation of DynNBT for an example.
  • Option: if serialized/deserialized standalone, will write/read a Tag::End byte. However, if inside a compound, will be skipped altogether.

Dependencies

~0.3–0.9MB
~19K SLoC