pub enum Backing {
File(File),
Sub {
file: Arc<File>,
base: u64,
len: u64,
},
Mem(Arc<[u8]>),
}Expand description
A positioned, cursor-free reader over one VHDX container’s bytes.
read_at(buf, offset) fills buf from logical offset within the container
and returns the byte count (short only at end of container) — never touching
a shared cursor, so it is safe to call concurrently through &self.
Variants§
File(File)
A loose container file: positioned reads go straight to the OS handle.
Sub
A contiguous sub-range [base, base+len) of a larger shared file.
Fields
Mem(Arc<[u8]>)
An in-RAM container (e.g. the legacy from_bytes path or an inflated
zip entry).
Implementations§
Source§impl Backing
impl Backing
Sourcepub fn sub(file: Arc<File>, base: u64, len: u64) -> Self
pub fn sub(file: Arc<File>, base: u64, len: u64) -> Self
Construct a Backing::Sub over [base, base+len) of file.
Sourcepub fn from_bytes(bytes: impl Into<Arc<[u8]>>) -> Self
pub fn from_bytes(bytes: impl Into<Arc<[u8]>>) -> Self
Construct an in-RAM Backing::Mem from owned bytes.
Sourcepub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
Fill buf from logical offset within this container, returning the
bytes read (short only at the container’s end). Cursor-free and
thread-safe.
§Errors
Propagates the underlying I/O error for Backing::File /
Backing::Sub; Backing::Mem never fails.
Sourcepub fn read_exact_at(&self, offset: u64, len: usize) -> Result<Vec<u8>>
pub fn read_exact_at(&self, offset: u64, len: usize) -> Result<Vec<u8>>
Read exactly len bytes starting at offset into a fresh Vec.
Used by the open/parse pass to pull a small, known-size structure
(a header slot, the region table, the metadata region, the BAT) into a
bounded buffer. The returned Vec is short only when the container ends
before offset + len (so the caller still range-checks the parse).
§Errors
Propagates the underlying positioned-read error.