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 reserve_scoped(
&self,
bytes: u64,
operation: &'static str,
location: Option<SourceLocation>,
) -> Result<ScopedReservation<'_>, CodecError>
pub fn reserve_scoped( &self, bytes: u64, operation: &'static str, location: Option<SourceLocation>, ) -> Result<ScopedReservation<'_>, CodecError>
Reserves bytes held by a temporary materialization.
Sourcepub fn charge_retained(
&self,
bytes: u64,
operation: &'static str,
location: Option<SourceLocation>,
) -> Result<(), CodecError>
pub fn charge_retained( &self, bytes: u64, operation: &'static str, location: Option<SourceLocation>, ) -> Result<(), CodecError>
Charges bytes retained for the remainder of this session.
Sourcepub fn copy_retained(
&self,
bytes: &[u8],
operation: &'static str,
location: Option<SourceLocation>,
) -> Result<Vec<u8>, CodecError>
pub fn copy_retained( &self, bytes: &[u8], operation: &'static str, location: Option<SourceLocation>, ) -> Result<Vec<u8>, CodecError>
Copies bytes into session-retained storage after charging and reserving safely.
Sourcepub fn charge_entities(
&self,
count: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_entities( &self, count: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges admitted entities.
Sourcepub fn charge_collection_items(
&self,
count: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_collection_items( &self, count: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges admitted collection items.
Sourcepub fn enter_nested(
&self,
operation: &'static str,
location: Option<SourceLocation>,
) -> Result<DepthGuard<'_>, CodecError>
pub fn enter_nested( &self, operation: &'static str, location: Option<SourceLocation>, ) -> Result<DepthGuard<'_>, CodecError>
Enters one recursive nesting level until the returned guard is dropped.
Sourcepub fn charge_work(
&self,
units: u64,
operation: &'static str,
) -> Result<(), CodecError>
pub fn charge_work( &self, units: u64, operation: &'static str, ) -> Result<(), CodecError>
Charges session-global algorithm work, fusing on refusal.
Sourcepub fn work_budget(&self, local_limit: u64) -> WorkBudget<'_>
pub fn work_budget(&self, local_limit: u64) -> WorkBudget<'_>
Creates a local work slice that also draws from the session allowance.
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_session(self) -> Result<(), CodecError>
pub fn finish_session(self) -> Result<(), CodecError>
Closes a decode or inspection session, returning a fused resource error even when codec code swallowed the charge that caused it.