pub struct ResourceLimits { /* private fields */ }Expand description
PDF 读取与转换过程的资源上限。
§Examples
use easypdf_core::ResourceLimits;
let limits = ResourceLimits::new()
.with_max_input_bytes(100 * 1024 * 1024)
.with_max_decompressed_size(512 * 1024 * 1024);
assert_eq!(limits.max_input_bytes(), 100 * 1024 * 1024);Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub const fn new() -> Self
pub const fn new() -> Self
创建默认资源限制。
默认值适用于一般用途的 PDF 处理。对于不可信输入,
考虑使用 Self::strict;对于受信任的内部文档,
考虑使用 Self::permissive。
Sourcepub const fn permissive() -> Self
pub const fn permissive() -> Self
创建宽松资源限制,适用于受信任的大型文档。
所有限制为默认值的约 4 倍。
Sourcepub const fn with_max_input_bytes(self, value: u64) -> Self
pub const fn with_max_input_bytes(self, value: u64) -> Self
设置最大输入字节数。
Sourcepub const fn with_max_pages(self, value: usize) -> Self
pub const fn with_max_pages(self, value: usize) -> Self
设置最大页数。
Sourcepub const fn with_max_extracted_text_bytes(self, value: usize) -> Self
pub const fn with_max_extracted_text_bytes(self, value: usize) -> Self
设置最大提取文本字节数。
Sourcepub const fn with_max_decompressed_size(self, value: u64) -> Self
pub const fn with_max_decompressed_size(self, value: u64) -> Self
设置解压后最大字节数(防解压炸弹)。
Sourcepub const fn with_max_compression_ratio(self, value: u32) -> Self
pub const fn with_max_compression_ratio(self, value: u32) -> Self
设置最大压缩比(解压后/压缩前)。
Sourcepub const fn with_max_element_count(self, value: usize) -> Self
pub const fn with_max_element_count(self, value: usize) -> Self
设置最大 PDF 对象/元素数量。
Sourcepub const fn max_input_bytes(self) -> u64
pub const fn max_input_bytes(self) -> u64
返回最大输入字节数。
Sourcepub const fn max_extracted_text_bytes(self) -> usize
pub const fn max_extracted_text_bytes(self) -> usize
返回最大提取文本字节数。
Sourcepub const fn max_decompressed_size(self) -> u64
pub const fn max_decompressed_size(self) -> u64
返回解压后最大字节数。
Sourcepub const fn max_compression_ratio(self) -> u32
pub const fn max_compression_ratio(self) -> u32
返回最大压缩比。
Sourcepub const fn max_element_count(self) -> usize
pub const fn max_element_count(self) -> usize
返回最大 PDF 对象/元素数量。
Trait Implementations§
Source§impl Clone for ResourceLimits
impl Clone for ResourceLimits
Source§fn clone(&self) -> ResourceLimits
fn clone(&self) -> ResourceLimits
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ResourceLimits
Source§impl Debug for ResourceLimits
impl Debug for ResourceLimits
Source§impl Default for ResourceLimits
impl Default for ResourceLimits
impl Eq for ResourceLimits
Source§impl PartialEq for ResourceLimits
impl PartialEq for ResourceLimits
impl StructuralPartialEq for ResourceLimits
Auto Trait Implementations§
impl Freeze for ResourceLimits
impl RefUnwindSafe for ResourceLimits
impl Send for ResourceLimits
impl Sync for ResourceLimits
impl Unpin for ResourceLimits
impl UnsafeUnpin for ResourceLimits
impl UnwindSafe for ResourceLimits
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more