pub struct MattenLimits {
pub max_dimensions: usize,
pub max_elements: usize,
pub max_parse_bytes: usize,
}Expand description
Resource safety limits for shape calculations and allocations (RFC-018).
MattenLimits is the single source of truth for all allocation budgets in
matten. The default values are generous for typical PoC workloads but
prevent pathological resource exhaustion from malformed or adversarial
inputs.
§Examples
use matten::MattenLimits;
let limits = MattenLimits::default();
assert_eq!(limits.max_dimensions, 8);Boundary-safe constructors (try_zeros, try_ones, try_full) use the
default limits automatically. Pass a custom MattenLimits to
Tensor::try_zeros_with_limits etc. if you need a different budget.
Fields§
§max_dimensions: usizeMaximum number of axes (rank). Default: 8.
max_elements: usizeMaximum number of elements any fill constructor or broadcast output may allocate. Default: 1 048 576 (~1 M, ~8 MiB for f64).
Note: a 2048×2048 matrix has ~4 M elements and exceeds this default.
This is an intentionally conservative safety-first default for PoC use.
Use try_zeros_with_limits with a custom MattenLimits for larger tensors,
or use the panicking zeros/ones/full only when you know the shape is safe.
max_parse_bytes: usizeMaximum number of bytes a JSON or CSV parser may accept. Default: 128 MiB.
Note: this field is a future extension point. The current
parsers (from_json, from_csv, etc.) do not yet enforce this
limit at runtime. See RFC-018 implementation notes.
Implementations§
Source§impl MattenLimits
impl MattenLimits
Trait Implementations§
Source§impl Clone for MattenLimits
impl Clone for MattenLimits
Source§fn clone(&self) -> MattenLimits
fn clone(&self) -> MattenLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more