storage: build++

This commit is contained in:
2026-03-14 12:19:51 +01:00
parent aa69464258
commit 2213c56ddb

View File

@@ -155,12 +155,19 @@ impl<S: Storage> RmpWrite for StorageRange<S> where S::Error: core::fmt::Debug +
} }
pub struct SimDataRecorder<S> { pub struct SimDataRecorder<S> {
storage: StorageRange<S>, storage: S,
last_stamp: Instant last_stamp: Instant
} }
impl<S: Storage + Clone> SimDataRecorder<S> where S::Error: core::fmt::Debug + 'static { impl<S> SimDataRecorder<S> {
pub fn open(storage: S, partitions: PartitionTable<'_>) -> Result<Self, SimDataError<ValueWriteError<StorageRangeError<S::Error>>>> { pub fn new(storage: S) -> Self {
Self {
storage,
last_stamp: Instant::now()
}
}
pub fn open(storage: S, partitions: PartitionTable<'_>) -> Result<SimDataRecorder<StorageRange<S>>, SimDataError<ValueWriteError<StorageRangeError<<S as ReadStorage>::Error>>>> where S: Storage, <S as ReadStorage>::Error: core::fmt::Debug + 'static {
let partition_type = esp_bootloader_esp_idf::partitions::PartitionType::Data( let partition_type = esp_bootloader_esp_idf::partitions::PartitionType::Data(
esp_bootloader_esp_idf::partitions::DataPartitionSubType::Undefined, esp_bootloader_esp_idf::partitions::DataPartitionSubType::Undefined,
); );
@@ -171,17 +178,17 @@ impl<S: Storage + Clone> SimDataRecorder<S> where S::Error: core::fmt::Debug + '
let start = data_partition.offset() as usize; let start = data_partition.offset() as usize;
let end = data_partition.len() as usize + start; let end = data_partition.len() as usize + start;
let mut writer = StorageRange::new(storage.clone(), start, end); let mut writer = StorageRange::new(storage, start, end);
warn!("Writing new simulation data at {start:#02x}:{end:#02x}"); warn!("Writing new simulation data at {start:#02x}:{end:#02x}");
StreamIndex { count: 1 }.write_rmp(&mut writer)?; StreamIndex { count: 1 }.write_rmp(&mut writer)?;
StreamHeader { id: StreamType::Bundle, size: 0 }.write_rmp(&mut writer)?; StreamHeader { id: StreamType::Bundle, size: 0 }.write_rmp(&mut writer)?;
Ok(Self { Ok(SimDataRecorder {
storage: writer, storage: writer,
last_stamp: Instant::now() last_stamp: Instant::now()
}) })
} }
pub fn write_next<T: EventRecord>(&mut self, event: T) -> Result<(), SimDataError<ValueWriteError<StorageRangeError<S::Error>>>> { pub fn write_next<T: EventRecord>(&mut self, event: T) -> Result<(), SimDataError<ValueWriteError<S::Error>>> where S: RmpWrite {
BundleEventHeader { id: T::stream_id() }.write_rmp(&mut self.storage)?; BundleEventHeader { id: T::stream_id() }.write_rmp(&mut self.storage)?;
let now = Instant::now(); let now = Instant::now();
let event = StreamEvent { let event = StreamEvent {