pub struct DbObjectPackedReader<'a> { /* private fields */ }Implementations§
Source§impl<'a> DbObjectPackedReader<'a>
impl<'a> DbObjectPackedReader<'a>
pub fn new(bytes: &'a [u8]) -> Self
pub fn with_limits(bytes: &'a [u8], limits: ProtocolLimits) -> Result<Self>
pub fn limits(&self) -> ProtocolLimits
pub fn read_u8(&mut self) -> Result<u8>
pub fn read_i32be(&mut self) -> Result<i32>
pub fn read_length(&mut self) -> Result<usize>
pub fn read_value_bytes(&mut self) -> Result<Option<Vec<u8>>>
pub fn read_header(&mut self) -> Result<()>
Sourcepub fn remaining(&self) -> usize
pub fn remaining(&self) -> usize
Bytes still unread in the packed image. Exposed so a caller materializing
a collection (whose element count is a server-declared read_length) can
bound its Vec pre-allocation against the buffer via the
BoundedReader trait — closing the
OOM-from-length class for DbObject collections too.
pub fn read_atomic_null(&mut self, is_collection_context: bool) -> Result<bool>
Trait Implementations§
Source§impl BoundedReader for DbObjectPackedReader<'_>
impl BoundedReader for DbObjectPackedReader<'_>
Source§fn remaining(&self) -> usize
fn remaining(&self) -> usize
Bytes still unread in the current message buffer. The ceiling on any
count-driven allocation.
Source§fn protocol_limits(&self) -> ProtocolLimits
fn protocol_limits(&self) -> ProtocolLimits
Resource policy attached to this decoder. Readers that have not yet
grown a configurable policy surface use the validated defaults.
Source§fn alloc_count_checked(
&self,
count: usize,
min_bytes_per_elem: usize,
) -> Result<usize>
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 moreSource§fn with_capacity_bounded<T>(
&self,
count: usize,
min_bytes_per_elem: usize,
) -> Vec<T>
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§fn with_capacity_limited<T, F>(
&self,
count: usize,
min_bytes_per_elem: usize,
check: F,
) -> Result<Vec<T>>
fn with_capacity_limited<T, F>( &self, count: usize, min_bytes_per_elem: usize, check: F, ) -> Result<Vec<T>>
Policy-aware form of
with_capacity_bounded:
the caller supplies the resource family check, then the speculative
allocation is still capped by the remaining buffer.Auto Trait Implementations§
impl<'a> Freeze for DbObjectPackedReader<'a>
impl<'a> RefUnwindSafe for DbObjectPackedReader<'a>
impl<'a> Send for DbObjectPackedReader<'a>
impl<'a> Sync for DbObjectPackedReader<'a>
impl<'a> Unpin for DbObjectPackedReader<'a>
impl<'a> UnsafeUnpin for DbObjectPackedReader<'a>
impl<'a> UnwindSafe for DbObjectPackedReader<'a>
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