pub struct File { /* private fields */ }Expand description
A mapped file containing extents and an optional transformation (compression or encryption).
Implementations§
Source§impl File
impl File
pub fn new( extents: Extents, uncompressed_size: u64, transform: Transform, ) -> Self
Sourcepub fn extents(&self) -> &Extents
pub fn extents(&self) -> &Extents
Returns the extents mapping logical offsets to device offsets.
Sourcepub fn uncompressed_size(&self) -> u64
pub fn uncompressed_size(&self) -> u64
Returns the uncompressed size of the file in bytes.
Sourcepub fn transform(&self) -> &Transform
pub fn transform(&self) -> &Transform
Returns the transform applied to the file if compressed or encrypted.
Sourcepub fn compression_info(&self) -> Option<&CompressionInfo>
pub fn compression_info(&self) -> Option<&CompressionInfo>
Returns decompression metadata if the file is compressed.
Sourcepub fn read_ahead_size(&self) -> u64
pub fn read_ahead_size(&self) -> u64
Returns the read-ahead window size in bytes for this file.
Sourcepub fn verification_alignment(&self) -> u64
pub fn verification_alignment(&self) -> u64
Returns the Merkle verification alignment in bytes for this file (chunk_size for
compressed files, or DEFAULT_VERIFICATION_ALIGNMENT for uncompressed/encrypted files).
Sourcepub fn read_range(
self: &Arc<Self>,
service: &(impl BlockService + ?Sized),
page_request: impl PageRequest,
)
pub fn read_range( self: &Arc<Self>, service: &(impl BlockService + ?Sized), page_request: impl PageRequest, )
Streams and decodes the uncompressed range requested by page_request, applying readahead.
Sourcepub fn read_range_with_alignment(
self: &Arc<Self>,
window_alignment: u64,
service: &(impl BlockService + ?Sized),
page_request: impl PageRequest,
)
pub fn read_range_with_alignment( self: &Arc<Self>, window_alignment: u64, service: &(impl BlockService + ?Sized), page_request: impl PageRequest, )
Streams and decodes the uncompressed range requested by page_request, aligning the read
window to window_alignment and delivering chunks at self.verification_alignment().
Unlike Self::read_range (which expands the read window to self.read_ahead_size()),
this allows a caller (such as a child file mapping) to bound the read window to a smaller
alignment (e.g. a single verification chunk of the parent file).
Sourcepub fn read_child_range<D: DeliveryHandler>(
self: &Arc<Self>,
child_key: u64,
original_range: Range<u64>,
parent_file: &Arc<File>,
service: &(impl BlockService + ?Sized),
delivery_handler: &Arc<D>,
) -> bool
pub fn read_child_range<D: DeliveryHandler>( self: &Arc<Self>, child_key: u64, original_range: Range<u64>, parent_file: &Arc<File>, service: &(impl BlockService + ?Sized), delivery_handler: &Arc<D>, ) -> bool
Services a page request for a child file (self, identified by child_key) whose extents
map to logical byte offsets in parent_file.
Expands original_range to self.read_ahead_size() and iterates over the overlapping
child extents:
- [
DeviceExtent::Sparse]: notifiesdelivery_handlerviaDeliveryHandler::deliver_child_sparseto zero-fill the child slice. - [
DeviceExtent::Block]: reads the corresponding byte range ofparent_filealigned toparent_file.verification_alignment()so the downstream verifier can verify the parent chunks before supplying the child VMO pages. - [
DeviceExtent::InlineTail]: enqueues a header-only command viaDeliveryHandler::deliver_child_inline_tailso the verifier can copy the tail bytes directly from the verified parent VMO without performing additional block I/O.
Returns true if at least one asynchronous block read was initiated.
Auto Trait Implementations§
impl !RefUnwindSafe for File
impl !UnwindSafe for File
impl Freeze for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin for File
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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