mod esp32;
mod ram;
pub use self::{esp32::Esp32Target, ram::RamTarget};
use crate::{Error, connection::Connection, image_format::Segment};
pub trait FlashTarget {
fn begin(&mut self, connection: &mut Connection) -> Result<(), Error>;
fn write_segment(
&mut self,
connection: &mut Connection,
segment: Segment<'_>,
progress: &mut dyn ProgressCallbacks,
) -> Result<(), Error>;
fn finish(&mut self, connection: &mut Connection, reboot: bool) -> Result<(), Error>;
}
pub trait ProgressCallbacks {
fn init(&mut self, addr: u32, total: usize);
fn update(&mut self, current: usize);
fn verifying(&mut self);
fn finish(&mut self, skipped: bool);
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct DefaultProgressCallback;
impl ProgressCallbacks for DefaultProgressCallback {
fn init(&mut self, _addr: u32, _total: usize) {}
fn update(&mut self, _current: usize) {}
fn verifying(&mut self) {}
fn finish(&mut self, _skipped: bool) {}
}