ImageHandle

Struct ImageHandle 

Source
pub struct ImageHandle {
    pub primary_header: PrimaryHeader,
    pub protected_header: Option<ProtectedHeader>,
    pub config: Option<Vec<u8>>,
    pub digest_table: Option<DigestTable>,
    pub directory: Option<Directory>,
    pub path: PathBuf,
    pub file_size: u64,
    pub id: String,
}
Expand description

Represents a goldboot image on disk.

§Binary format

SectionEncryption Key
Primary HeaderNone
Protected HeaderPassword + SHA256
Image ConfigPassword + SHA256
Cluster TableCluster Key
Digest TablePassword + SHA256
DirectoryPassword + SHA256

The target data is divided into equal size sections called “blocks”. Blocks that are nonzero will have an associated “cluster” allocated in the image file. Clusters are variable in size and ideally smaller than their associated blocks (due to compression). If a block does not have an associated cluster, that block is zero.

Fields§

§primary_header: PrimaryHeader

The primary file header

§protected_header: Option<ProtectedHeader>

The secondary header

§config: Option<Vec<u8>>

The encoded config used to build the image

§digest_table: Option<DigestTable>

The digest table

§directory: Option<Directory>

The section directory

§path: PathBuf

The filesystem path to the image file

§file_size: u64

The size in bytes of the image file on disk

§id: String

The image’s ID (SHA256 hash)

Implementations§

Source§

impl ImageHandle

Source

pub fn load(&mut self, password: Option<String>) -> Result<()>

Load all sections into memory except the cluster table. If the image is encrypted, the sections will be decrypted.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a new handle on the given file.

Source

pub fn change_password( &self, _old_password: String, new_password: String, ) -> Result<()>

Modify the password and re-encrypt all encrypted sections. This doesn’t re-encrypt the clusters because they are encrypted with the cluster key.

Source

pub fn write<F: Fn(u64, u64)>( &self, dest: impl AsRef<Path>, progress: F, ) -> Result<()>

TODO multi threaded WriteWorkers TODO write backup GPT header Write the image contents out to disk.

Trait Implementations§

Source§

impl Debug for ImageHandle

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more