Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

CardJob

Struct CardJob 

Source
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>

Source

pub const fn new() -> Self

An idle job with the default SETTLE_VBLANKS commit wait.

Source

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.

Source

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).

Source

pub fn abort(&mut self)

Drop the operation in progress. Frames already sent stay on the card.

Source

pub fn is_busy(&self) -> bool

Whether an operation is in progress.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<const N: usize> Default for CardJob<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for CardJob<N>

§

impl<const N: usize> RefUnwindSafe for CardJob<N>

§

impl<const N: usize> Send for CardJob<N>

§

impl<const N: usize> Sync for CardJob<N>

§

impl<const N: usize> Unpin for CardJob<N>

§

impl<const N: usize> UnsafeUnpin for CardJob<N>

§

impl<const N: usize> UnwindSafe for CardJob<N>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.