Trait playdate_fs::FileSystem
source · pub trait FileSystem: FileSystemRawwhere
Self::Error: From<Self::AccessError>,{
type Error: Error + From<Self::AccessError>;
Show 15 methods
// Required methods
fn open<P: AsRef<Path>, Opts: OpenOptions>(
&self,
path: P,
options: Opts
) -> Result<File, Self::Error>;
fn close(&self, file: File) -> Result<(), Self::Error>;
fn tell(&self, file: &mut File) -> Result<c_uint, Self::Error>;
fn seek_raw(
&self,
file: &mut File,
pos: c_int,
whence: Whence
) -> Result<c_uint, Self::Error>;
fn read(
&self,
file: &mut File,
to: &mut Vec<u8>,
len: c_uint
) -> Result<c_uint, Self::Error>;
fn write(&self, file: &mut File, from: &[u8]) -> Result<c_uint, Self::Error>;
fn flush(&self, file: &mut File) -> Result<c_uint, Self::Error>;
fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<FileStat, Self::Error>;
fn metadata_to<P: AsRef<Path>>(
&self,
path: P,
metadata: &mut FileStat
) -> Result<(), Self::Error>;
fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Error>;
fn remove<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Error>;
fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<(), Self::Error>;
fn rename<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: P,
to: Q
) -> Result<(), Self::Error>;
fn read_dir<P, Fn>(
&self,
path: P,
callback: Fn,
include_hidden: bool
) -> Result<(), Self::Error>
where P: AsRef<Path>,
Fn: FnMut(String);
// Provided method
fn seek(
&self,
file: &mut File,
pos: SeekFrom
) -> Result<c_uint, Self::Error> { ... }
}Required Associated Types§
Required Methods§
sourcefn open<P: AsRef<Path>, Opts: OpenOptions>(
&self,
path: P,
options: Opts
) -> Result<File, Self::Error>
fn open<P: AsRef<Path>, Opts: OpenOptions>( &self, path: P, options: Opts ) -> Result<File, Self::Error>
Open file for given options.
sourcefn tell(&self, file: &mut File) -> Result<c_uint, Self::Error>
fn tell(&self, file: &mut File) -> Result<c_uint, Self::Error>
Get current cursor position in the file, in bytes.
sourcefn seek_raw(
&self,
file: &mut File,
pos: c_int,
whence: Whence
) -> Result<c_uint, Self::Error>
fn seek_raw( &self, file: &mut File, pos: c_int, whence: Whence ) -> Result<c_uint, Self::Error>
Seek to an offset, in bytes.
Works similarly to [
std::io::Seek::seek].
sourcefn read(
&self,
file: &mut File,
to: &mut Vec<u8>,
len: c_uint
) -> Result<c_uint, Self::Error>
fn read( &self, file: &mut File, to: &mut Vec<u8>, len: c_uint ) -> Result<c_uint, Self::Error>
Read the len bytes of a file into the to vector.
Works similarly to [
std::io::Read::read].
sourcefn write(&self, file: &mut File, from: &[u8]) -> Result<c_uint, Self::Error>
fn write(&self, file: &mut File, from: &[u8]) -> Result<c_uint, Self::Error>
Write a buffer into the file, returning how many bytes were written.
Works similarly to [
std::io::Write::write].
sourcefn flush(&self, file: &mut File) -> Result<c_uint, Self::Error>
fn flush(&self, file: &mut File) -> Result<c_uint, Self::Error>
Flush the file, ensuring that all intermediately buffered
contents reach their destination.
Works similarly to [
std::io::Write::flush].