#[non_exhaustive]pub enum BufferPolicy {
Window {
window_bytes: usize,
},
Spool {
max_bytes: usize,
},
}Expand description
How a BufferedReadAt retains bytes from a sequential stream.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Window
Retain only the most recent window_bytes. A read older than the
window fails with SourceError::BeyondWindow. Right for
AccessPattern::Sequential and small
AccessPattern::BoundedBacktrack decoders.
Spool
Retain every byte consumed, up to max_bytes; more fails with
SourceError::BeyondLimit. Right for
AccessPattern::RandomAccess decoders, with the cap sized to the
largest file the driver is willing to hold in memory.
Implementations§
Source§impl BufferPolicy
impl BufferPolicy
Sourcepub const fn for_pattern(pattern: AccessPattern, max_bytes: usize) -> Self
pub const fn for_pattern(pattern: AccessPattern, max_bytes: usize) -> Self
A compatibility heuristic that may clamp the required lookback.
Use Self::try_for_pattern when the access pattern must be satisfied.
Sourcepub const fn try_for_pattern(
pattern: AccessPattern,
max_bytes: usize,
) -> Result<Self, SourceError>
pub const fn try_for_pattern( pattern: AccessPattern, max_bytes: usize, ) -> Result<Self, SourceError>
Choose a policy whose retained history satisfies pattern within the cap.
A required backtrack window larger than the cap is refused, never clamped. A random-access stream can still exceed its spool cap at runtime. This caps retained payload, not total process memory or caller-owned output.
Trait Implementations§
Source§impl Clone for BufferPolicy
impl Clone for BufferPolicy
Source§fn clone(&self) -> BufferPolicy
fn clone(&self) -> BufferPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more