Skip to main content

TtcReader

Struct TtcReader 

Source
pub struct TtcReader<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> TtcReader<'a>

Source

pub fn new(bytes: &'a [u8]) -> Self

Source

pub fn remaining(&self) -> usize

Source

pub fn position(&self) -> usize

Source

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

Source

pub fn peek_u8(&self) -> Result<u8>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn read_raw(&mut self, len: usize) -> Result<&'a [u8]>

Source

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

Source

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

Source

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

Source

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

Source

pub fn read_sb8(&mut self) -> Result<i64>

Source

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

Source

pub fn read_bytes_borrowed(&mut self) -> Result<BorrowedBytes<'a>>

Zero-copy companion to read_bytes for the borrowed fetch path. The common short-value form (length byte 1..=253) is a single contiguous run in the buffer, so it is returned as a borrowed slice with no allocation. The chunked long form (0xfe) is not contiguous on the wire (it is a sequence of length-prefixed chunks), so it cannot be borrowed and falls back to an owned Vec — the rare path. 0/0xff signal SQL NULL.

Consumes exactly the same number of bytes as read_bytes for every input, so the two are interchangeable mid-stream.

Source

pub fn skip_bytes_field(&mut self) -> Result<()>

Advance past one length-prefixed TTC byte field (short, NULL, or chunked long form) without allocating — the zero-copy skip used by the borrowed fetch offset-capture pass. Consumes exactly the bytes read_bytes would.

Source

pub fn read_bytes(&mut self) -> Result<Option<Vec<u8>>>

Source

pub fn read_bytes_with_length(&mut self) -> Result<Option<Vec<u8>>>

Source

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

Source

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

Trait Implementations§

Source§

impl BoundedReader for TtcReader<'_>

Source§

fn remaining(&self) -> usize

Bytes still unread in the current message buffer. The ceiling on any count-driven allocation.
Source§

fn alloc_count_checked( &self, count: usize, min_bytes_per_elem: usize, ) -> Result<usize>

Validate a server-declared element count against the buffer: a run of count elements must carry at least count * min_bytes_per_elem bytes, so a count whose minimum byte footprint exceeds [remaining] is a lie. Returns the (unchanged) count when it fits, or a fail-closed ProtocolError::TtcDecode otherwise — never a panic, never an OOM. Read more
Source§

fn with_capacity_bounded<T>( &self, count: usize, min_bytes_per_elem: usize, ) -> Vec<T>

Pre-size a Vec for count elements without trusting count: the reserved capacity is capped at remaining() / min_bytes_per_elem, the largest number of elements the buffer could actually hold. The returned Vec is a normal growable Vec, so a legitimately large payload (where count really fits) is pre-sized to the honest count, and a streamed / chunked field that grows past the initial buffer still appends correctly — the cap only governs the speculative up-front reservation.
Source§

impl<'a> Clone for TtcReader<'a>

Source§

fn clone(&self) -> TtcReader<'a>

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<'a> Debug for TtcReader<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TtcReader<'a>

§

impl<'a> RefUnwindSafe for TtcReader<'a>

§

impl<'a> Send for TtcReader<'a>

§

impl<'a> Sync for TtcReader<'a>

§

impl<'a> Unpin for TtcReader<'a>

§

impl<'a> UnsafeUnpin for TtcReader<'a>

§

impl<'a> UnwindSafe for TtcReader<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V