Skip to main content

build_sparse_writers_streaming

Function build_sparse_writers_streaming 

Source
pub fn build_sparse_writers_streaming<F>(
    name: &str,
    file_to_upload: &str,
    max_download_size: u64,
    on_slice: F,
) -> Result<(), SparseError>
Expand description

Takes the given file_to_upload for the named partition and generates SparseFileWriter slices on the fly, emitting each slice as soon as it reaches max_download_size.

§Arguments

  • name - Name of the partition for the image. Used for logs only.
  • file_to_upload - Path to the file to translate to sparse image format.
  • max_download_size - Maximum size that can be downloaded by the device for each slice.
  • on_slice - Callback invoked with each SparseFileWriter slice as it is completed.

§Errors

Returns SparseError::MaxDownloadSizeTooSmall if max_download_size is less than or equal to the block size ([BLK_SIZE]), or an I/O error if file_to_upload fails to open or read.