[][src]Struct nobility::bin_decode::Document

pub struct Document { /* fields omitted */ }

Represents an NBT document and is the owner of the data contained in it. All other decoder types are borrows of the data stored in this.

Example

use nobility::bin_decode::Document;

// Either copies the data (plaintext) or decompresses it (gzip). Accepts
// any implementation of Read.
let doc = Document::load(input)?;

// Returns the root tag's name, and the root tag (always a Compound tag).
// Both of these are borrowing the data inside the Document.
let (name, root) = doc.parse()?;

Implementations

impl Document[src]

pub fn load<R: Read + Clone>(input: R) -> Result<Document, IoError>[src]

Loads a document from any source implementing Read. Sources that are compressed with gzip will be automatically decompressed, otherwise the data will just be copied.

Errors

Errors from this function are either from the input Read object or from GzDecoder.

pub fn parse(&self) -> Result<(NbtString<'_>, Compound<'_>), ParseError>[src]

Parses the document and returns the name and contents of the root tag.

Errors

The only cases that this should return an error are:

  1. The input is not an NBT document. This will likely generate ParseError::IncorrectStartTag.
  2. The input is an NBT document, but is malformed/corrupted, or in the Bedrock edition version of the format.
  3. The document is compressed using something other than gzip. This will likely generate ParseError::IncorrectStartTag.
  4. The specification has changed due to a new Minecraft version. This will likely generate ParseError::UnknownTag.
  5. There's a bug in the parser.

Trait Implementations

impl Clone for Document[src]

impl Debug for Document[src]

impl PartialEq<Document> for Document[src]

impl StructuralPartialEq for Document[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.