azalea/azalea-nbt/README.md

34 lines
992 B
Markdown
Raw Normal View History

2021-12-20 19:36:20 +00:00
# Azalea NBT
2022-04-22 18:03:57 +00:00
A fast NBT serializer and deserializer.
2023-01-30 22:05:18 +00:00
2023-03-23 18:04:53 +00:00
- Gzip and Zlib compression
- All data is owned for ease-of-use
- Serde support with the `serde` feature.
2023-01-30 22:05:18 +00:00
# Examples
```
2023-03-23 13:55:33 +00:00
use azalea_nbt::{Nbt, NbtCompound};
2023-03-11 22:38:13 +00:00
use std::io::Cursor;
2023-01-30 22:05:18 +00:00
2023-03-11 22:38:13 +00:00
let buf = include_bytes!("../tests/hello_world.nbt");
2023-03-23 13:55:33 +00:00
let tag = Nbt::read(&mut Cursor::new(&buf[..])).unwrap();
2023-01-30 22:05:18 +00:00
assert_eq!(
tag,
2023-03-23 13:55:33 +00:00
Nbt::Compound(NbtCompound::from_iter(vec![(
2023-03-22 13:52:38 +00:00
"hello world".into(),
2023-03-23 13:55:33 +00:00
Nbt::Compound(NbtCompound::from_iter(vec![(
2023-03-22 13:52:38 +00:00
"name".into(),
2023-03-23 13:55:33 +00:00
Nbt::String("Bananrama".into()),
2023-01-30 22:05:18 +00:00
)]))
)]))
);
```
2023-03-23 18:04:53 +00:00
# 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`.