Struct nbt_lib::reader::NbtReader

source ·
pub struct NbtReader {
    pub data: Vec<u8>,
    pub cursor: usize,
}
Expand description

Struct that is needed for the NBT reading

Fields§

§data: Vec<u8>

A list of the whole data in bytes

§cursor: usize

Cursor, where we are currently reading

Implementations§

source§

impl NbtReader

source

pub fn new(data: Vec<u8>) -> NbtReader

function to create a new instance of NbtReader

§Arguments

data - List of the whole data in bytes

source

pub fn from_compressed_data(data: Vec<u8>) -> NbtReader

function to create a new instance of NbtReader but before storing the byte array it gets decompressed

§Arguments

data - List of the whole data in bytes

source

pub fn read_u8(&mut self) -> NbtResult<u8>

function to read an u8

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_i8(&mut self) -> NbtResult<i8>

function to read an i8

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_i16(&mut self) -> NbtResult<i16>

function to read an i16 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_le_i16(&mut self) -> NbtResult<i16>

function to read an i16 LE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_u16(&mut self) -> NbtResult<u16>

function to read an u16 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_le_u16(&mut self) -> NbtResult<u16>

function to read an u16 LE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_i32(&mut self) -> NbtResult<i32>

function to read an i32 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_u32(&mut self) -> NbtResult<u32>

function to read an u32 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_var_i32(&mut self) -> NbtResult<i32>

function to read a VarInt

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_var_i64(&mut self) -> NbtResult<i64>

function to read a VarLong

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_zigzag_var_i32(&mut self) -> NbtResult<i32>

function to read a ZigZagVarInt

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_i64(&mut self) -> NbtResult<i64>

function to read an i64 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_u64(&mut self) -> NbtResult<u64>

function to read an u64 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_f32(&mut self) -> NbtResult<f32>

function to read a f32 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_f64(&mut self) -> NbtResult<f64>

function to read a f64 BE

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_u8_array(&mut self, len: usize) -> NbtResult<Vec<u8>>

function to read an u8 array

§Arguments

len - The amount of elements in the array

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_i8_array(&mut self, len: usize) -> NbtResult<Vec<i8>>

function to read an i8 array

§Arguments

len - The amount of elements in the array

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_i32_array(&mut self, len: usize) -> NbtResult<Vec<i32>>

function to read an i32 BE array

§Arguments

len - The amount of elements in the array

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_be_i64_array(&mut self, len: usize) -> NbtResult<Vec<i64>>

function to read an i64 BE array

§Arguments

len - The amount of elements in the array

§Returns

Returns the value or an error, why whe read operation failed

source

pub fn read_string(&mut self, len: usize) -> Result<String, NbtError>

function to read an string

§Arguments

len - The length of the string

§Returns

Returns the value or an error, why whe read operation failed

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.