lol_html

Struct MemorySettings

source
#[repr(C)]
pub struct MemorySettings { pub preallocated_parsing_buffer_size: usize, pub max_allowed_memory_usage: usize, }
Expand description

Specifies the memory settings for HtmlRewriter.

Fields§

§preallocated_parsing_buffer_size: usize

Specifies the number of bytes that should be preallocated on HtmlRewriter instantiation for the internal parsing buffer.

In some cases (e.g. when rewriter encounters a start tag represented by two or more input chunks) the rewriter needs to buffer input content.

Internal parsing buffer is used in such cases. Reallocations and, thus, performance degradation can be avoided by preallocating the buffer ahead of time. As a drawback of this approach, every instance of the rewriter will consume the preallocated amount of memory.

It’s up to the user to adjust the limit according to their environment limitations.

§Default

1024 bytes when constructed with MemorySettings::new().

§max_allowed_memory_usage: usize

Sets a hard limit in bytes on memory consumption of a HtmlRewriter instance.

Rewriter’s write and end methods will error if this limit is exceeded.

Note, that value doesn’t reflect the exact threshold after which the rewriter will bailout. It is impossible to account for all the memory consumed without a significant performance penalty. So, instead, we try to provide the best approximation by measuring the memory consumed by internal buffers that grow depending on the input.

§Default

std::usize::MAX when constructed with MemorySettings::new().

Implementations§

source§

impl MemorySettings

source

pub fn new() -> MemorySettings

Create a new MemorySettings with default values.

Trait Implementations§

source§

impl Default for MemorySettings

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