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
impl Limits
Sourcepub fn hardened() -> Self
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.