Trait quartz_nbt::NbtRepr[][src]

pub trait NbtRepr: Sized {
    type Error;
    fn read_nbt(&mut self, nbt: &NbtCompound) -> Result<(), Self::Error>;
fn write_nbt(&self, nbt: &mut NbtCompound); fn to_nbt(&self) -> NbtCompound { ... } }
Expand description

Defines a type which has a full representation as a NbtCompound.

Full representation meaning that the type can be constructed from a NbtCompound, and fully serialized as one as well.

Associated Types

type Error[src]

The error type returned if the read_nbt function fails.

Required methods

fn read_nbt(&mut self, nbt: &NbtCompound) -> Result<(), Self::Error>[src]

Updates the data in this type based on the given compound. The intention is that data is copied, not moved, from the compound to update this type.

fn write_nbt(&self, nbt: &mut NbtCompound)[src]

Writes all necessary data to the given compound to serialize this type.

Although not enforced, the data written should allow for the type to be restored via the read_nbt function.

Provided methods

fn to_nbt(&self) -> NbtCompound[src]

Converts this type into an owned NbtCompound.

Currently this is just a wrapper around creating an empty compound, proceeding to call write_nbt on a mutable reference to that compound, then returning the compound.

Implementors