pub struct Decoder { /* private fields */ }Expand description
High-level decoder configuration.
Implementations§
Source§impl Decoder
impl Decoder
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.
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.