24 lines
871 B
Rust
24 lines
871 B
Rust
//! Host region IO. Logical mapping, checksums and publication belong to the runtime.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum MemcardIoError {
|
|
Unavailable,
|
|
ReadOnly,
|
|
InvalidRange,
|
|
NoSpace,
|
|
Unsupported,
|
|
IoError,
|
|
}
|
|
|
|
/// Implementations return success only for a complete transfer. Errors may have
|
|
/// partial effects. Instances stay owned by their worker until all IO has ceased.
|
|
pub trait MemcardStorage: Send {
|
|
fn len(&self) -> Result<u64, MemcardIoError>;
|
|
fn is_empty(&self) -> Result<bool, MemcardIoError> {
|
|
self.len().map(|length| length == 0)
|
|
}
|
|
fn read_at(&mut self, offset: u64, target: &mut [u8]) -> Result<(), MemcardIoError>;
|
|
fn write_at(&mut self, offset: u64, source: &[u8]) -> Result<(), MemcardIoError>;
|
|
fn sync(&mut self) -> Result<(), MemcardIoError>;
|
|
fn read_only(&self) -> bool;
|
|
}
|