pub struct Decoder { /* private fields */ }Expand description
High-level decoder configuration.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn decode_rgb(
&self,
input: &[u8],
) -> Result<DecodedColourDocument, DecodeError>
pub fn decode_rgb( &self, input: &[u8], ) -> Result<DecodedColourDocument, DecodeError>
Decodes the supported sequential generic-region RGB8 profile strictly.
Existing bi-level entry points retain their colour Unsupported result.
This byte-only profile supports consecutive known-height unstriped pages, immediate
generic regions, RGB8 palettes, monochrome OR/REPLACE and transparent
coloured REPLACE, without deferred retention. Other profiles return typed Unsupported.
§Errors
Returns typed framing, palette, entropy, resource or profile errors.
Sourcepub fn decode_rgb_with_policy(
&self,
input: &[u8],
policy: DecodePolicy,
) -> Result<DecodeResult<DecodedColourDocument>, DecodeError>
pub fn decode_rgb_with_policy( &self, input: &[u8], policy: DecodePolicy, ) -> Result<DecodeResult<DecodedColourDocument>, DecodeError>
Decodes RGB8 with explicit colour declaration-bit recovery.
Compatibility may report missing file/page colour declarations only. It does not inherit the bi-level decoder’s other recovery exceptions. No palette ID is clamped and no colour flag is discarded.
§Errors
Every region and page must complete; errors return no pages or recoveries.
Source§impl Decoder
impl Decoder
Sourcepub fn decode_with_policy(
&self,
input: &[u8],
policy: DecodePolicy,
) -> Result<DecodeResult<DecodedDocument>, DecodeError>
pub fn decode_with_policy( &self, input: &[u8], policy: DecodePolicy, ) -> Result<DecodeResult<DecodedDocument>, DecodeError>
Decodes standalone bytes using an explicit validation policy.
Compatibility permits uniquely owned zero/closed-earlier-page EOP, complete pages missing end-of-page at exact boundaries, observed page counts, one CR LF after a validated EOF, reserved region bit 4, and unretained, unreferenced fixed-length type 1. Random-access files remain strict. Colour, necessary extensions, entropy errors and truncation are never waived. Diagnostics accompany only complete successful output. Preparation, copies and diagnostics consume the existing budgets.
§Errors
Returns ordinary typed errors without retry or partial output.
Sourcepub fn decode_embedded_with_policy(
&self,
input: &[u8],
globals: Option<&GlobalSegments>,
policy: EmbeddedPolicy,
) -> Result<EmbeddedResult<DecodedDocument>, DecodeError>
pub fn decode_embedded_with_policy( &self, input: &[u8], globals: Option<&GlobalSegments>, policy: EmbeddedPolicy, ) -> Result<EmbeddedResult<DecodedDocument>, DecodeError>
Decodes embedded PDF/JBIG2 data with an explicit recovery policy.
See Decoder::inspect_embedded_with_policy for the allowlist and budget
accounting. Inspect recoveries on the returned result to distinguish
normalized metadata from a strict success. No partial image is returned.
§Errors
Returns the normal typed errors; there is no implicit retry or fallback.
Sourcepub fn decode(&self, input: &[u8]) -> Result<DecodedDocument, DecodeError>
pub fn decode(&self, input: &[u8]) -> Result<DecodedDocument, DecodeError>
Decodes a standalone document into owned pages.
§Errors
Returns a typed malformed, unsupported, resource, allocation, I/O, or sink error.
Sourcepub fn decode_reader<R: Read>(
&self,
reader: &mut R,
) -> Result<DecodedDocument, DecodeError>
pub fn decode_reader<R: Read>( &self, reader: &mut R, ) -> Result<DecodedDocument, DecodeError>
Reads a bounded standalone document and decodes it into owned pages.
§Errors
Returns a typed malformed, unsupported, resource, allocation, or I/O error.
Sourcepub fn decode_embedded(
&self,
input: &[u8],
) -> Result<DecodedDocument, DecodeError>
pub fn decode_embedded( &self, input: &[u8], ) -> Result<DecodedDocument, DecodeError>
Decodes a contiguous embedded page stream without external globals.
For PDF integration, including PDFium, a complete input may omit the final end-of-page segment. An initially unknown page height must still be established by a completed final stripe. This does not permit truncated segment or compressed bitmap data, or substitute PDF image dimensions.
§Errors
Returns a typed error for malformed, unresolved, unsupported, or over-limit input.
Sourcepub fn decode_embedded_with_globals(
&self,
input: &[u8],
globals: &GlobalSegments,
) -> Result<DecodedDocument, DecodeError>
pub fn decode_embedded_with_globals( &self, input: &[u8], globals: &GlobalSegments, ) -> Result<DecodedDocument, DecodeError>
Decodes a contiguous embedded page stream with validated globals.
Final-page completion follows Decoder::decode_embedded.
§Errors
Returns a typed error for malformed, unresolved, unsupported, or over-limit input.
Sourcepub fn decode_with_sink<S: PageSink>(
&self,
input: &[u8],
sink: &mut S,
) -> Result<DocumentInfo, DecodeError>
pub fn decode_with_sink<S: PageSink>( &self, input: &[u8], sink: &mut S, ) -> Result<DocumentInfo, DecodeError>
Decodes a standalone document and emits each completed page.
§Errors
Returns a typed malformed, unsupported, resource, allocation, I/O, or sink error.
Sourcepub fn decode_reader_with_sink<R: Read, S: PageSink>(
&self,
reader: &mut R,
sink: &mut S,
) -> Result<DocumentInfo, DecodeError>
pub fn decode_reader_with_sink<R: Read, S: PageSink>( &self, reader: &mut R, sink: &mut S, ) -> Result<DocumentInfo, DecodeError>
Reads a bounded standalone document and emits each completed page.
§Errors
Returns a typed malformed, unsupported, resource, allocation, I/O, or sink error.
Source§impl Decoder
impl Decoder
Sourcepub fn inspect_embedded_with_policy(
&self,
input: &[u8],
globals: Option<&GlobalSegments>,
policy: EmbeddedPolicy,
) -> Result<EmbeddedResult<DocumentInfo>, DecodeError>
pub fn inspect_embedded_with_policy( &self, input: &[u8], globals: Option<&GlobalSegments>, policy: EmbeddedPolicy, ) -> Result<EmbeddedResult<DocumentInfo>, DecodeError>
Inspects an embedded stream with an explicit, observable recovery policy.
Best effort overrides inconsistent page auxiliary/refinement flags (T.88 7.4.8.5) and normalizes an existing FF D0 marker at the exact end of a known-length arithmetic generic region to FF AC (E.2.9, E.3.3). It never adds compressed data or repairs framing or dimensions. Preparation debits work and temporary storage from the existing budgets; any later resource error reports the remaining effective budget.
§Errors
Returns typed validation, resource or allocation errors. There is no retry.
Sourcepub fn parse_globals_with_policy(
&self,
input: &[u8],
policy: EmbeddedPolicy,
) -> Result<EmbeddedResult<GlobalSegments>, DecodeError>
pub fn parse_globals_with_policy( &self, input: &[u8], policy: EmbeddedPolicy, ) -> Result<EmbeddedResult<GlobalSegments>, DecodeError>
Parses and validates an immutable embedded global-segment stream with an explicit recovery policy.
Under EmbeddedPolicy::BestEffort, missing advisory retention flags
on referenced global segments are normalized before running the strict
Decoder::parse_globals validator.
§Errors
Returns the same typed errors as Decoder::parse_globals.
Source§impl Decoder
impl Decoder
Sourcepub fn inspect(&self, input: &[u8]) -> Result<DocumentInfo, DecodeError>
pub fn inspect(&self, input: &[u8]) -> Result<DocumentInfo, DecodeError>
Parses and validates a standalone sequential or random-access stream.
This method validates the document envelope and page lifecycle without decoding compressed region payloads. On success, organization and the optional declared count match the standalone header; a known count equals the returned page count.
§Errors
Returns a typed error for malformed, unsupported, over-limit, or allocation-failing input.
Sourcepub fn inspect_reader<R: Read>(
&self,
reader: &mut R,
) -> Result<DocumentInfo, DecodeError>
pub fn inspect_reader<R: Read>( &self, reader: &mut R, ) -> Result<DocumentInfo, DecodeError>
Reads a bounded standalone stream and validates its document envelope.
§Errors
Returns a typed I/O, malformed, unsupported, resource-limit, or allocation error.
Sourcepub fn inspect_embedded(
&self,
input: &[u8],
) -> Result<DocumentInfo, DecodeError>
pub fn inspect_embedded( &self, input: &[u8], ) -> Result<DocumentInfo, DecodeError>
Parses a contiguous embedded segment stream such as PDF page data.
For PDF integration, including PDFium, the end of the complete input may terminate the final page without an end-of-page segment. An initially unknown height still requires a final completed stripe. Segment headers and payloads must not be truncated. Standalone validation remains strict.
§Errors
Returns a typed error for malformed, unsupported, over-limit, or allocation-failing input.
Sourcepub fn inspect_embedded_with_globals(
&self,
input: &[u8],
globals: &GlobalSegments,
) -> Result<DocumentInfo, DecodeError>
pub fn inspect_embedded_with_globals( &self, input: &[u8], globals: &GlobalSegments, ) -> Result<DocumentInfo, DecodeError>
Parses an embedded page stream with reusable validated global segments.
Final-page completion follows Decoder::inspect_embedded.
§Errors
Returns a typed error for malformed, unsupported, over-limit, allocation-failing, or unresolved input.
Sourcepub fn parse_globals(&self, input: &[u8]) -> Result<GlobalSegments, DecodeError>
pub fn parse_globals(&self, input: &[u8]) -> Result<GlobalSegments, DecodeError>
Parses and validates an immutable embedded global-segment stream.
§Errors
Returns a typed error if a global segment is malformed, associated with a page, unresolved, unsupported, over-limit, or cannot be allocated.