espflash/targets/flash_target/
mod.rs

1pub(crate) use self::ram::MAX_RAM_BLOCK_SIZE;
2pub use self::{esp32::Esp32Target, ram::RamTarget};
3use crate::{connection::Connection, elf::RomSegment, error::Error};
4
5mod esp32;
6mod ram;
7
8/// Progress update callbacks
9pub trait ProgressCallbacks {
10    /// Initialize some progress report
11    fn init(&mut self, addr: u32, total: usize);
12    /// Update some progress report
13    fn update(&mut self, current: usize);
14    /// Finish some progress report
15    fn finish(&mut self);
16}
17
18/// Operations for interacting with a flash target
19pub trait FlashTarget {
20    /// Begin the flashing operation
21    fn begin(&mut self, connection: &mut Connection) -> Result<(), Error>;
22
23    /// Write a segment to the target device
24    fn write_segment(
25        &mut self,
26        connection: &mut Connection,
27        segment: RomSegment,
28        progress: &mut Option<&mut dyn ProgressCallbacks>,
29    ) -> Result<(), Error>;
30
31    /// Complete the flashing operation
32    fn finish(&mut self, connection: &mut Connection, reboot: bool) -> Result<(), Error>;
33}