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

Card

Struct Card 

Source
pub struct Card<B: Block> { /* private fields */ }
Expand description

A memory card with the standard PS1 filesystem on top of a Block device.

Implementations§

Source§

impl<B: Block> Card<B>

Source

pub fn is_formatted(&mut self) -> Result<bool>

True if the card carries the MC directory header.

Source

pub fn validate_filesystem(&mut self) -> Result<()>

Validate the directory before a safety-critical write.

This checks the MC header, every directory-sector checksum, every allocation state and link, rejects loops/cross-links and orphan continuation blocks, and requires each first entry’s file size to equal its allocated chain in 8 KiB units as required by the Sony BIOS. It performs no writes.

Source

pub fn format(&mut self) -> Result<()>

Lay down a fresh, empty directory (byte-identical to a BIOS format’s system area). Data blocks are left as-is; the directory marks them free.

Source

pub fn free_blocks(&mut self) -> Result<usize>

Number of free 8 KiB blocks.

Source

pub fn list(&mut self, out: &mut [Entry]) -> Result<usize>

List all files. Returns the number written to out (capped at its len).

Source

pub fn delete(&mut self, name: &str) -> Result<()>

Delete name, freeing its blocks. Ok(()) even if it did not exist.

Source

pub fn write(&mut self, name: &str, title: &str, data: &[u8]) -> Result<()>

Write a save (uncompressed), replacing any existing file of the same name. The old save stays on the card until the new one is complete, so a failed or interrupted write leaves it readable; the price is that the card needs room for both copies at once, and a write that does not fit returns Error::NoSpace without touching the card. name is the BIOS file name (product code + label, <= 20 ASCII); title is the human-readable label shown by the card manager (<= 32 ASCII).

Source

pub fn write_with_icon( &mut self, name: &str, title: &str, data: &[u8], icon: &SaveIcon, ) -> Result<()>

Write an uncompressed save with a caller-supplied native 16×16 icon.

Source

pub fn write_compressed( &mut self, name: &str, title: &str, data: &[u8], scratch: &mut [u8], ) -> Result<()>

Write a save, compressing the payload with LZSS when it helps. scratch receives the compressor output and must be at least data.len() bytes; if compression does not shrink the data, it is stored as-is.

Source

pub fn read(&mut self, name: &str, buf: &mut [u8]) -> Result<usize>

Read a save into buf. Returns the payload length. Transparently decompresses if the save was written with Card::write_compressed (requires the compress feature).

Source§

impl<B: Block> Card<B>

Source

pub fn new(dev: B) -> Self

Wrap a block device. Does no I/O; call Card::is_formatted / Card::format as needed.

Source

pub fn into_inner(self) -> B

Recover the underlying block device.

Source

pub fn device(&mut self) -> &mut B

Borrow the underlying block device.

Auto Trait Implementations§

§

impl<B> Freeze for Card<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Card<B>
where B: RefUnwindSafe,

§

impl<B> Send for Card<B>
where B: Send,

§

impl<B> Sync for Card<B>
where B: Sync,

§

impl<B> Unpin for Card<B>
where B: Unpin,

§

impl<B> UnsafeUnpin for Card<B>
where B: UnsafeUnpin,

§

impl<B> UnwindSafe for Card<B>
where B: UnwindSafe,

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.