pub struct DecodeContext<'p> {
pub limits: Limits,
pub parallel: bool,
pub simd: bool,
pub profiler: &'p Profiler,
pub recover: bool,
/* private fields */
}Expand description
Context passed to decoders.
Fields§
§limits: LimitsSafety limits for allocations and dimensions.
parallel: boolAllow multithreaded decoding.
simd: boolAllow explicit SIMD kernels (scalar reference paths otherwise).
profiler: &'p ProfilerReceives per-stage timings.
recover: boolRecover from truncated sensor data (zero-fill and warn) instead of failing.
Default: true (the high-level API’s default policy). See crate::integrity.
Implementations§
Source§impl<'p> DecodeContext<'p>
impl<'p> DecodeContext<'p>
Source§impl DecodeContext<'_>
impl DecodeContext<'_>
Sourcepub fn sensor_bytes<'a>(
&self,
data: &'a [u8],
unit: DataUnit,
offset: usize,
needed: usize,
) -> Result<SensorBytes<'a>>
pub fn sensor_bytes<'a>( &self, data: &'a [u8], unit: DataUnit, offset: usize, needed: usize, ) -> Result<SensorBytes<'a>>
The bytes [offset, offset + needed) of sensor-data unit in data (the whole
input). Under the strict policy a range not entirely in the file is an
Error::CorruptFile carrying a Truncation; under the recover policy the
available prefix (possibly empty) is returned with the truncation, which the caller
reports through DecodeContext::recovered after zero-filling what is missing.
Sourcepub fn sensor_rows<'a>(
&self,
data: &'a [u8],
unit: DataUnit,
offset: usize,
geometry: RowGeometry,
) -> Result<&'a [u8]>
pub fn sensor_rows<'a>( &self, data: &'a [u8], unit: DataUnit, offset: usize, geometry: RowGeometry, ) -> Result<&'a [u8]>
Like DecodeContext::sensor_bytes for a row-structured unit: needed comes
from geometry, and a recovered truncation is reported immediately with the
samples the available bytes do not cover (callers must leave those zero).
Sourcepub fn truncated(&self, t: Truncation, samples_filled: u64) -> Result<()>
pub fn truncated(&self, t: Truncation, samples_filled: u64) -> Result<()>
Fail with t (strict), or record it as recovered with samples_filled zero
samples (recover). For checks made outside DecodeContext::sensor_bytes.
Sourcepub fn recovered(&self, reason: CorruptReason, samples_filled: u64)
pub fn recovered(&self, reason: CorruptReason, samples_filled: u64)
Record a problem the decode repaired (recover policy).
Sourcepub fn take_warnings(&self) -> Vec<DecodeWarning>
pub fn take_warnings(&self) -> Vec<DecodeWarning>
Warnings recorded so far, sorted by unit (decoding may run units in parallel).
Auto Trait Implementations§
impl<'p> !Freeze for DecodeContext<'p>
impl<'p> RefUnwindSafe for DecodeContext<'p>
impl<'p> Send for DecodeContext<'p>
impl<'p> Sync for DecodeContext<'p>
impl<'p> Unpin for DecodeContext<'p>
impl<'p> UnsafeUnpin for DecodeContext<'p>
impl<'p> UnwindSafe for DecodeContext<'p>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more