commandblock/
lib.rs

1/// This module provides functionality for reading, manipulating, and writing NBT data.
2/// It supports both Java and Bedrock data formats.
3///
4/// # Example
5///
6/// ```
7/// use commandblock::nbt::{read_from_file, write_to_file, NbtValue, Compression, Endian};
8/// use std::collections::HashMap;
9/// use std::path::PathBuf;
10///
11/// // Read NBT data from a file
12/// let path = PathBuf::from("./tests/data/bedrock_level.dat");
13/// let (name, mut value) = read_from_file(path, Compression::Uncompressed, Endian::Little).unwrap();
14///
15/// // Manipulate the NBT data which automatically converts to NbtValue's
16/// value.insert("test".to_string(), "Hello, world!");
17///
18/// let mut inner_compound = HashMap::new();
19/// inner_compound.insert("isTest".to_string(), NbtValue::Byte(1));
20/// inner_compound.insert("numberTests".to_string(), NbtValue::Int(123));
21/// value.insert("test2".to_string(), inner_compound);
22///
23/// // Write the manipulated NBT data to a new file
24/// let path = PathBuf::from("./tests/data/test.dat");
25/// write_to_file(Some(&name), value, path, Compression::Uncompressed, Endian::Little).unwrap();
26/// ```
27pub mod nbt;