Module nbt_lib::de

source ·
Expand description

This is a Module for deserializing NbtValue’s

The following code is copied and modified from fastnbt: https://github.com/owengage/fastnbt/blob/da6d919ac3916d2a951ee79451497f4981802ca9/fastnbt/src/ser/serializer.rs

for which the license is MIT

§Example

use serde::{Deserialize, Serialize};
use nbt_lib::de::from_bytes;
#[derive(Debug, Deserialize, PartialEq, Eq)]
struct Test {
    name: String
}
let data = include_bytes!("../../test_data/hello_world.nbt");
let test_struct = Test { name: "Bananrama".to_string() };
let test_data: Test = from_bytes(data).expect("This should not fail");
assert_eq!(test_data, test_struct);

Structs§

  • A struct for the desierialization options
  • A struct for deserializing raw NBT data into other datastructs

Functions§

  • Converts raw nbt bytes directly into an struct