Skip to main content

Backing

Enum Backing 

Source
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

§file: Arc<File>

The backing file (shared; positioned reads carry their own offset).

§base: u64

Absolute file offset where this container’s bytes begin.

§len: u64

Length of this container in bytes.

§

Mem(Arc<[u8]>)

An in-RAM container (e.g. the legacy from_bytes path or an inflated zip entry).

Implementations§

Source§

impl Backing

Source

pub fn sub(file: Arc<File>, base: u64, len: u64) -> Self

Construct a Backing::Sub over [base, base+len) of file.

Source

pub fn from_bytes(bytes: impl Into<Arc<[u8]>>) -> Self

Construct an in-RAM Backing::Mem from owned bytes.

Source

pub fn len(&self) -> u64

Total length of this container in bytes.

Source

pub fn is_empty(&self) -> bool

Whether the container is empty.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Backing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.