Skip to main content

SpoolerAsync

Struct SpoolerAsync 

Source
pub struct SpoolerAsync<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> { /* private fields */ }
Available on crate feature 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.

Source

pub fn is_attached(&self) -> bool

Whether a volume is attached, faulted or not.

Source

pub fn is_faulted(&self) -> bool

Whether the attached volume has faulted and needs detaching.

Source

pub fn resume_point(&self) -> Option<LogPosition>

Source position replication will resume from, if a volume is attached.

Source

pub fn source_log(&self) -> Option<LogId>

Identity of the log this spooler replicates.

Source

pub fn region(&self) -> CursorRegion

Layout of the cursor region on the volume.

Source

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>

Source

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.

Source

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
  • AlreadyAttached if a volume is already attached
  • NotMounted if the volume has not been mounted
  • ForeignVolume if its cursor belongs to a different log
Source

pub async fn reconcile<S, const SP: usize, const SS: usize>( &mut self, source: &mut SensorDbAsync<S, SP, SS>, ) -> Result<u32, Error>

Skip the part of an interrupted batch the replica already holds.

See Spooler::reconcile.

§Returns

The number of entries skipped.

Source

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.

Source

pub fn detach(&mut self) -> Option<SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>

Detach the volume, returning it to the application. Also clears a fault.

Source

pub fn volume(&self) -> Option<&SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>

The attached volume, if it is usable.

Source

pub fn volume_mut( &mut self, ) -> Option<&mut SensorDbAsync<C, PAGE_SIZE, MAX_SECTORS>>

The attached volume, if it is usable.

Source

pub fn volume_fill(&self) -> Option<VolumeFill>

How much room is left on the attached volume.

See Spooler::volume_fill.

Source

pub async fn spool<S, const SP: usize, const SS: usize>( &mut self, source: &mut SensorDbAsync<S, SP, SS>, budget: SpoolBudget, ) -> Result<SpoolProgress, Error>

Copy up to budget.max_entries durable source entries onto the volume.

See Spooler::spool.

Source

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>

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>

Source

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>

Like spool, but skip the pass when the driver reports the medium absent.

Source

pub fn is_present(&mut self) -> bool

Whether the driver reports the attached medium as present.

Auto Trait Implementations§

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> Freeze for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: Freeze, [u8; PAGE_SIZE]: Freeze,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> RefUnwindSafe for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: RefUnwindSafe, [u8; PAGE_SIZE]: RefUnwindSafe,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> Send for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: Send, [u8; PAGE_SIZE]: Send,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> Sync for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: Sync, [u8; PAGE_SIZE]: Sync,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> Unpin for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: Unpin, [u8; PAGE_SIZE]: Unpin,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> UnsafeUnpin for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: UnsafeUnpin, [u8; PAGE_SIZE]: UnsafeUnpin,

§

impl<C, const PAGE_SIZE: usize, const MAX_SECTORS: usize> UnwindSafe for SpoolerAsync<C, PAGE_SIZE, MAX_SECTORS>
where Slot<C, PAGE_SIZE, MAX_SECTORS>: UnwindSafe, [u8; PAGE_SIZE]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.