Skip to main content

Limits

Struct Limits 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_input_bytes: u64

Largest input file (MAX_UPLOAD_BYTES).

§max_units: usize

Most units (and most segments) in a document (MAX_DOCUMENT_SEGMENTS).

§max_unit_chars: usize

Most characters in one unit (MAX_SEGMENT_CHARS).

§max_lines: usize

Most lines in a text file: twenty per allowed unit, as LocOS’s line budget.

§max_xml_depth: usize

Deepest XML element nesting (libxml2’s own default).

§max_xml_elements: usize

Most XML elements in one part.

§max_zip_entries: usize

Most entries in a zip (ZIP_MAX_MEMBERS).

§max_zip_bytes: u64

Most bytes all entries of a zip unpack to (ZIP_MAX_UNCOMPRESSED_BYTES).

§max_zip_entry_bytes: u64

Most 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: u64

Largest unpacked/packed ratio of one entry (ZIP_MAX_RATIO).

§zip_ratio_floor_bytes: u64

Entries smaller than this are not checked for ratio (ZIP_RATIO_MIN_BYTES).

§max_paragraphs: usize

Most paragraphs in a DOCX, empty ones included (DOCX_MAX_PARAGRAPHS).

§xlsx_max_cells: usize

Most cells in an XLSX (XLSX_MAX_CELLS).

§xlsx_max_rows: u32

Highest row number in an XLSX (XLSX_MAX_ROWS).

§xlsx_max_cell_chars: usize

Most characters in one XLSX cell or shared string (XLSX_MAX_CELL_CHARS, Excel’s own limit).

§xlsx_max_total_text_chars: usize

Most characters of cell text in an XLSX, repeated shared strings counted every time (XLSX_MAX_TOTAL_TEXT_CHARS).

§max_context_bytes: u64

Most 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: u64

Most 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

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_max_input_bytes(self, v: u64) -> Limits

Sets max_input_bytes.

Source

pub fn with_max_units(self, v: usize) -> Limits

Sets max_units.

Source

pub fn with_max_unit_chars(self, v: usize) -> Limits

Sets max_unit_chars.

Source

pub fn with_max_lines(self, v: usize) -> Limits

Sets max_lines.

Source

pub fn with_max_xml_depth(self, v: usize) -> Limits

Sets max_xml_depth.

Source

pub fn with_max_xml_elements(self, v: usize) -> Limits

Sets max_xml_elements.

Source

pub fn with_max_zip_entries(self, v: usize) -> Limits

Sets max_zip_entries.

Source

pub fn with_max_zip_bytes(self, v: u64) -> Limits

Sets max_zip_bytes.

Source

pub fn with_max_zip_entry_bytes(self, v: u64) -> Limits

Sets max_zip_entry_bytes.

Source

pub fn with_max_zip_ratio(self, v: u64) -> Limits

Sets max_zip_ratio.

Source

pub fn with_zip_ratio_floor_bytes(self, v: u64) -> Limits

Sets zip_ratio_floor_bytes.

Source

pub fn with_max_paragraphs(self, v: usize) -> Limits

Sets max_paragraphs.

Source

pub fn with_xlsx_max_cells(self, v: usize) -> Limits

Sets xlsx_max_cells.

Source

pub fn with_xlsx_max_rows(self, v: u32) -> Limits

Sets xlsx_max_rows.

Source

pub fn with_xlsx_max_cell_chars(self, v: usize) -> Limits

Sets xlsx_max_cell_chars.

Source

pub fn with_xlsx_max_total_text_chars(self, v: usize) -> Limits

Sets xlsx_max_total_text_chars.

Source

pub fn with_max_context_bytes(self, v: u64) -> Limits

Sets max_context_bytes.

Source

pub fn with_max_output_bytes(self, v: u64) -> Limits

Sets max_output_bytes.

Trait Implementations§

Source§

impl Clone for Limits

Source§

fn clone(&self) -> Self

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 Copy for Limits

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
Source§

impl<'de> Deserialize<'de> for Limits
where Limits: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Limits

Source§

impl PartialEq for Limits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Limits

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Limits

Auto Trait Implementations§

§

impl Forget for Limits

§

impl Freeze for Limits

§

impl Move for Limits

§

impl RefUnwindSafe for Limits

§

impl Send for Limits

§

impl Sync for Limits

§

impl Unpin for Limits

§

impl UnsafeUnpin for Limits

§

impl UnwindSafe for Limits

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.