pub struct SpoolerAsync<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> { /* private fields */ }async only.Expand description
Copies a log onto a removable volume, and remembers how far it got.
Async counterpart of Spooler, with the same
guarantees: no loss, duplication bounded by SpoolBudget::max_entries and
in practice reconciled away on reinsert, and nothing written to a volume
belonging to a different log.
Implementations§
Source§impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
Inspection that needs no flash access, and therefore no trait bounds.
impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
Inspection that needs no flash access, and therefore no trait bounds.
Sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Whether a volume is attached, faulted or not.
Sourcepub fn is_faulted(&self) -> bool
pub fn is_faulted(&self) -> bool
Whether the attached volume has faulted and needs detaching.
Sourcepub fn resume_point(&self) -> Option<LogPosition>
pub fn resume_point(&self) -> Option<LogPosition>
Source position replication will resume from, if a volume is attached.
Sourcepub fn source_log(&self) -> Option<LogId>
pub fn source_log(&self) -> Option<LogId>
Identity of the log this spooler replicates.
Sourcepub fn region(&self) -> CursorRegion
pub fn region(&self) -> CursorRegion
Layout of the cursor region on the volume.
Sourcepub fn pending_reconciliation(&self) -> u32
pub fn pending_reconciliation(&self) -> u32
Entries of an interrupted batch that the replica already holds and the next pass will skip rather than copy again.
Source§impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>where
C: NorFlash + ReadNorFlash,
impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>where
C: NorFlash + ReadNorFlash,
Sourcepub fn new(
source_log: Option<LogId>,
cursor_base: u32,
sector_size: u32,
) -> Result<Self, Error>
pub fn new( source_log: Option<LogId>, cursor_base: u32, sector_size: u32, ) -> Result<Self, Error>
Create a spooler for a log with the given identity.
See Spooler::new. cursor_base must name
a region outside the volume’s database region, which
attach enforces with Error::RegionOverlap.
Sourcepub async fn attach(
&mut self,
volume: SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>,
) -> Result<Attached, Error>
pub async fn attach( &mut self, volume: SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>, ) -> Result<Attached, Error>
Attach a mounted volume and read its cursor.
Reconciles an interrupted batch the same way as
Spooler::attach; see there for why the
replica is the thing that knows how far the batch got.
§Errors
AlreadyAttachedif a volume is already attachedNotMountedif the volume has not been mountedForeignVolumeif its cursor belongs to a different log
Sourcepub async fn reconcile<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
) -> Result<u32, Error>where
S: NorFlash + ReadNorFlash,
pub async fn reconcile<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
) -> Result<u32, Error>where
S: NorFlash + ReadNorFlash,
Skip the part of an interrupted batch the replica already holds.
See Spooler::reconcile.
§Returns
The number of entries skipped.
Sourcepub fn fault(&mut self) -> Option<&mut SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
pub fn fault(&mut self) -> Option<&mut SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
Mark the attached volume faulted and borrow it.
Returns the volume so the caller can still reach data in its RAM page buffer, which survives the medium being pulled.
Sourcepub fn detach(&mut self) -> Option<SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
pub fn detach(&mut self) -> Option<SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
Detach the volume, returning it to the application. Also clears a fault.
Sourcepub fn volume(&self) -> Option<&SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
pub fn volume(&self) -> Option<&SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
The attached volume, if it is usable.
Sourcepub fn volume_mut(
&mut self,
) -> Option<&mut SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
pub fn volume_mut( &mut self, ) -> Option<&mut SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>
The attached volume, if it is usable.
Sourcepub fn volume_fill(&self) -> Option<VolumeFill>
pub fn volume_fill(&self) -> Option<VolumeFill>
How much room is left on the attached volume.
See Spooler::volume_fill.
Sourcepub async fn spool<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
) -> Result<SpoolProgress, Error>where
S: NorFlash + ReadNorFlash,
pub async fn spool<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
) -> Result<SpoolProgress, Error>where
S: NorFlash + ReadNorFlash,
Copy up to budget.max_entries durable source entries onto the volume.
See Spooler::spool.
Sourcepub async fn spool_until_caught_up<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
max_batches: u32,
) -> Result<SpoolProgress, Error>where
S: NorFlash + ReadNorFlash,
pub async fn spool_until_caught_up<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
max_batches: u32,
) -> Result<SpoolProgress, Error>where
S: NorFlash + ReadNorFlash,
Copy until the replica is level with the source, or max_batches passes
have run.
Source§impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
Sourcepub async fn spool_if_present<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
) -> Result<Option<SpoolProgress>, Error>where
S: NorFlash + ReadNorFlash,
pub async fn spool_if_present<S, const SP: usize, const SS: usize>(
&mut self,
source: &mut SensorDbAsync<S, SP, SS>,
budget: SpoolBudget,
) -> Result<Option<SpoolProgress>, Error>where
S: NorFlash + ReadNorFlash,
Like spool, but skip the pass when the driver reports
the medium absent.
Sourcepub fn is_present(&mut self) -> bool
pub fn is_present(&mut self) -> bool
Whether the driver reports the attached medium as present.