pub struct VhdxReader { /* private fields */ }Expand description
Read-only VHDX container reader.
Implements Read + Seek over the virtual sector stream.
§Bounded memory
The reader holds the BAT (a small Vec<u64>), the parsed metadata, and a
log overlay (empty for a clean image, ~log-sized for a dirty one) — never the
whole container. Block bytes are fetched on demand from a positioned
Backing, so peak RSS does not scale with image size. VhdxReader::open
takes the bounded Backing::File path; VhdxReader::from_bytes keeps the
legacy in-RAM path (backed by Backing::Mem).
Implementations§
Source§impl VhdxReader
impl VhdxReader
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a VHDX container from a path with bounded memory.
Reads only the small fixed structures (headers, region table, metadata, BAT, and — for a dirty image — the log region) at construction; the payload blocks are read on demand. A 2 TB image no longer means a 2 TB heap.
Sourcepub fn from_backing(
backing: Backing,
parent: Option<Box<VhdxReader>>,
) -> Result<Self>
pub fn from_backing( backing: Backing, parent: Option<Box<VhdxReader>>, ) -> Result<Self>
Construct a reader over an arbitrary positioned Backing.
The escape hatch behind open (and the issen zip bridge):
a Backing::Sub reads a STORED zip entry in place, a Backing::Mem
reads inflated/owned bytes. Parsing and reads are identical across all
three backings.
Sourcepub fn from_bytes(data: Vec<u8>) -> Result<Self>
pub fn from_bytes(data: Vec<u8>) -> Result<Self>
Open a VHDX container from owned bytes (legacy in-RAM path).
The whole buffer is held in RAM (via Backing::Mem) and the dirty log,
if any, is replayed in place before parsing — byte-identical to the
historical behaviour. Prefer open for files on disk.
Sourcepub fn from_bytes_with_parent(data: Vec<u8>, parent: VhdxReader) -> Result<Self>
pub fn from_bytes_with_parent(data: Vec<u8>, parent: VhdxReader) -> Result<Self>
Open a differencing (child) disk with its parent chain (in-RAM path).
Reads absent blocks from parent instead of returning zeros.
Sourcepub fn from_backing_with_parent(
backing: Backing,
parent: VhdxReader,
) -> Result<Self>
pub fn from_backing_with_parent( backing: Backing, parent: VhdxReader, ) -> Result<Self>
Open a differencing (child) disk over an arbitrary backing with its parent chain.
pub fn virtual_disk_size(&self) -> u64
pub fn logical_sector_size(&self) -> u32
Trait Implementations§
Source§impl Debug for VhdxReader
impl Debug for VhdxReader
Source§impl Read for VhdxReader
impl Read for VhdxReader
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
fn take(self, limit: u64) -> Take<Self>where
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)Source§impl Seek for VhdxReader
impl Seek for VhdxReader
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)