pub struct PolicyDecoder<D, R> { /* private fields */ }Expand description
Connect a controlled decoder to every existing slice, file and network driver. Decisions run only at actual suspensions, before native work resumes. The decoder remains terminal after a callback failure or caught unwind.
ContinueReading leaves affected output blocked. This adapter does not
certify native workspace or admit a codec’s internal staging. Its bounded
report contains facts and decisions, not metadata or application payloads.
A workspace requirement refuses before the first native step because this
adapter has no qualified native bound. Construction of the supplied decoder
precedes this check and remains the caller/adapter’s admission responsibility.
Implementations§
Source§impl<D, R> PolicyDecoder<D, R>
impl<D, R> PolicyDecoder<D, R>
Sourcepub fn new(decoder: D, resolver: R) -> Self
pub fn new(decoder: D, resolver: R) -> Self
Use the resolver at mandatory boundaries and the default built-in policy
when it returns UsePreset.
Sourcepub fn with_policy_set(self, preset: PolicySet) -> Self
👎Deprecated: Pass PolicySet or BoundPolicy as the operation policy argument
pub fn with_policy_set(self, preset: PolicySet) -> Self
Pass PolicySet or BoundPolicy as the operation policy argument
Configure the built-in policy used for explicit delegation. During migration, these requirements and the policy argument both apply. A bound policy supplies preferences in place of these.
Sourcepub const fn report(&self) -> &OperationReport
pub const fn report(&self) -> &OperationReport
Decisions made before success or failure. Available after a driver error.
Source§impl<D, R: OperationPolicy> PolicyDecoder<D, R>
impl<D, R: OperationPolicy> PolicyDecoder<D, R>
Sourcepub fn try_new<E>(
factory: impl FnOnce() -> Result<D, E>,
policy: R,
pulse: Option<&dyn Pulse>,
) -> Result<Self, StepError<PolicyDecodeError<E>>>
pub fn try_new<E>( factory: impl FnOnce() -> Result<D, E>, policy: R, pulse: Option<&dyn Pulse>, ) -> Result<Self, StepError<PolicyDecodeError<E>>>
Admit requirements before constructing a native decoder.
Prefer this to Self::new when native construction may allocate. The
factory is invoked exactly once on successful admission and never on
admission refusal. Its original error is retained as
PolicyDecodeError::Native. The same policy is moved into the returned
adapter, where metadata and interpretation decisions still occur later.
This generic adapter has no qualified native workspace bound, so any
configured workspace limit refuses with Workspace(Unknown) before the
factory runs. Other requirements remain pending for their boundaries;
success here does not certify metadata, fidelity or output scheduling.
Configure requirements on policy before this call, not with a later
legacy setter. Values evaluated before the closure is invoked (including
captured allocations) cannot be admitted by this method.
let decoder = PolicyDecoder::try_new(
|| request.start_controlled(&codecs, storage),
policy,
pulse,
)?;Cancellation is checked before and after construction. If cancellation
arrives during a successful factory call, the decoder is dropped before
return. Lengthy factories must poll the same pulse themselves; this check
cannot preempt synchronous work. None skips these per-call checks only.
Sourcepub fn try_from_factory<E>(
factory: impl FnOnce() -> Result<D, E>,
policy: R,
) -> Result<Self, PolicyDecodeError<E>>
👎Deprecated: Use try_new(factory, policy, pulse); pass None when no per-call control is needed
pub fn try_from_factory<E>( factory: impl FnOnce() -> Result<D, E>, policy: R, ) -> Result<Self, PolicyDecodeError<E>>
Use try_new(factory, policy, pulse); pass None when no per-call control is needed
Construct after workspace admission, without per-call cancellation.
Trait Implementations§
Source§impl<D: ControlledIncrementalDecode, R: OperationPolicy> IncrementalDecode for PolicyDecoder<D, R>
impl<D: ControlledIncrementalDecode, R: OperationPolicy> IncrementalDecode for PolicyDecoder<D, R>
Source§type Error = PolicyDecodeError<<D as IncrementalDecode>::Error>
type Error = PolicyDecodeError<<D as IncrementalDecode>::Error>
Source§fn step(
&mut self,
input: Input<'_>,
sink: &mut dyn DecodeRowSink,
pulse: Option<&dyn Pulse>,
) -> Result<Progress, StepError<Self::Error>>
fn step( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<Progress, StepError<Self::Error>>
input and advance by one event. Read moreSource§fn requested(&self) -> &[InputRequest]
fn requested(&self) -> &[InputRequest]
Event::Need
(never empty then). Empty otherwise.