Crate fastsnbt

source ·
Expand description

fastsnbt aims for fast deserializing and serializing of sNBT data from Minecraft: Java Edition. This is the human-readable equivalent of NBT data. (see fastnbt).

  • For documentation of serde (de)serialization, see ser and de.
  • See fastnbt for most NBT related things.

Example

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct SimpleStruct {
    num: i64,
    s: String,
}

let data = SimpleStruct {
    num: 31300,
    s: "Hello world!".into(),
};
let ser = fastsnbt::to_string(&data).unwrap();
assert_eq!("{\"num\":31300l,\"s\":\"Hello world!\"}", ser);

let input = "{num:31300L,s:\"Hello world!\"}";
let de: SimpleStruct = fastsnbt::from_str(input).unwrap();
assert_eq!(data, de);

Modules

  • This module contains a serde deserializer. It can do most of the things you would expect of a typical serde deserializer, such as deserializing into:
  • Contains the Error and Result type used by the deserializer.
  • This module contains a serde serializer for sNBT data. This should be able to serialize most structures to sNBT. Use to_vec or to_string.

Functions

  • Deserialize into a T from some sNBT data. See the de module for more information.
  • Serialize some T into a sNBT string. See the ser module for more information.
  • Serialize some T into some sNBT string. This produces valid utf-8. See the ser module for more information.