Skip to main content

PolicyDecoder

Struct PolicyDecoder 

Source
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>

Source

pub fn new(decoder: D, resolver: R) -> Self

Use the resolver at mandatory boundaries and the default built-in policy when it returns UsePreset.

Source

pub fn with_policy_set(self, preset: PolicySet) -> Self

👎Deprecated:

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.

Source

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>

Source

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.

Source

pub 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

Construct after workspace admission, without per-call cancellation.

Trait Implementations§

Source§

impl<D: ControlledIncrementalDecode, R: OperationPolicy> IncrementalDecode for PolicyDecoder<D, R>

Source§

type Error = PolicyDecodeError<<D as IncrementalDecode>::Error>

The codec-specific error type.
Source§

fn step( &mut self, input: Input<'_>, sink: &mut dyn DecodeRowSink, pulse: Option<&dyn Pulse>, ) -> Result<Progress, StepError<Self::Error>>

Take bytes from the front of input and advance by one event. Read more
Source§

fn requested(&self) -> &[InputRequest]

What the decoder needs, valid after a step returned Event::Need (never empty then). Empty otherwise.
Source§

fn info(&self) -> Option<&ImageInfo>

Image metadata, once the header has been parsed.
Source§

fn take_details(&mut self) -> Option<DecodeDetails>

Take the owned details of a successfully completed decode, at most once. Read more
Source§

fn output_descriptor(&self) -> Option<PixelDescriptor>

Output pixel descriptor, once the header has been parsed.
Source§

fn access_pattern(&self) -> AccessPattern

How this decoder reads its input, so a driver can choose a buffering strategy. May change once the format is known.

Auto Trait Implementations§

§

impl<D, R> Freeze for PolicyDecoder<D, R>
where R: Freeze, D: Freeze,

§

impl<D, R> RefUnwindSafe for PolicyDecoder<D, R>

§

impl<D, R> Send for PolicyDecoder<D, R>
where R: Send, D: Send,

§

impl<D, R> Sync for PolicyDecoder<D, R>
where R: Sync, D: Sync,

§

impl<D, R> Unpin for PolicyDecoder<D, R>
where R: Unpin, D: Unpin,

§

impl<D, R> UnsafeUnpin for PolicyDecoder<D, R>
where R: UnsafeUnpin, D: UnsafeUnpin,

§

impl<D, R> UnwindSafe for PolicyDecoder<D, R>
where R: UnwindSafe, D: UnwindSafe,

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