pub struct DecodeBudget { /* private fields */ }Expand description
How much a stream is allowed to decompress to.
The ceiling starts at MAX_DECODED_STREAM_BYTES and is raised — never
lowered — by whatever the stream dictionary declares about its own
uncompressed size. Raising rather than replacing is what keeps this from
rejecting files stet renders correctly today: a stream that declares
nothing, or declares something small, still gets the full general
allowance.
Implementations§
Source§impl DecodeBudget
impl DecodeBudget
Sourcepub fn for_stream(dict: &PdfDict) -> Self
pub fn for_stream(dict: &PdfDict) -> Self
Derive a budget from a stream dictionary.
Two dictionary shapes declare an uncompressed size, and a file that legitimately carries a stream larger than the general allowance will be one of them:
- An image XObject declares
/Width,/Height,/BitsPerComponentand/ColorSpace, which give the raster size exactly. A 60x40 inch grand-format image at 1200 dpi is 3.46 Gpx, and as 8-bit CMYK that is a legitimate 13.8 GB stream. Refusing it would be precisely the prepress regression an earlier corpus-derived image cap already caused once. - An embedded file declares
/Params << /Size n >>(PDF 32000-1 7.11.4.2), the attachment’s uncompressed length. Attachments are only decoded when a caller explicitly asks for one by name.
Both declared values are themselves bounded — image dimensions by
stet_graphics::image_limits, attachment size by the file’s own
claim — so a lie is a bounded lie, which is the property the general
ceiling exists to guarantee.
Trait Implementations§
Source§impl Clone for DecodeBudget
impl Clone for DecodeBudget
Source§fn clone(&self) -> DecodeBudget
fn clone(&self) -> DecodeBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DecodeBudget
Source§impl Debug for DecodeBudget
impl Debug for DecodeBudget
Auto Trait Implementations§
impl Freeze for DecodeBudget
impl RefUnwindSafe for DecodeBudget
impl Send for DecodeBudget
impl Sync for DecodeBudget
impl Unpin for DecodeBudget
impl UnsafeUnpin for DecodeBudget
impl UnwindSafe for DecodeBudget
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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