Skip to main content

DecoderContext

Struct DecoderContext 

Source
pub struct DecoderContext<'a> { /* private fields */ }
Expand description

Reusable decoding state for repeated documents with one Decoder.

The context retains only allocation capacity, never document semantics. Every operation clears scratch lengths after success or error. Call Self::reset to clear scratch while retaining capacity, or Self::release_scratch to return all retained allocations.

Implementations§

Source§

impl DecoderContext<'_>

Source

pub fn decode_embedded_with_policy( &mut self, input: &[u8], globals: Option<&GlobalSegments>, policy: EmbeddedPolicy, ) -> Result<EmbeddedResult<DecodedDocument>, DecodeError>

Decodes with the explicit policy of Decoder::decode_embedded_with_policy.

§Errors

Returns the same typed errors and always performs normal context cleanup.

Source

pub fn decode(&mut self, input: &[u8]) -> Result<DecodedDocument, DecodeError>

Decodes one standalone document using retained scratch capacity.

§Errors

Returns the same typed errors as Decoder::decode.

Source

pub fn decode_embedded( &mut self, input: &[u8], ) -> Result<DecodedDocument, DecodeError>

Decodes one embedded page stream using retained scratch capacity.

§Errors

Returns the same typed errors as Decoder::decode_embedded.

Source

pub fn decode_embedded_with_globals( &mut self, input: &[u8], globals: &GlobalSegments, ) -> Result<DecodedDocument, DecodeError>

Decodes one embedded page stream with validated globals.

§Errors

Returns the same typed errors as Decoder::decode_embedded_with_globals.

Source§

impl DecoderContext<'_>

Source

pub fn inspect_embedded_with_policy( &mut self, input: &[u8], globals: Option<&GlobalSegments>, policy: EmbeddedPolicy, ) -> Result<EmbeddedResult<DocumentInfo>, DecodeError>

Inspects with the explicit policy of Decoder::inspect_embedded_with_policy.

§Errors

Returns the same typed errors and always performs normal context cleanup.

Source§

impl DecoderContext<'_>

Source

pub const fn limits(&self) -> &Limits

Returns the limits governing this context.

Source

pub fn retained_scratch_bytes(&self) -> u64

Exact bytes currently retained by reusable allocation capacities.

Source

pub fn reset(&mut self)

Clears all per-document scratch contents while retaining capacity.

Source

pub fn release_scratch(&mut self)

Clears per-document state and releases every retained allocation.

Source

pub fn inspect(&mut self, input: &[u8]) -> Result<DocumentInfo, DecodeError>

Parses and validates one standalone document.

§Errors

Returns the same typed errors as Decoder::inspect.

Source

pub fn inspect_embedded( &mut self, input: &[u8], ) -> Result<DocumentInfo, DecodeError>

Parses one embedded page stream.

§Errors

Returns the same typed errors as Decoder::inspect_embedded.

Source

pub fn inspect_embedded_with_globals( &mut self, input: &[u8], globals: &GlobalSegments, ) -> Result<DocumentInfo, DecodeError>

Parses one embedded page stream with validated globals.

§Errors

Returns the same typed errors as Decoder::inspect_embedded_with_globals.

Source

pub fn parse_globals( &mut self, input: &[u8], ) -> Result<GlobalSegments, DecodeError>

Parses and validates immutable embedded global segments.

§Errors

Returns the same typed errors as Decoder::parse_globals.

Trait Implementations§

Source§

impl<'a> Debug for DecoderContext<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Forget for DecoderContext<'a>

§

impl<'a> Freeze for DecoderContext<'a>

§

impl<'a> Move for DecoderContext<'a>

§

impl<'a> RefUnwindSafe for DecoderContext<'a>

§

impl<'a> Send for DecoderContext<'a>

§

impl<'a> Sync for DecoderContext<'a>

§

impl<'a> Unpin for DecoderContext<'a>

§

impl<'a> UnsafeUnpin for DecoderContext<'a>

§

impl<'a> UnwindSafe for DecoderContext<'a>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.