#[non_exhaustive]pub struct Limits {Show 18 fields
pub max_input_bytes: u64,
pub max_units: usize,
pub max_unit_chars: usize,
pub max_lines: usize,
pub max_xml_depth: usize,
pub max_xml_elements: usize,
pub max_zip_entries: usize,
pub max_zip_bytes: u64,
pub max_zip_entry_bytes: u64,
pub max_zip_ratio: u64,
pub zip_ratio_floor_bytes: u64,
pub max_paragraphs: usize,
pub xlsx_max_cells: usize,
pub xlsx_max_rows: u32,
pub xlsx_max_cell_chars: usize,
pub xlsx_max_total_text_chars: usize,
pub max_context_bytes: u64,
pub max_output_bytes: u64,
}Expand description
The limits one extraction runs under. Default is Localization OS’s configuration.
Build them with Limits::new and the with_* methods (Limits::new().with_max_units(500)); new limits are
added without breaking callers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_input_bytes: u64Largest input file (MAX_UPLOAD_BYTES).
max_units: usizeMost units (and most segments) in a document (MAX_DOCUMENT_SEGMENTS).
max_unit_chars: usizeMost characters in one unit (MAX_SEGMENT_CHARS).
max_lines: usizeMost lines in a text file: twenty per allowed unit, as LocOS’s line budget.
max_xml_depth: usizeDeepest XML element nesting (libxml2’s own default).
max_xml_elements: usizeMost XML elements in one part.
max_zip_entries: usizeMost entries in a zip (ZIP_MAX_MEMBERS).
max_zip_bytes: u64Most bytes all entries of a zip unpack to (ZIP_MAX_UNCOMPRESSED_BYTES).
max_zip_entry_bytes: u64Most bytes one zip entry may unpack to. LocOS has no cap of its own beyond the total, so the default is the same 256 MB; a caller may set it lower (or raise both for desktop use).
max_zip_ratio: u64Largest unpacked/packed ratio of one entry (ZIP_MAX_RATIO).
zip_ratio_floor_bytes: u64Entries smaller than this are not checked for ratio (ZIP_RATIO_MIN_BYTES).
max_paragraphs: usizeMost paragraphs in a DOCX, empty ones included (DOCX_MAX_PARAGRAPHS).
xlsx_max_cells: usizeMost cells in an XLSX (XLSX_MAX_CELLS).
xlsx_max_rows: u32Highest row number in an XLSX (XLSX_MAX_ROWS).
xlsx_max_cell_chars: usizeMost characters in one XLSX cell or shared string (XLSX_MAX_CELL_CHARS, Excel’s own limit).
xlsx_max_total_text_chars: usizeMost characters of cell text in an XLSX, repeated shared strings counted every time
(XLSX_MAX_TOTAL_TEXT_CHARS).
max_context_bytes: u64Most bytes of context the units of one document may carry together: keys, notes, headings, locations and
the other strings of UnitContext. A string the file holds once and a parser copies into many units counts
once per copy, so one long key or comment over many units cannot multiply the input.
max_output_bytes: u64Most bytes one merge may write (1 GB). Only a merge reads it: an ordinary file never comes near it, so it bounds what a stored Document that was changed by hand can make a merge produce.
Implementations§
Source§impl Limits
impl Limits
Sourcepub fn new() -> Limits
pub fn new() -> Limits
Localization OS’s limits (the same as Limits::default()); change any of them with the with_* methods.
These are the limits for a server that takes uploads from people it does not know (hosted).
Sourcepub fn large() -> Limits
pub fn large() -> Limits
The limits for a person’s own files on their own machine (the CLI, the desktop app, a batch job): large enough for any ordinary document (a 4 GB input, 20 million units or paragraphs, every row Excel allows, 200 million cells), so big manuals, spreadsheets and pages are processed at the cost of memory. The structural guards stay: XML nesting depth, zip entry count, a zip that unpacks to at most 4 GB (2 GB per part, more than a full million-row sheet needs) and a ratio check that still stops a zip bomb (1000:1 instead of 200:1). It is the CLI’s default, so it must stay safe for a downloaded attachment.
Sourcepub fn unbounded() -> Limits
pub fn unbounded() -> Limits
No size or count limits at all: only what the machine’s memory allows. The XML depth limit stays (it protects the stack, and no real document nests 256 elements deep). Use it only for trusted files.
Sourcepub fn profile(name: &str) -> Option<Limits>
pub fn profile(name: &str) -> Option<Limits>
A profile by name, any case: hosted (the default, Limits::new; also default, server), large
(Limits::large; also desktop, local) or unbounded (Limits::unbounded; also none). None
for any other name.
Sourcepub fn clamped(self) -> Limits
pub fn clamped(self) -> Limits
The same limits with every count and size kept to what Limits::unbounded allows, so no budget a
format derives from a limit (200 * max_units, 10 * max_units as i64) can overflow. Extract and merge
apply it to the caller’s limits; it changes nothing under hosted or large.
Sourcepub fn with_max_input_bytes(self, v: u64) -> Limits
pub fn with_max_input_bytes(self, v: u64) -> Limits
Sets max_input_bytes.
Sourcepub fn with_max_units(self, v: usize) -> Limits
pub fn with_max_units(self, v: usize) -> Limits
Sets max_units.
Sourcepub fn with_max_unit_chars(self, v: usize) -> Limits
pub fn with_max_unit_chars(self, v: usize) -> Limits
Sets max_unit_chars.
Sourcepub fn with_max_lines(self, v: usize) -> Limits
pub fn with_max_lines(self, v: usize) -> Limits
Sets max_lines.
Sourcepub fn with_max_xml_depth(self, v: usize) -> Limits
pub fn with_max_xml_depth(self, v: usize) -> Limits
Sets max_xml_depth.
Sourcepub fn with_max_xml_elements(self, v: usize) -> Limits
pub fn with_max_xml_elements(self, v: usize) -> Limits
Sets max_xml_elements.
Sourcepub fn with_max_zip_entries(self, v: usize) -> Limits
pub fn with_max_zip_entries(self, v: usize) -> Limits
Sets max_zip_entries.
Sourcepub fn with_max_zip_bytes(self, v: u64) -> Limits
pub fn with_max_zip_bytes(self, v: u64) -> Limits
Sets max_zip_bytes.
Sourcepub fn with_max_zip_entry_bytes(self, v: u64) -> Limits
pub fn with_max_zip_entry_bytes(self, v: u64) -> Limits
Sets max_zip_entry_bytes.
Sourcepub fn with_max_zip_ratio(self, v: u64) -> Limits
pub fn with_max_zip_ratio(self, v: u64) -> Limits
Sets max_zip_ratio.
Sourcepub fn with_zip_ratio_floor_bytes(self, v: u64) -> Limits
pub fn with_zip_ratio_floor_bytes(self, v: u64) -> Limits
Sets zip_ratio_floor_bytes.
Sourcepub fn with_max_paragraphs(self, v: usize) -> Limits
pub fn with_max_paragraphs(self, v: usize) -> Limits
Sets max_paragraphs.
Sourcepub fn with_xlsx_max_cells(self, v: usize) -> Limits
pub fn with_xlsx_max_cells(self, v: usize) -> Limits
Sets xlsx_max_cells.
Sourcepub fn with_xlsx_max_rows(self, v: u32) -> Limits
pub fn with_xlsx_max_rows(self, v: u32) -> Limits
Sets xlsx_max_rows.
Sourcepub fn with_xlsx_max_cell_chars(self, v: usize) -> Limits
pub fn with_xlsx_max_cell_chars(self, v: usize) -> Limits
Sets xlsx_max_cell_chars.
Sourcepub fn with_xlsx_max_total_text_chars(self, v: usize) -> Limits
pub fn with_xlsx_max_total_text_chars(self, v: usize) -> Limits
Sets xlsx_max_total_text_chars.
Sourcepub fn with_max_context_bytes(self, v: u64) -> Limits
pub fn with_max_context_bytes(self, v: u64) -> Limits
Sets max_context_bytes.
Sourcepub fn with_max_output_bytes(self, v: u64) -> Limits
pub fn with_max_output_bytes(self, v: u64) -> Limits
Sets max_output_bytes.