[−][src]Module nobility::bin_decode
Contains the implementation of the binary format decoder. Decoder for the NBT binary format. This module is based around the idea that you won't store the objects, instead they will be walked through to build up some other data structure.
As a result, almost all of the types here use borrows into the original data buffer, rather than copying into a Vec. The main exception is bookkeeping where necessary, such as when parsing Compound tags.
Example
use nobility::bin_decode::Document; use std::fs::File; use std::io::Read; let mut file = File::open("files/hello_world.nbt")?; let mut data = vec![]; file.read_to_end(&mut data)?; let cursor = std::io::Cursor::new(data); // Either copies the data (plaintext) or decompresses it (gzip). let doc = Document::load(cursor)?; // Returns the root tag's name, and the root tag (always a Compound tag). // Both of these are borrowing the data inside the Document. let (name, root) = doc.parse()?; println!("name: {}", name.decode()?); println!("{:#?}", root);
Structs
Compound | Represents TAG_Compound, a list of key/value pairs. The order of the entries is the same that they appear in the file, although this usually is not significant. |
Document | Represents an NBT document and is the owner of the data contained in it. All other decoder types are borrows of the data stored in this. |
Entry | Represents an entry into a Compound, with a name and a value. |
ListIter | |
NbtArray | Common representation for TAG_Int_Array, TAG_Long_Array, and TAG_List with elements of fixed size (Byte, Short, Int, Long, Float, Double). |
NbtArrayIter | Iterator over the contents of NbtArray, yielding the element type. |
NbtList | Implementation for lists whose elements do not have a fixed size. |
NbtString | NBT stores strings in Java's modified version of CESU-8 called "Modified UTF-8". This type stores a reference to the raw data in the file, and NbtString::decode can be used to convert it to a string. |
Enums
List | An enum that represents all possible list types. |
ParseError | Failures which can occur while parsing an NBT document. |
Tag | Representation for all values that a tag can be. |
Type Definitions
ByteArrayList | A TAG_List of TAG_Byte_Array. |
CompoundList | A TAG_List of TAG_Compound. |
DoubleList | A TAG_List of TAG_Double. |
FloatList | A TAG_List of TAG_Float. |
IntArray | TAG_Int_Array, represented using NbtArray. |
IntArrayList | A TAG_List of TAG_Int_Array. |
IntList | A TAG_List of TAG_Int. |
ListList | A TAG_List of TAG_List. This is a nested list. The inner lists can each have distinct element types. |
LongArray | TAG_Long_Array, represented using NbtArray. |
LongArrayList | A TAG_List of TAG_Long_Array. |
LongList | A TAG_List of TAG_Long. |
ShortList | A TAG_List of TAG_Short. |
StringList | A TAG_List of TAG_String. |