Struct binarystream::binary::BinaryStream
source · 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
impl BinaryStream
source§impl BinaryStream
impl BinaryStream
sourcepub fn read_uint8(&mut self) -> Result<u8>
pub fn read_uint8(&mut self) -> Result<u8>
- readUint8
- Reads an unsigned 8-bit ( 1 byte ) integer from the stream. ( 0 to 255 )
sourcepub fn write_uint8(&mut self, value: u8)
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
impl BinaryStream
sourcepub fn read_uint16(&mut self, endian: Option<Endianness>) -> Result<u16>
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 )
sourcepub fn write_uint16(&mut self, value: u16, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_uint24(&mut self, endian: Option<Endianness>) -> Result<u32>
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 )
sourcepub fn write_uint24(&mut self, value: u32, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_uint32(&mut self, endian: Option<Endianness>) -> Result<u32>
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 )
sourcepub fn write_uint32(&mut self, value: u32, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_uint64(&mut self, endian: Option<Endianness>) -> Result<BigInt>
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 )
sourcepub fn write_uint64(&mut self, value: BigInt, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_u_short(&mut self, endian: Option<Endianness>) -> Result<u16>
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 )
sourcepub fn write_u_short(&mut self, value: u16, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_u_long(&mut self, endian: Option<Endianness>) -> Result<BigInt>
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 )
sourcepub fn write_u_long(&mut self, value: BigInt, endian: Option<Endianness>)
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
impl BinaryStream
source§impl BinaryStream
impl BinaryStream
source§impl BinaryStream
impl BinaryStream
sourcepub fn read_int16(&mut self, endian: Option<Endianness>) -> Result<i16>
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 )
sourcepub fn write_int16(&mut self, value: i16, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_int24(&mut self, endian: Option<Endianness>) -> Result<i32>
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 )
sourcepub fn write_int24(&mut self, value: i32, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_int32(&mut self, endian: Option<Endianness>) -> Result<i32>
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 )
sourcepub fn write_int32(&mut self, value: i32, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_int64(&mut self, endian: Option<Endianness>) -> Result<BigInt>
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 )
sourcepub fn write_int64(&mut self, value: BigInt, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_short(&mut self, endian: Option<Endianness>) -> Result<i16>
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 )
sourcepub fn write_short(&mut self, value: i16, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_long(&mut self, endian: Option<Endianness>) -> Result<BigInt>
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 )
sourcepub fn write_long(&mut self, value: BigInt, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_float32(&mut self, endian: Option<Endianness>) -> Result<f64>
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 )
sourcepub fn write_float32(&mut self, value: f64, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_float64(&mut self, endian: Option<Endianness>) -> Result<f64>
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 )
sourcepub fn write_float64(&mut self, value: f64, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_var_int(&mut self) -> Result<u32>
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 )
sourcepub fn write_var_int(&mut self, value: u32)
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
impl BinaryStream
sourcepub fn read_zig_zag(&mut self) -> Result<i32>
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 )
sourcepub fn write_zig_zag(&mut self, value: i32)
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
impl BinaryStream
sourcepub fn read_var_long(&mut self) -> Result<BigInt>
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 )
sourcepub fn write_var_long(&mut self, value: BigInt)
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
impl BinaryStream
sourcepub fn read_zig_zong(&mut self) -> Result<BigInt>
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 )
sourcepub fn write_zig_zong(&mut self, value: BigInt)
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
impl BinaryStream
sourcepub fn read_string16(&mut self, endian: Option<Endianness>) -> Result<String>
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 )
sourcepub fn write_string16(&mut self, value: String, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_string32(&mut self, endian: Option<Endianness>) -> Result<String>
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 )
sourcepub fn write_string32(&mut self, value: String, endian: Option<Endianness>)
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
impl BinaryStream
sourcepub fn read_var_string(&mut self) -> Result<String>
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 )
sourcepub fn write_var_string(&mut self, value: String)
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
impl BinaryStream
source§impl BinaryStream
impl BinaryStream
source§impl BinaryStream
impl BinaryStream
pub fn into_reference( val: BinaryStream, env: Env ) -> Result<Reference<BinaryStream>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<BinaryStream>>
source§impl BinaryStream
impl BinaryStream
sourcepub fn new(buffer: Option<Buffer>, offset: Option<u32>) -> Self
pub fn new(buffer: Option<Buffer>, offset: Option<u32>) -> Self
- BinaryStream
- Creates a new BinaryStream with an optional JavaScript Buffer.
sourcepub fn from(binary: Vec<u8>, offset: Option<u32>) -> Self
pub fn from(binary: Vec<u8>, offset: Option<u32>) -> Self
- from
- Creates a new BinaryStream from a binary vector.
sourcepub fn from_buffer(buffer: Buffer, offset: Option<u32>) -> Self
pub fn from_buffer(buffer: Buffer, offset: Option<u32>) -> Self
- fromBuffer
- Creates a new BinaryStream from a JavaScript Buffer.
sourcepub fn read(&mut self, length: u32) -> Result<Vec<u8>>
pub fn read(&mut self, length: u32) -> Result<Vec<u8>>
- read
- Reads a number of bytes from the stream.
sourcepub fn read_buffer(&mut self, length: u32) -> Result<Buffer>
pub fn read_buffer(&mut self, length: u32) -> Result<Buffer>
- readBuffer
- Reads a number of bytes from the stream and returns a JavaScript Buffer.
sourcepub fn write_buffer(&mut self, data: Buffer)
pub fn write_buffer(&mut self, data: Buffer)
- **writeBuffer
- Writes a JavaScript Buffer to the stream.
sourcepub fn read_remaining(&mut self) -> Vec<u8>
pub fn read_remaining(&mut self) -> Vec<u8>
- readRemaining
- Reads the remaining bytes from the stream.
sourcepub fn read_remaining_buffer(&mut self) -> Buffer
pub fn read_remaining_buffer(&mut self) -> Buffer
- readRemainingBuffer
- Reads the remaining bytes from the stream and returns a JavaScript Buffer.
sourcepub fn cursor_at_end(&self) -> bool
pub fn cursor_at_end(&self) -> bool
- cursorAtEnd
- Checks if the cursor is at the end of the stream.
sourcepub fn cursor_at_start(&self) -> bool
pub fn cursor_at_start(&self) -> bool
- cursorAtStart
- Checks if the cursor is at the start of the stream.
sourcepub fn get_buffer(&self) -> Buffer
pub fn get_buffer(&self) -> Buffer
- getBuffer
- Gets the binary as a JavaScript Buffer.
Trait Implementations§
source§impl FromNapiMutRef for BinaryStream
impl FromNapiMutRef for BinaryStream
source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value
) -> Result<&'static mut Self>
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
impl FromNapiRef for BinaryStream
source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value ) -> Result<&'static Self>
Safety Read more
source§impl FromNapiValue for &BinaryStream
impl FromNapiValue for &BinaryStream
source§impl FromNapiValue for &mut BinaryStream
impl FromNapiValue for &mut BinaryStream
source§impl ToNapiValue for BinaryStream
impl ToNapiValue for BinaryStream
source§unsafe fn to_napi_value(env: napi_env, val: BinaryStream) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: BinaryStream) -> Result<napi_value>
Safety Read more
source§impl TypeName for &BinaryStream
impl TypeName for &BinaryStream
source§impl TypeName for &mut BinaryStream
impl TypeName for &mut BinaryStream
source§impl TypeName for BinaryStream
impl TypeName for BinaryStream
source§impl ValidateNapiValue for &BinaryStream
impl ValidateNapiValue for &BinaryStream
source§impl ValidateNapiValue for &mut BinaryStream
impl ValidateNapiValue for &mut BinaryStream
Auto Trait Implementations§
impl RefUnwindSafe for BinaryStream
impl Send for BinaryStream
impl Sync for BinaryStream
impl Unpin for BinaryStream
impl UnwindSafe for BinaryStream
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more