pub struct BinaryReader<'a> { /* private fields */ }Expand description
Binary reader that matches TypeScript SDK decoding exactly
Implementations§
Source§impl<'a> BinaryReader<'a>
impl<'a> BinaryReader<'a>
Sourcepub fn has_remaining(&self) -> bool
pub fn has_remaining(&self) -> bool
Check if there are more bytes to read
Sourcepub fn peek_byte(&self) -> Result<u8, DecodingError>
pub fn peek_byte(&self) -> Result<u8, DecodingError>
Peek at the next byte without advancing position
Sourcepub fn read_byte(&mut self) -> Result<u8, DecodingError>
pub fn read_byte(&mut self) -> Result<u8, DecodingError>
Read a single byte
Sourcepub fn read_bytes(&mut self, count: usize) -> Result<&'a [u8], DecodingError>
pub fn read_bytes(&mut self, count: usize) -> Result<&'a [u8], DecodingError>
Read exact number of bytes
Sourcepub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), DecodingError>
Read exact number of bytes into a buffer
Sourcepub fn read_uvarint(&mut self) -> Result<u64, DecodingError>
pub fn read_uvarint(&mut self) -> Result<u64, DecodingError>
Decode an unsigned varint using Go’s canonical encoding/binary algorithm Matches Go: binary.ReadUvarint(r)
Sourcepub fn read_varint(&mut self) -> Result<i64, DecodingError>
pub fn read_varint(&mut self) -> Result<i64, DecodingError>
Decode a signed varint using Go’s canonical zigzag decoding Matches Go: binary.ReadVarint(r)
Sourcepub fn read_big_number(&mut self) -> Result<BigUint, DecodingError>
pub fn read_big_number(&mut self) -> Result<BigUint, DecodingError>
Decode a big number (unsigned big integer) Matches TS: bigNumberUnmarshalBinary(data: Uint8Array, offset?: number)
Sourcepub fn read_bool(&mut self) -> Result<bool, DecodingError>
pub fn read_bool(&mut self) -> Result<bool, DecodingError>
Decode a boolean value Matches TS: booleanUnmarshalBinary(data: Uint8Array, offset?: number)
Sourcepub fn read_string(&mut self) -> Result<String, DecodingError>
pub fn read_string(&mut self) -> Result<String, DecodingError>
Decode a string as UTF-8 bytes with length prefix Matches TS: stringUnmarshalBinary(data: Uint8Array, offset?: number)
Sourcepub fn read_bytes_with_length(&mut self) -> Result<&'a [u8], DecodingError>
pub fn read_bytes_with_length(&mut self) -> Result<&'a [u8], DecodingError>
Decode bytes with length prefix Matches TS: bytesUnmarshalBinary(data: Uint8Array, offset?: number)
Sourcepub fn read_hash(&mut self) -> Result<[u8; 32], DecodingError>
pub fn read_hash(&mut self) -> Result<[u8; 32], DecodingError>
Decode a 32-byte hash without length prefix Matches TS: hashUnmarshalBinary(data: Uint8Array, offset?: number)
Sourcepub fn read_hash_bytes(&mut self) -> Result<Vec<u8>, DecodingError>
pub fn read_hash_bytes(&mut self) -> Result<Vec<u8>, DecodingError>
Decode a variable-length hash with validation
Sourcepub fn read_remaining(&mut self) -> &'a [u8] ⓘ
pub fn read_remaining(&mut self) -> &'a [u8] ⓘ
Read the remaining bytes
Source§impl<'a> BinaryReader<'a>
Helper functions that match TypeScript SDK exactly
impl<'a> BinaryReader<'a>
Helper functions that match TypeScript SDK exactly
Sourcepub fn decode_uvarint(data: &[u8]) -> Result<(u64, usize), DecodingError>
pub fn decode_uvarint(data: &[u8]) -> Result<(u64, usize), DecodingError>
Decode uvarint as standalone function
Sourcepub fn decode_varint(data: &[u8]) -> Result<(i64, usize), DecodingError>
pub fn decode_varint(data: &[u8]) -> Result<(i64, usize), DecodingError>
Decode varint as standalone function
Sourcepub fn decode_string(data: &[u8]) -> Result<(String, usize), DecodingError>
pub fn decode_string(data: &[u8]) -> Result<(String, usize), DecodingError>
Decode string as standalone function
Sourcepub fn decode_bytes(data: &[u8]) -> Result<(Vec<u8>, usize), DecodingError>
pub fn decode_bytes(data: &[u8]) -> Result<(Vec<u8>, usize), DecodingError>
Decode bytes as standalone function
Sourcepub fn decode_bool(data: &[u8]) -> Result<(bool, usize), DecodingError>
pub fn decode_bool(data: &[u8]) -> Result<(bool, usize), DecodingError>
Decode boolean as standalone function
Sourcepub fn decode_hash(data: &[u8]) -> Result<([u8; 32], usize), DecodingError>
pub fn decode_hash(data: &[u8]) -> Result<([u8; 32], usize), DecodingError>
Decode hash as standalone function
Trait Implementations§
Source§impl<'a> Clone for BinaryReader<'a>
impl<'a> Clone for BinaryReader<'a>
Source§fn clone(&self) -> BinaryReader<'a>
fn clone(&self) -> BinaryReader<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more