pub fn decode<T: DeserializeOwned>(tag: Blob) -> Result<T, NBTError>Expand description
Decode a NBT Blob into a Serde deserializable value.
ยงExample
use nbt::{Tag, decode, Blob};
use serde::Deserialize;
// Create Deserializable struct
#[derive(Deserialize, PartialEq, Debug)]
pub struct Example {
foo: String
}
// Create a Blob
let mut blob = Blob::new();
blob.insert("foo", "bar");
// Decode the data from blob
let data: Example = decode(blob).unwrap();
assert_eq!(data, Example { foo: "bar".to_string() });