aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/README.md
blob: e13bcf228017996335a1ab91f0726d5ca1114ff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Azalea NBT

A fast NBT serializer and deserializer.

- Gzip and Zlib compression
- All data is owned for ease-of-use
- Serde support with the `serde` feature.

# Examples

```
use azalea_nbt::{Nbt, NbtCompound};
use std::io::Cursor;

let buf = include_bytes!("../tests/hello_world.nbt");
let tag = Nbt::read(&mut Cursor::new(&buf[..])).unwrap();
assert_eq!(
    tag,
    Nbt::Compound(NbtCompound::from_iter(vec![(
        "hello world".into(),
        Nbt::Compound(NbtCompound::from_iter(vec![(
            "name".into(),
            Nbt::String("Bananrama".into()),
        )]))
    )]))
);
```

# Benchmarks

At the time of writing, Azalea NBT is the fastest NBT decoder (approximately twice as fast as Graphite NBT, the second fastest) and on-par with the fastest NBT encoders (sometimes the fastest, depending on the data).

You can run the benchmarks to compare against other NBT libraries with `cargo bench --bench compare` and the normal benchmarks with `cargo bench --bench nbt`.

Note: For best performance, use `RUSTFLAGS='-C target-cpu=native'`.