pub struct CardJob<const N: usize> { /* private fields */ }Expand description
A save, format or delete run a little at a time. N is the number of
frame writes it can queue (see queue_frames and FORMAT_FRAMES); the
job holds N frames of 128 bytes plus the 2 KiB directory, so keep it in a
static. The idle job is all zero bytes, so a static one costs no space
in the executable.
Implementations§
Source§impl<const N: usize> CardJob<N>
impl<const N: usize> CardJob<N>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
An idle job with the default SETTLE_VBLANKS commit wait.
Sourcepub const fn with_settle_vblanks(self, vblanks: u32) -> Self
pub const fn with_settle_vblanks(self, vblanks: u32) -> Self
The same job with vblanks as the commit wait after each frame write,
for a card slower than the default allows for. 0 is the default.
Sourcepub fn begin(&mut self)
pub fn begin(&mut self)
Start an operation: the next steps read the directory. Anything in progress is dropped (what it had already written stays written).
Sourcepub fn progress_q8(&self) -> u32
pub fn progress_q8(&self) -> u32
How far along the operation is, 0 to 256: the directory read is the first sixteenth and the frame writes the rest.
Sourcepub fn step<B: Block>(&mut self, dev: &mut B, now: u32) -> Result<Step>
pub fn step<B: Block>(&mut self, dev: &mut B, now: u32) -> Result<Step>
Advance by at most one card transaction. now is the vblank count
(psx_rt::interrupts::vblank_count()), which times the commit wait;
dev is the card for this call only.
A card error ends the operation (the job is idle again) and is returned.
Sourcepub fn plan<R>(
&mut self,
build: impl FnOnce(&mut Card<Staged<'_, N>>) -> Result<R>,
) -> Result<R>
pub fn plan<R>( &mut self, build: impl FnOnce(&mut Card<Staged<'_, N>>) -> Result<R>, ) -> Result<R>
Run the filesystem operations for this job on a Staged card, after
step has returned Step::NeedsPlan. The closure sees
the card as it was probed and may read what it has written; its result
is passed through.
On Ok the queued writes are sent by the following steps. On Err the
job is idle again and nothing was written, so a caller that wants to
act on the error (ask before formatting a blank card, say) starts a new
operation with begin.
Out of order, this returns Error::Protocol and changes nothing.