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
impl SparseFileWriter
Sourcepub fn new(chunks: Vec<Chunk>) -> SparseFileWriter
pub fn new(chunks: Vec<Chunk>) -> SparseFileWriter
Creates a new SparseFileWriter from a sequence of Chunks.
Sourcepub fn total_blocks(&self) -> u32
pub fn total_blocks(&self) -> u32
Returns the total number of blocks represented by all chunks in this sparse image.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Returns the total unsparsed size in bytes represented by this sparse image.
Sourcepub fn file_size(&self) -> u64
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.
Sourcepub fn slice_reader<'a, R: Read + Seek>(
&'a self,
source: &'a mut R,
) -> Result<SparseSliceReader<'a, R>, SparseError>
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.
Sourcepub fn write<W: Write + Seek, R: Read + Seek>(
&self,
reader: &mut R,
writer: &mut W,
) -> Result<(), SparseError>
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
impl Clone for SparseFileWriter
Source§fn clone(&self) -> SparseFileWriter
fn clone(&self) -> SparseFileWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more