Skip to main content

Limits

Struct Limits 

Source
pub struct Limits {
    pub max_sheets: Option<u32>,
    pub max_cells_read: Option<u64>,
    pub max_cells_compared: Option<u64>,
    pub max_diffs_returned: Option<u64>,
    pub max_alignment_product: Option<u64>,
    pub max_input_bytes: Option<u64>,
}
Expand description

Resource bounds that protect against pathological workbooks.

None means no limit on that dimension. Per RFC-035 §5.1, the four linear fields (max_sheets, max_cells_read, max_cells_compared, max_diffs_returned) default to None — their cost scales predictably with input size the caller chose to open, so bounding them by default would surprise working callers for no safety gain they could not have anticipated. max_alignment_product and max_input_bytes default to Some instead: their unbounded cost is superlinear or is incurred before any comparison logic can observe it, which is exactly the failure class RFC-035 exists to close. See Limits::hardened() for a preset that bounds every dimension, for callers who do not trust their input.

Fields§

§max_sheets: Option<u32>§max_cells_read: Option<u64>§max_cells_compared: Option<u64>§max_diffs_returned: Option<u64>§max_alignment_product: Option<u64>

Bounds the m × n row-alignment table. Exceeding it degrades this sheet to positional comparison and emits an AlignmentBoundExceeded diagnostic — it never errors and never aborts (RFC-035 §5.2). Some by default; see DEFAULT_MAX_ALIGNMENT_PRODUCT.

§max_input_bytes: Option<u64>

Bounds the input size, checked before the file is read (or the reader is drained). Exceeding it returns SheetsDiffError::LimitExceeded with LimitKind::InputBytes — this one does error, unlike the alignment bound, because there is no “positional fallback” for an oversized file. Some by default; see DEFAULT_MAX_INPUT_BYTES.

Implementations§

Source§

impl Limits

Source

pub fn hardened() -> Self

A conservative bound on every dimension, for comparing a workbook from a source you do not trust (RFC-035 §5.3).

Limits::default() deliberately does not provide this — its four linear fields stay unbounded so ordinary large-but-legitimate workbooks are never surprised. hardened() trades that off: a caller who opts into it accepts that a very large but legitimate workbook may hit a limit, in exchange for a guarantee that no workbook — hostile or merely huge — can demand unbounded time or memory. Values are chosen to comfortably accommodate an ordinary office workbook while capping the worst case; they are not individually re-measured beyond the alignment bound already justified above; if a specific dimension proves too tight in practice, that is a finding to report, not a default to silently loosen.

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Limits

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 Limits

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Limits

Source§

fn default() -> Self

Returns the “default value” for a type. 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.