Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

60 Commits

Repository files navigation

named-binary-tag

crates.ioBuild Statuscodecov

NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of additional data.

Usage

Add this to your Cargo.toml:

[dependencies]
named-binary-tag = "0.6"

Example

Read

use nbt::decode::read_compound_tag;use std::io::Cursor;letmut cursor = Cursor::new(include_bytes!("../test/binary/servers.dat").to_vec());let root_tag = read_compound_tag(&mut cursor).unwrap();let servers = root_tag.get_compound_tag_vec("servers").unwrap();assert_eq!(servers.len(),1);let server = servers[0];let ip = server.get_str("ip").unwrap();let name = server.get_str("name").unwrap();let hide_address = server.get_bool("hideAddress").unwrap();assert_eq!(ip,"localhost:25565");assert_eq!(name,"Minecraft Server");assert!(hide_address);

Write

use nbt::encode::write_compound_tag;use nbt::CompoundTag;letmut server = CompoundTag::new();
server.insert_str("ip","localhost:25565");
server.insert_str("name","Minecraft Server");
server.insert_bool("hideAddress",true);letmut servers = Vec::new();
servers.push(server);letmut root_tag = CompoundTag::new();
root_tag.insert_compound_tag_vec("servers", servers);letmut vec = Vec::new();write_compound_tag(&mut vec,&root_tag).unwrap();

About

Tag based binary format designed to carry large amounts of binary data

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages