pub struct WindowReader { /* private fields */ }Expand description
An I/O-free decoder retaining only the current window and current entry.
Binding. Done means every entry yielded across the whole run chain (the original run and every resume
through its cursors) is an entry, in order, of the one pack whose bytes hash to the verified pack id: the trailer,
and expected_pack_id when set. A cursor from pack A used on a source that yields different bytes for any
not-yet-verified range fails with PackfileCorrupted, never Done. The reader does not re-read ranges it has
already verified. Keeping the source immutable across resumes is the caller’s job (informative: WP-4.8 binds
R2 range reads to the object’s etag). A source whose already-verified prefix changed after verification can still
reach Done, but only with entries of the verified pack.
Implementations§
Source§impl WindowReader
impl WindowReader
Sourcepub fn new(
pack_len: u64,
window_size: u64,
limits: DecodeLimits,
expected_pack_id: Option<Hash>,
) -> Result<Self, PackError>
pub fn new( pack_len: u64, window_size: u64, limits: DecodeLimits, expected_pack_id: Option<Hash>, ) -> Result<Self, PackError>
Start a pack with power-of-two windows between 64 KiB and 64 MiB.
§Errors
Short pack lengths give PackfileTooShort; invalid geometry gives
PackfileCorrupted.
Sourcepub fn resume(
cursor: &WindowCursor,
limits: DecodeLimits,
) -> Result<Self, PackError>
pub fn resume( cursor: &WindowCursor, limits: DecodeLimits, ) -> Result<Self, PackError>
Restore an entry boundary. The first request contains the next entry.
§Errors
Inconsistent cursors give PackfileCorrupted.
Sourcepub fn step(&mut self) -> Result<Step, PackError>
pub fn step(&mut self) -> Result<Step, PackError>
Advance to a request, an entry, or verified completion.
§Errors
Malformed packs, resource limits, and failed integrity checks use the errors documented at module level. A parsing error makes the reader inert.
Sourcepub fn feed(&mut self, offset: u64, bytes: &[u8]) -> Result<(), PackError>
pub fn feed(&mut self, offset: u64, bytes: &[u8]) -> Result<(), PackError>
Supply exactly the outstanding range. Wrong ranges leave it pending.
§Errors
Wrong ranges give PackfileCorrupted; failed allocations give
PackfileTooLarge.
Sourcepub fn feed_owned(
&mut self,
offset: u64,
bytes: Vec<u8>,
) -> Result<(), PackError>
pub fn feed_owned( &mut self, offset: u64, bytes: Vec<u8>, ) -> Result<(), PackError>
Supply a range by transferring its buffer, avoiding two full-window copies.
§Errors
Wrong ranges give PackfileCorrupted; allocation failure gives PackfileTooLarge.
Sourcepub fn last_frame(&self) -> Option<FrameInfo>
pub fn last_frame(&self) -> Option<FrameInfo>
The frame of the entry the latest Step::Entry returned, or None
before the first one. A resumed reader starts with None.
Sourcepub fn checkpoint(&self) -> Option<WindowCursor>
pub fn checkpoint(&self) -> Option<WindowCursor>
A compact checkpoint only at an entry boundary, never within an entry.
Hashes the current window prefix lazily on this call. Returns None if
the reader has released the bytes needed for that prefix, including while
fetching a split trailer or awaiting a resumed window. Keep the previous
cursor in that case. No bytes are needed when the boundary is exactly at
a window start. Mid-entry states, including carried straddling entries,
never produce a checkpoint.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WindowReader
impl RefUnwindSafe for WindowReader
impl Send for WindowReader
impl Sync for WindowReader
impl Unpin for WindowReader
impl UnsafeUnpin for WindowReader
impl UnwindSafe for WindowReader
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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