Api

Trait Api 

Source
pub trait Api: Send {
    const CHUNK_SIZE: usize;

    // Required methods
    fn start(dry_run: bool) -> Result<usize, Error>;
    fn erase() -> Result<(), Error>;
    fn write(chunk: &[u8]) -> Result<(), Error>;
    fn finish() -> Result<(), Error>;
}
Expand description

Common transfer interface.

A transfer process follows these steps:

  • start is called once
  • erase is called start() times
  • write is called zero or more times
  • finish is called once

Required Associated Constants§

Source

const CHUNK_SIZE: usize

Complete chunk size in bytes.

Required Methods§

Source

fn start(dry_run: bool) -> Result<usize, Error>

Starts a transfer process and returns the number of pages to erase.

The destination is not modified if dry-run is set.

Source

fn erase() -> Result<(), Error>

Erases a page of the destination.

Source

fn write(chunk: &[u8]) -> Result<(), Error>

Writes a chunk to the destination.

All chunks but the last must be complete.

Source

fn finish() -> Result<(), Error>

Finishes a transfer process.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§