Skip to main content

TupleInput

Struct TupleInput 

Source
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

Source

pub fn new(data: &[u8]) -> Self

Creates a new TupleInput from a byte slice (copies the slice).

Source

pub fn from_vec(data: Vec<u8>) -> Self

Creates a new TupleInput from a byte vector — zero-copy.

Source

pub fn from_bytes(data: Bytes) -> Self

Creates a new TupleInput from existing Bytes — zero-copy.

Source

pub fn available(&self) -> usize

Returns the number of bytes remaining to be read.

Source

pub fn get_offset(&self) -> usize

Returns the current read offset.

Source

pub fn set_offset(&mut self, offset: usize)

Sets the read offset.

Source

pub fn get_buffer(&self) -> &[u8]

Returns a reference to the underlying buffer.

Source

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.

Source

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

Reads an unsigned byte value.

Reads values written by TupleOutput::write_u8.

Source

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.

Source

pub fn read_u16(&mut self) -> Result<u16>

Reads an unsigned short (two byte, big-endian) value.

Reads values written by TupleOutput::write_u16.

Source

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.

Source

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

Reads an unsigned int (four byte, big-endian) value.

Reads values written by TupleOutput::write_u32.

Source

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.

Source

pub fn read_u64(&mut self) -> Result<u64>

Reads an unsigned long (eight byte, big-endian) value.

Reads values written by TupleOutput::write_u64.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Reads the specified number of raw bytes from the buffer.

Reads values written by TupleOutput::write_bytes.

Source

pub fn skip(&mut self, count: usize) -> Result<()>

Skips the specified number of bytes.

Trait Implementations§

Source§

impl Clone for TupleInput

Source§

fn clone(&self) -> TupleInput

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TupleInput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.