pub struct SizeGuards {
pub max_cell_bytes: usize,
pub max_row_bytes: usize,
pub max_total_buffered_bytes: usize,
}Expand description
Per-connection size ceilings applied to every read.
All three caps are byte counts; 0 disables that dimension. The
defaults are generous enough that ordinary OLTP rows never trip them
yet still cap a runaway result well short of an OOM:
max_cell_bytes(default 64 MiB) — a single value’s payload.max_row_bytes(default 256 MiB) — one row’s summed cell payloads.max_total_buffered_bytes(default 1 GiB) — the running total an eagerqueryis allowed to materialize before failing withSqlError::BufferTooLarge. The streaming cursor does not apply this total (it never buffers the whole result); it applies only the per-cell and per-row caps.
Construct with SizeGuards::unlimited to opt out entirely, or
tweak individual fields. The guards are copied into each connection
at connect time and consulted on every row.
Fields§
§max_cell_bytes: usizeMax payload bytes for a single cell; 0 = unlimited.
max_row_bytes: usizeMax summed payload bytes for one row; 0 = unlimited.
max_total_buffered_bytes: usizeMax running total an eager query may buffer; 0 = unlimited.
Ignored by the streaming cursor, which is bounded by design.
Implementations§
Source§impl SizeGuards
impl SizeGuards
Sourcepub fn unlimited() -> Self
pub fn unlimited() -> Self
Disable every guard. Use only when the caller has its own bound on result size and wants ferrule-sql to impose none.
Sourcepub fn check_row(
&self,
row_ordinal: u64,
row: &[Value],
columns: &[ColumnInfo],
) -> Result<(), SqlError>
pub fn check_row( &self, row_ordinal: u64, row: &[Value], columns: &[ColumnInfo], ) -> Result<(), SqlError>
Check one fully-decoded row against the per-cell and per-row
caps. Returns a structured SqlError naming the offending
row/column the instant a cap is crossed, so the caller never
retains an over-budget row.
row_ordinal is the 0-based position of this row within the
current result (used only for diagnostics). columns supplies
the column names for the SqlError::CellTooLarge message; when
shorter than the row (or empty) the column index is rendered
instead. This performs no allocation proportional to row size —
it sums precomputed Value::byte_size values.
Sourcepub fn caps_total(&self) -> bool
pub fn caps_total(&self) -> bool
True when this configuration buffers an eager result under a
finite total cap. The eager query path uses this to decide
whether to maintain the running byte tally at all.
Trait Implementations§
Source§impl Clone for SizeGuards
impl Clone for SizeGuards
Source§fn clone(&self) -> SizeGuards
fn clone(&self) -> SizeGuards
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SizeGuards
Source§impl Debug for SizeGuards
impl Debug for SizeGuards
Source§impl Default for SizeGuards
impl Default for SizeGuards
impl Eq for SizeGuards
Source§impl PartialEq for SizeGuards
impl PartialEq for SizeGuards
Source§fn eq(&self, other: &SizeGuards) -> bool
fn eq(&self, other: &SizeGuards) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SizeGuards
Auto Trait Implementations§
impl Freeze for SizeGuards
impl RefUnwindSafe for SizeGuards
impl Send for SizeGuards
impl Sync for SizeGuards
impl Unpin for SizeGuards
impl UnsafeUnpin for SizeGuards
impl UnwindSafe for SizeGuards
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.