pub struct Sealed<B: Blob> { /* private fields */ }Expand description
An immutable, page-cache-backed read handle for a Blob. The read-only counterpart to
super::Writer.
Implementations§
Source§impl<B: Blob> Sealed<B>
impl<B: Blob> Sealed<B>
Sourcepub async fn read_at(&self, offset: u64, len: usize) -> Result<IoBufs, Error>
pub async fn read_at(&self, offset: u64, len: usize) -> Result<IoBufs, Error>
Read exactly len immutable bytes starting at offset.
Sourcepub fn try_read_sync_into(&self, buf: &mut [u8], offset: u64) -> bool
pub fn try_read_sync_into(&self, buf: &mut [u8], offset: u64) -> bool
Read into buf if it can be done synchronously without I/O. Returns true only if all
buf.len() bytes were satisfied from the page cache and/or the in-memory tail. When false
is returned, the contents of buf are unspecified.
Sourcepub async fn read_into(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
pub async fn read_into(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
Reads bytes starting at offset into buf.
Sourcepub async fn read_up_to(
&self,
offset: u64,
len: usize,
bufs: impl Into<IoBufMut> + Send,
) -> Result<(IoBufMut, usize), Error>
pub async fn read_up_to( &self, offset: u64, len: usize, bufs: impl Into<IoBufMut> + Send, ) -> Result<(IoBufMut, usize), Error>
Reads up to len bytes starting at offset, but only as many as are available.
Returns the buffer (truncated to actual bytes read) and the number of bytes read. Returns an error if no bytes are available at the given offset.
Sourcepub async fn read_many_into(
&self,
buf: &mut [u8],
offsets: &[u64],
item_size: NonZeroUsize,
) -> Result<usize, Error>
pub async fn read_many_into( &self, buf: &mut [u8], offsets: &[u64], item_size: NonZeroUsize, ) -> Result<usize, Error>
Read multiple fixed-size items at sorted byte offsets into a contiguous caller buffer.
buf must be exactly offsets.len() * item_size bytes. All offsets must be sorted,
non-overlapping, and within bounds.
Returns the number of items fully served without a blob read (from the in-memory tail and the page cache). The remaining items required at least one blob read.
Sourcepub async fn read_ranges_into(
&self,
buf: &mut [u8],
ranges: &[(u64, usize)],
) -> Result<usize, Error>
pub async fn read_ranges_into( &self, buf: &mut [u8], ranges: &[(u64, usize)], ) -> Result<usize, Error>
Like Self::read_many_into, but each (offset, len) range has its own length. buf
holds the ranges back to back.
Returns how many ranges were served entirely from the in-memory tail and page cache before any blob read. Empty ranges count as served.
§Panics
Panics if a range starts before the previous range ends, or if buf is not the ranges’
total length.
Sourcepub fn try_read_many_sync_into(
&self,
buf: &mut [u8],
offsets: &[u64],
item_size: NonZeroUsize,
) -> Vec<usize>
pub fn try_read_many_sync_into( &self, buf: &mut [u8], offsets: &[u64], item_size: NonZeroUsize, ) -> Vec<usize>
Like Self::read_many_into, but synchronous and cache-only. Returns the indices of
items that require a blob read. Their slots in buf hold unspecified bytes.
Sourcepub fn try_read_ranges_sync_into(
&self,
buf: &mut [u8],
ranges: &[(u64, usize)],
) -> Vec<usize>
pub fn try_read_ranges_sync_into( &self, buf: &mut [u8], ranges: &[(u64, usize)], ) -> Vec<usize>
Like Self::try_read_many_sync_into, but for variable-length (offset, len) ranges:
buf holds one slot per range, back to back.
Sourcepub fn replay(
&self,
buffer_size: NonZeroUsize,
read_options: ReadOptions,
) -> Result<Replay<B>, Error>
pub fn replay( &self, buffer_size: NonZeroUsize, read_options: ReadOptions, ) -> Result<Replay<B>, Error>
Returns a Replay for sequentially reading all logical bytes of the sealed view.
Sealed values have no write buffer to flush, so unlike super::Writer::replay this method
is not async. Replay validates full pages read from storage and uses the frozen partial
page. Every underlying blob read uses read_options, including refills after seeking.
Pages are read in batches ahead of the decoder. The batch being decoded and the batches in
flight together span buffer_size, each rounded up to whole pages, so they exceed it by
less than one page each. A fill that crosses into the next batch keeps the earlier batch
alive until its last bytes are consumed, and a large fill or a retained byte field keeps
more alive. A seek or a dropped replay abandons the batches read ahead, as
Blob::start_read_many describes.
Trait Implementations§
Auto Trait Implementations§
impl<B> !RefUnwindSafe for Sealed<B>
impl<B> !UnwindSafe for Sealed<B>
impl<B> Freeze for Sealed<B>
impl<B> Send for Sealed<B>
impl<B> Sync for Sealed<B>
impl<B> Unpin for Sealed<B>
impl<B> UnsafeUnpin for Sealed<B>where
Arc<SealedInner<B>>: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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