Skip to main content

DecodeContext

Struct DecodeContext 

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

Shared monotonic decode state.

Implementations§

Source§

impl<'a> DecodeContext<'a>

Source

pub fn read_root( reader: &mut dyn ReadSeek, arena: &'a DecodeArena, policy: &DecodePolicy, ) -> Result<(Self, View<'a>), CodecError>

Reads the root input under max_input_bytes, copies it into the arena, registers the root space, establishes input-proportional allowances, and returns the context and root view.

Source

pub fn from_root_bytes( bytes: &'a [u8], arena: &'a DecodeArena, policy: &DecodePolicy, ) -> Result<(Self, View<'a>), CodecError>

Builds a context over caller-owned root bytes, for fuzz targets and tests. The arena still backs any expansions produced during decode.

Source

pub fn policy(&self) -> &DecodePolicy

Returns the decode policy in force.

Source

pub fn container_only(&self) -> bool

Returns whether the caller requested container-only decoding.

Source

pub fn set_container_only(&mut self, value: bool)

Records the caller’s container-only request before decoding begins.

Source

pub fn begin_expand( &self, source: View<'_>, spec: ExpandSpec, ) -> Result<ExpandWriter<'_, 'a>, CodecError>

Begins an expansion whose output is charged incrementally and becomes available only after successful finalization.

Source

pub fn concat_views(&self, inputs: &[View<'_>]) -> Result<View<'a>, CodecError>

Copies several input extents into one derived view.

Source

pub fn register_slice<'v>( &self, parent: View<'v>, range: ByteRange, ) -> Result<View<'v>, CodecError>

Registers a stored (uncompressed) child range as a space that borrows the parent bytes without copying.

range is expressed in the parent view’s own space coordinates and must lie within the parent window; a range that escapes the parent is refused here, at the request site, exactly as View::child refuses. No bytes are copied. It is the archive-entry counterpart of DecodeContext::begin_expand — stored ZIP entries take this path, compressed ones take the expander. Registration still refuses on a fused context so a stored entry cannot be admitted after a refusal.

Source

pub fn finish( self, result: Result<DecodeResult, CodecError>, ) -> Result<DecodeResult, CodecError>

Closes a decode, returning a fused resource error even when codec code swallowed the charge that caused it.

Trait Implementations§

Source§

impl<'a> Debug for DecodeContext<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for DecodeContext<'a>

§

impl<'a> !RefUnwindSafe for DecodeContext<'a>

§

impl<'a> !Send for DecodeContext<'a>

§

impl<'a> !Sync for DecodeContext<'a>

§

impl<'a> !UnwindSafe for DecodeContext<'a>

§

impl<'a> Unpin for DecodeContext<'a>

§

impl<'a> UnsafeUnpin for DecodeContext<'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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.