Skip to main content

SparseFileWriter

Struct SparseFileWriter 

Source
pub struct SparseFileWriter {
    pub chunks: Vec<Chunk>,
}
Expand description

An in-memory description of an Android sparse image file.

Holds a sequence of Chunk definitions that describe how unsparsed image data should be formatted or partitioned. Can be serialized to a destination writer or lazily read via a SparseSliceReader.

Fields§

§chunks: Vec<Chunk>

The sequence of chunks that make up the sparse image.

Implementations§

Source§

impl SparseFileWriter

Source

pub fn new(chunks: Vec<Chunk>) -> SparseFileWriter

Creates a new SparseFileWriter from a sequence of Chunks.

Source

pub fn total_blocks(&self) -> u32

Returns the total number of blocks represented by all chunks in this sparse image.

Source

pub fn total_bytes(&self) -> u64

Returns the total unsparsed size in bytes represented by this sparse image.

Source

pub fn file_size(&self) -> u64

Returns the total serialized size (in bytes) of the sparse image file, including the file header, all chunk headers, and chunk payloads.

Source

pub fn slice_reader<'a, R: Read + Seek>( &'a self, source: &'a mut R, ) -> Result<SparseSliceReader<'a, R>, SparseError>

Creates an io::Read stream that lazily reads the serialized sparse image bytes directly from source without creating an intermediate file on disk.

§Errors

Returns SparseError::UnalignedChunk if any chunk is not aligned to the block size, or SparseError::Serialize if header serialization fails.

Source

pub fn write<W: Write + Seek, R: Read + Seek>( &self, reader: &mut R, writer: &mut W, ) -> Result<(), SparseError>

Writes the serialized sparse image to writer, reading raw payload data from reader.

§Errors

Returns an error if writing to writer or seeking/reading from reader fails, or if any chunk is invalid or cannot be serialized.

Trait Implementations§

Source§

impl Clone for SparseFileWriter

Source§

fn clone(&self) -> SparseFileWriter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SparseFileWriter

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for SparseFileWriter

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SparseFileWriter

Source§

fn eq(&self, other: &SparseFileWriter) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SparseFileWriter

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.