pub struct TupleInput { /* private fields */ }Expand description
A reader for tuple-encoded byte data.
Reads primitive values from a byte buffer using the same encoding formats
as TupleInput. Signed integers use big-endian with the sign bit
flipped for sortable ordering. Floats use IEEE 754 with bit manipulation
for sortable ordering.
Internally uses bytes::Bytes so that clone() is O(1) and from_vec
is zero-copy.
Implementations§
Source§impl TupleInput
impl TupleInput
Sourcepub fn from_vec(data: Vec<u8>) -> Self
pub fn from_vec(data: Vec<u8>) -> Self
Creates a new TupleInput from a byte vector — zero-copy.
Sourcepub fn from_bytes(data: Bytes) -> Self
pub fn from_bytes(data: Bytes) -> Self
Creates a new TupleInput from existing Bytes — zero-copy.
Sourcepub fn get_offset(&self) -> usize
pub fn get_offset(&self) -> usize
Returns the current read offset.
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Sets the read offset.
Sourcepub fn get_buffer(&self) -> &[u8] ⓘ
pub fn get_buffer(&self) -> &[u8] ⓘ
Returns a reference to the underlying buffer.
Sourcepub fn read_bool(&mut self) -> Result<bool>
pub fn read_bool(&mut self) -> Result<bool>
Reads a boolean (one byte) value. Non-zero is true.
Reads values written by TupleOutput::write_bool.
Sourcepub fn read_u8(&mut self) -> Result<u8>
pub fn read_u8(&mut self) -> Result<u8>
Reads an unsigned byte value.
Reads values written by TupleOutput::write_u8.
Sourcepub fn read_i8(&mut self) -> Result<i8>
pub fn read_i8(&mut self) -> Result<i8>
Reads a signed byte (one byte) value with sign bit flipped for sort order.
Reads values written by TupleOutput::write_i8.
Sourcepub fn read_u16(&mut self) -> Result<u16>
pub fn read_u16(&mut self) -> Result<u16>
Reads an unsigned short (two byte, big-endian) value.
Reads values written by TupleOutput::write_u16.
Sourcepub fn read_i16(&mut self) -> Result<i16>
pub fn read_i16(&mut self) -> Result<i16>
Reads a signed short (two byte) value with sign bit flipped for sort order.
Reads values written by TupleOutput::write_i16.
Sourcepub fn read_u32(&mut self) -> Result<u32>
pub fn read_u32(&mut self) -> Result<u32>
Reads an unsigned int (four byte, big-endian) value.
Reads values written by TupleOutput::write_u32.
Sourcepub fn read_i32(&mut self) -> Result<i32>
pub fn read_i32(&mut self) -> Result<i32>
Reads a signed int (four byte) value with sign bit flipped for sort order.
Reads values written by TupleOutput::write_i32.
Sourcepub fn read_u64(&mut self) -> Result<u64>
pub fn read_u64(&mut self) -> Result<u64>
Reads an unsigned long (eight byte, big-endian) value.
Reads values written by TupleOutput::write_u64.
Sourcepub fn read_i64(&mut self) -> Result<i64>
pub fn read_i64(&mut self) -> Result<i64>
Reads a signed long (eight byte) value with sign bit flipped for sort order.
Reads values written by TupleOutput::write_i64.
Sourcepub fn read_float(&mut self) -> Result<f32>
pub fn read_float(&mut self) -> Result<f32>
Reads an unsorted float (four byte) value from the buffer.
The float is stored as raw IEEE 754 bits in big-endian order. This does NOT produce sortable byte ordering.
Reads values written by TupleOutput::write_float.
Sourcepub fn read_double(&mut self) -> Result<f64>
pub fn read_double(&mut self) -> Result<f64>
Reads an unsorted double (eight byte) value from the buffer.
The double is stored as raw IEEE 754 bits in big-endian order. This does NOT produce sortable byte ordering.
Reads values written by TupleOutput::write_double.
Sourcepub fn read_sorted_float(&mut self) -> Result<f32>
pub fn read_sorted_float(&mut self) -> Result<f32>
Reads a sorted float (four byte) value from the buffer.
Uses sign-bit manipulation to produce sortable byte ordering:
- Positive floats: sign bit flipped (0x80000000 XOR)
- Negative floats: all bits flipped (0xFFFFFFFF XOR)
Reads values written by TupleOutput::write_sorted_float.
Sourcepub fn read_sorted_double(&mut self) -> Result<f64>
pub fn read_sorted_double(&mut self) -> Result<f64>
Reads a sorted double (eight byte) value from the buffer.
Uses sign-bit manipulation to produce sortable byte ordering:
- Positive doubles: sign bit flipped (0x8000000000000000 XOR)
- Negative doubles: all bits flipped (0xFFFFFFFFFFFFFFFF XOR)
Reads values written by TupleOutput::write_sorted_double.
Sourcepub fn read_packed_int(&mut self) -> Result<i32>
pub fn read_packed_int(&mut self) -> Result<i32>
Reads a packed (variable-length) i32 value.
This is an unsorted variable-length encoding where values in [-119, 119] are stored in a single byte. Larger values use 2-5 bytes.
Reads values written by TupleOutput::write_packed_int.
Sourcepub fn read_packed_long(&mut self) -> Result<i64>
pub fn read_packed_long(&mut self) -> Result<i64>
Reads a packed (variable-length) i64 value.
This is an unsorted variable-length encoding where values in [-119, 119] are stored in a single byte. Larger values use 2-9 bytes.
Reads values written by TupleOutput::write_packed_long.
Sourcepub fn read_sorted_packed_int(&mut self) -> Result<i32>
pub fn read_sorted_packed_int(&mut self) -> Result<i32>
Reads a sorted packed (variable-length, order-preserving) i32 value.
Decodes the format written by TupleOutput::write_sorted_packed_int.
Single-byte range [-119, 120]: first byte in [0x08, 0xF7], stored as
(value + 127). Negative multi-byte: first byte < 0x08, meaning
(0x08 - b1) big-endian value bytes follow; value = raw - 119.
Positive multi-byte: first byte > 0xF7, meaning (b1 - 0xF7) big-endian
value bytes follow; value = raw + 121.
Sourcepub fn read_sorted_packed_long(&mut self) -> Result<i64>
pub fn read_sorted_packed_long(&mut self) -> Result<i64>
Reads a sorted packed (variable-length, order-preserving) i64 value.
Decodes the format written by TupleOutput::write_sorted_packed_long.
Uses the same header-byte scheme as read_sorted_packed_int, extended
to up to 8 value bytes.
Sourcepub fn read_char(&mut self) -> Result<u16>
pub fn read_char(&mut self) -> Result<u16>
Reads a Java char (16-bit Unicode code point) stored as two big-endian bytes.
Reads values written by TupleOutput::write_char.
Sourcepub fn read_string(&mut self) -> Result<String>
pub fn read_string(&mut self) -> Result<String>
Reads a null-escaped UTF-8 string from the buffer.
Scans for the two-byte terminator [0x00, 0x00], unescaping any
[0x00, 0x01] sequences back to a single 0x00 byte. This is the
inverse of TupleOutput::write_string.
Trait Implementations§
Source§impl Clone for TupleInput
impl Clone for TupleInput
Source§fn clone(&self) -> TupleInput
fn clone(&self) -> TupleInput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more