pub struct DecodeContext<'a> { /* private fields */ }Expand description
Shared monotonic decode state.
Implementations§
Source§impl<'a> DecodeContext<'a>
impl<'a> DecodeContext<'a>
Sourcepub fn read_root(
reader: &mut dyn ReadSeek,
arena: &'a DecodeArena,
policy: &DecodePolicy,
) -> Result<(Self, View<'a>), CodecError>
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.
Sourcepub fn from_root_bytes(
bytes: &'a [u8],
arena: &'a DecodeArena,
policy: &DecodePolicy,
) -> Result<(Self, View<'a>), CodecError>
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.
Sourcepub fn policy(&self) -> &DecodePolicy
pub fn policy(&self) -> &DecodePolicy
Returns the decode policy in force.
Sourcepub fn container_only(&self) -> bool
pub fn container_only(&self) -> bool
Returns whether the caller requested container-only decoding.
Sourcepub fn set_container_only(&mut self, value: bool)
pub fn set_container_only(&mut self, value: bool)
Records the caller’s container-only request before decoding begins.
Sourcepub fn begin_expand(
&self,
source: View<'_>,
spec: ExpandSpec,
) -> Result<ExpandWriter<'_, 'a>, CodecError>
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.
Sourcepub fn concat_views(&self, inputs: &[View<'_>]) -> Result<View<'a>, CodecError>
pub fn concat_views(&self, inputs: &[View<'_>]) -> Result<View<'a>, CodecError>
Copies several input extents into one derived view.
Sourcepub fn register_slice<'v>(
&self,
parent: View<'v>,
range: ByteRange,
) -> Result<View<'v>, CodecError>
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.
Sourcepub fn finish(
self,
result: Result<DecodeResult, CodecError>,
) -> Result<DecodeResult, CodecError>
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.