pub struct BinaryStream {
    pub binary: Vec<u8>,
    pub offset: u32,
}

Fields§

§binary: Vec<u8>
  • binary
  • The binary data of the stream.
§offset: u32
  • offset
  • The current offset of the stream.

Implementations§

source§

impl BinaryStream

source

pub fn read_bool(&mut self) -> Result<bool>

  • readBool
  • Reads a boolean ( 1 byte ) value from the stream. ( true or false )
source

pub fn write_bool(&mut self, value: bool)

  • writeBool
  • Writes a boolean ( 1 byte ) value to the stream. ( true or false )
source§

impl BinaryStream

source

pub fn read_uint8(&mut self) -> Result<u8>

  • readUint8
  • Reads an unsigned 8-bit ( 1 byte ) integer from the stream. ( 0 to 255 )
source

pub fn write_uint8(&mut self, value: u8)

  • writeUint8
  • Writes an unsigned 8-bit ( 1 byte ) integer to the stream. ( 0 to 255 )
source§

impl BinaryStream

source

pub fn read_uint16(&mut self, endian: Option<Endianness>) -> Result<u16>

  • readUint16
  • Read an unsigned 16-bit ( 2 bytes ) integer from the stream. ( 0 to 65535 )
source

pub fn write_uint16(&mut self, value: u16, endian: Option<Endianness>)

  • writeUint16
  • Write an unsigned 16-bit ( 2 bytes ) integer to the stream. ( 0 to 65535 )
source§

impl BinaryStream

source

pub fn read_uint24(&mut self, endian: Option<Endianness>) -> Result<u32>

  • readUint24
  • Reads an unsigned 24-bit ( 3 bytes ) integer from the stream. ( 0 to 16777215 )
source

pub fn write_uint24(&mut self, value: u32, endian: Option<Endianness>)

  • writeUint24
  • Writes an unsigned 24-bit ( 3 bytes ) integer to the stream. ( 0 to 16777215 )
source§

impl BinaryStream

source

pub fn read_uint32(&mut self, endian: Option<Endianness>) -> Result<u32>

  • readUint32
  • Reads an unsigned 32-bit ( 4 bytes ) integer from the stream. ( 0 to 4294967295 )
source

pub fn write_uint32(&mut self, value: u32, endian: Option<Endianness>)

  • writeUint32
  • Writes an unsigned 32-bit ( 4 bytes ) integer to the stream. ( 0 to 4294967295 )
source§

impl BinaryStream

source

pub fn read_uint64(&mut self, endian: Option<Endianness>) -> Result<BigInt>

  • readUint64
  • Reads an usigned 64-bit ( 8 bytes ) integer from the stream. ( 0 to 18446744073709551615 )
source

pub fn write_uint64(&mut self, value: BigInt, endian: Option<Endianness>)

  • writeUint64
  • Writes an unsigned 64-bit ( 8 bytes ) integer to the stream. ( 0 to 18446744073709551615 )
source§

impl BinaryStream

source

pub fn read_u_short(&mut self, endian: Option<Endianness>) -> Result<u16>

  • readUShort
  • Read an unsigned 16-bit ( 2 bytes ) integer from the stream. ( 0 to 65535 )
source

pub fn write_u_short(&mut self, value: u16, endian: Option<Endianness>)

  • writeUShort
  • Write an unsigned 16-bit ( 2 bytes ) integer to the stream. ( 0 to 65535 )
source§

impl BinaryStream

source

pub fn read_u_long(&mut self, endian: Option<Endianness>) -> Result<BigInt>

  • readULong
  • Reads an usigned 64-bit ( 8 bytes ) integer from the stream. ( 0 to 18446744073709551615 )
source

pub fn write_u_long(&mut self, value: BigInt, endian: Option<Endianness>)

  • writeULong
  • Writes an unsigned 64-bit ( 8 bytes ) integer to the stream. ( 0 to 18446744073709551615 )
source§

impl BinaryStream

source

pub fn read_byte(&mut self) -> Result<i8>

  • readByte
  • Reads a signed 8-bit ( 1 byte ) integer from the stream. ( -128 to 127 )
source

pub fn write_byte(&mut self, value: i8)

  • writeByte
  • Writes a signed 8-bit ( 1 byte ) integer to the stream. ( -128 to 127 )
source§

impl BinaryStream

source

pub fn read_int8(&mut self) -> Result<i8>

  • readInt8
  • Reads a signed 8-bit ( 1 byte ) integer from the stream. ( -128 to 127 )
source

pub fn write_int8(&mut self, value: i8)

  • writeInt8
  • Writes a signed 8-bit ( 1 byte ) integer to the stream. ( -128 to 127 )
source§

impl BinaryStream

source

pub fn read_int16(&mut self, endian: Option<Endianness>) -> Result<i16>

  • readInt16
  • Reads a signed 16-bit ( 2 bytes ) integer from the stream. ( -32768 to 32767 )
source

pub fn write_int16(&mut self, value: i16, endian: Option<Endianness>)

  • writeInt16
  • Writes a signed 16-bit ( 2 bytes ) integer to the stream. ( -32768 to 32767 )
source§

impl BinaryStream

source

pub fn read_int24(&mut self, endian: Option<Endianness>) -> Result<i32>

  • readInt24
  • Reads a signed 24-bit ( 3 bytes ) integer from the stream. ( -8388608 to 8388607 )
source

pub fn write_int24(&mut self, value: i32, endian: Option<Endianness>)

  • writeInt24
  • Writes a signed 24-bit ( 3 bytes ) integer to the stream. ( -8388608 to 8388607 )
source§

impl BinaryStream

source

pub fn read_int32(&mut self, endian: Option<Endianness>) -> Result<i32>

  • readInt32
  • Reads a signed 32-bit ( 4 bytes ) integer from the stream. ( -2147483648 to 2147483647 )
source

pub fn write_int32(&mut self, value: i32, endian: Option<Endianness>)

  • writeInt32
  • Write a signed 32-bit ( 4 bytes ) integer to the stream. ( -2147483648 to 2147483647 )
source§

impl BinaryStream

source

pub fn read_int64(&mut self, endian: Option<Endianness>) -> Result<BigInt>

  • readInt64
  • Reads a signed 64-bit ( 8 bytes ) integer from the stream. ( -9223372036854775808 to 9223372036854775807 )
source

pub fn write_int64(&mut self, value: BigInt, endian: Option<Endianness>)

  • writeInt64
  • Writes a signed 64-bit ( 8 bytes ) integer to the stream. ( -9223372036854775808 to 9223372036854775807 )
source§

impl BinaryStream

source

pub fn read_short(&mut self, endian: Option<Endianness>) -> Result<i16>

  • readShort
  • Reads a signed 16-bit ( 2 bytes ) integer from the stream. ( -32768 to 32767 )
source

pub fn write_short(&mut self, value: i16, endian: Option<Endianness>)

  • writeShort
  • Writes a signed 16-bit ( 2 bytes ) integer to the stream. ( -32768 to 32767 )
source§

impl BinaryStream

source

pub fn read_long(&mut self, endian: Option<Endianness>) -> Result<BigInt>

  • readLong
  • Reads a signed 64-bit ( 8 bytes ) integer from the stream. ( -9223372036854775808 to 9223372036854775807 )
source

pub fn write_long(&mut self, value: BigInt, endian: Option<Endianness>)

  • writeLong
  • Writes a signed 64-bit ( 8 bytes ) integer to the stream. ( -9223372036854775808 to 9223372036854775807 )
source§

impl BinaryStream

source

pub fn read_float32(&mut self, endian: Option<Endianness>) -> Result<f64>

  • readFloat32
  • Reads a signed 32-bit ( 4 bytes ) integer from the stream. ( -2147483648 to 2147483647 )
source

pub fn write_float32(&mut self, value: f64, endian: Option<Endianness>)

  • writeFloat32
  • Write a signed 32-bit ( 4 bytes ) integer to the stream. ( -2147483648 to 2147483647 )
source§

impl BinaryStream

source

pub fn read_float64(&mut self, endian: Option<Endianness>) -> Result<f64>

  • readFloat64
  • Reads a signed 64 bit ( 8 bytes ) floating point number from the stream. ( -1.7976931348623157e308 to 1.7976931348623157e308 )
source

pub fn write_float64(&mut self, value: f64, endian: Option<Endianness>)

  • writeFloat64
  • Writes a signed 64 bit ( 8 bytes ) floating point number to the stream. ( -1.7976931348623157e308 to 1.7976931348623157e308 )
source§

impl BinaryStream

source

pub fn read_var_int(&mut self) -> Result<u32>

  • readVarInt
  • Reads a 32 bit ( 4 bytes ) unsigned variable length integer from the stream. ( 0 to 4294967295 )
source

pub fn write_var_int(&mut self, value: u32)

  • writeVarInt
  • Writes a 32 bit ( 4 bytes ) unsigned variable length integer to the stream. ( 0 to 4294967295 )
source§

impl BinaryStream

source

pub fn read_zig_zag(&mut self) -> Result<i32>

  • readZigZag
  • Reads a 32 bit ( 4 bytes ) zigzag encoded signed variable length integer from the stream. ( -2147483648 to 2147483647 )
source

pub fn write_zig_zag(&mut self, value: i32)

  • writeZigZag
  • Writes a 32 bit ( 4 bytes ) zigzag encoded signed variable length integer to the stream. ( -2147483648 to 2147483647 )
source§

impl BinaryStream

source

pub fn read_var_long(&mut self) -> Result<BigInt>

  • readVarLong
  • Reads a 64 bit ( 8 bytes ) unsigned variable length integer from the stream. ( 0 to 18446744073709551615 )
source

pub fn write_var_long(&mut self, value: BigInt)

  • writeVarLong
  • Writes a 64 bit ( 8 bytes ) unsigned variable length integer to the stream. ( 0 to 18446744073709551615 )
source§

impl BinaryStream

source

pub fn read_zig_zong(&mut self) -> Result<BigInt>

  • readZigZong
  • Reads a 64 bit ( 8 bytes ) zigzag encoded signed variable length integer from the stream. ( -9223372036854775808 to 9223372036854775807 )
source

pub fn write_zig_zong(&mut self, value: BigInt)

  • writeZigZong
  • Writes a 64 bit ( 8 bytes ) zigzag encoded signed variable length integer to the stream. ( -9223372036854775808 to 9223372036854775807 )
source§

impl BinaryStream

source

pub fn read_string16(&mut self, endian: Option<Endianness>) -> Result<String>

  • readString16
  • Reads an unsigned 16-bit ( 2 bytes ) utf-8 string from the stream. ( 0 to 65535 )
source

pub fn write_string16(&mut self, value: String, endian: Option<Endianness>)

  • writeString16
  • Writes an unsigned 16-bit ( 2 bytes ) utf-8 string to the stream. ( 0 to 65535 )
source§

impl BinaryStream

source

pub fn read_string32(&mut self, endian: Option<Endianness>) -> Result<String>

  • readString32
  • Reads a signed 32-bit ( 4 bytes ) utf-8 string from the stream. ( 0 to 4294967295 )
source

pub fn write_string32(&mut self, value: String, endian: Option<Endianness>)

  • writeString32
  • Writes a signed 32-bit ( 4 bytes ) utf-8 string to the stream. ( 0 to 4294967295 )
source§

impl BinaryStream

source

pub fn read_var_string(&mut self) -> Result<String>

  • readVarString
  • Reads a signed 32-bit ( 4 bytes ) utf-8 string from the stream. ( 0 to 4294967295 )
source

pub fn write_var_string(&mut self, value: String)

  • writeVarString
  • Writes a signed 32-bit ( 4 bytes ) utf-8 string to the stream. ( 0 to 4294967295 )
source§

impl BinaryStream

source

pub fn read_uuid(&mut self) -> Result<String>

  • readUuid
  • Reads a signed 128-bit ( 16 bytes ) uuid string from the stream.
source

pub fn write_uuid(&mut self, value: String)

  • writeUuid
  • Writes a signed 128-bit ( 16 bytes ) uuid string to the stream.
source§

impl BinaryStream

source

pub fn instance_of<V: NapiRaw>(env: Env, value: V) -> Result<bool>

source§

impl BinaryStream

source§

impl BinaryStream

source

pub fn new(buffer: Option<Buffer>, offset: Option<u32>) -> Self

  • BinaryStream
  • Creates a new BinaryStream with an optional JavaScript Buffer.
source

pub fn from(binary: Vec<u8>, offset: Option<u32>) -> Self

  • from
  • Creates a new BinaryStream from a binary vector.
source

pub fn from_buffer(buffer: Buffer, offset: Option<u32>) -> Self

  • fromBuffer
  • Creates a new BinaryStream from a JavaScript Buffer.
source

pub fn read(&mut self, length: u32) -> Result<Vec<u8>>

  • read
  • Reads a number of bytes from the stream.
source

pub fn read_buffer(&mut self, length: u32) -> Result<Buffer>

  • readBuffer
  • Reads a number of bytes from the stream and returns a JavaScript Buffer.
source

pub fn write(&mut self, data: Vec<u8>)

  • write
  • Writes a number of bytes to the stream.
source

pub fn write_buffer(&mut self, data: Buffer)

  • **writeBuffer
  • Writes a JavaScript Buffer to the stream.
source

pub fn read_remaining(&mut self) -> Vec<u8>

  • readRemaining
  • Reads the remaining bytes from the stream.
source

pub fn read_remaining_buffer(&mut self) -> Buffer

  • readRemainingBuffer
  • Reads the remaining bytes from the stream and returns a JavaScript Buffer.
source

pub fn skip(&mut self, length: u32)

  • skip
  • Skips a number of bytes from the stream.
source

pub fn cursor_at_end(&self) -> bool

  • cursorAtEnd
  • Checks if the cursor is at the end of the stream.
source

pub fn cursor_at_start(&self) -> bool

  • cursorAtStart
  • Checks if the cursor is at the start of the stream.
source

pub fn get_buffer(&self) -> Buffer

  • getBuffer
  • Gets the binary as a JavaScript Buffer.

Trait Implementations§

source§

impl FromNapiMutRef for BinaryStream

source§

unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value ) -> Result<&'static mut Self>

Safety Read more
source§

impl FromNapiRef for BinaryStream

source§

unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value ) -> Result<&'static Self>

Safety Read more
source§

impl FromNapiValue for &BinaryStream

source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

source§

impl FromNapiValue for &mut BinaryStream

source§

unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self, Error>

source§

impl NapiRaw for &BinaryStream

source§

unsafe fn raw(&self) -> napi_value

source§

impl NapiRaw for &mut BinaryStream

source§

unsafe fn raw(&self) -> napi_value

source§

impl ObjectFinalize for BinaryStream

source§

fn finalize(self, env: Env) -> Result<(), Error>

source§

impl ToNapiValue for BinaryStream

source§

unsafe fn to_napi_value(env: napi_env, val: BinaryStream) -> Result<napi_value>

Safety Read more
source§

impl TypeName for &BinaryStream

source§

impl TypeName for &mut BinaryStream

source§

impl TypeName for BinaryStream

source§

impl ValidateNapiValue for &BinaryStream

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more
source§

impl ValidateNapiValue for &mut BinaryStream

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more

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> JsValuesTupleIntoVec for T
where T: ToNapiValue,

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.