pub struct Fs<Api = Default>(/* private fields */);Expand description
Playdate File-system API.
Uses inner api end-point for all operations.
Implementations§
Source§impl Fs<Default>
impl Fs<Default>
Sourcepub fn Default() -> Self
pub fn Default() -> Self
Creates default Fs without type parameter requirement.
Uses ZST api::Default.
Source§impl Fs<Cache>
impl Fs<Cache>
Sourcepub fn Cached() -> Self
pub fn Cached() -> Self
Creates Fs without type parameter requirement.
Uses api::Cache.
Source§impl<Api: Api> Fs<Api>
impl<Api: Api> Fs<Api>
Sourcepub fn open<P: AsRef<Path>, Opts: OpenOptions>(
&self,
path: P,
options: Opts,
) -> Result<File<Api>, ApiError>where
Api: Copy,
pub fn open<P: AsRef<Path>, Opts: OpenOptions>(
&self,
path: P,
options: Opts,
) -> Result<File<Api>, ApiError>where
Api: Copy,
Open file for given options.
Creates new File instance with copy of inner api end-point.
Equivalent to sys::ffi::playdate_file::open
Sourcepub fn open_with<T: Api, P: AsRef<Path>, Opts: OpenOptions>(
&self,
api: T,
path: P,
options: Opts,
) -> Result<File<T>, ApiError>
pub fn open_with<T: Api, P: AsRef<Path>, Opts: OpenOptions>( &self, api: T, path: P, options: Opts, ) -> Result<File<T>, ApiError>
Open file for given options.
Creates new File instance with given api.
Equivalent to sys::ffi::playdate_file::open
Sourcepub fn close<T: Api>(&self, file: File<T>) -> Result<(), Error>
pub fn close<T: Api>(&self, file: File<T>) -> Result<(), Error>
Closes the given file.
Equivalent to sys::ffi::playdate_file::close
Sourcepub fn tell(&self, file: &mut impl AnyFile) -> Result<c_uint, Error>
pub fn tell(&self, file: &mut impl AnyFile) -> Result<c_uint, Error>
Returns the current read/write offset in the given file.
Equivalent to sys::ffi::playdate_file::tell
Sourcepub fn seek_raw(
&self,
file: &mut impl AnyFile,
pos: c_int,
whence: Whence,
) -> Result<(), Error>
pub fn seek_raw( &self, file: &mut impl AnyFile, pos: c_int, whence: Whence, ) -> Result<(), Error>
Sets the read/write offset in the given file to pos, relative to the whence.
Whence::Startis relative to the beginning of the file,Whence::Currentis relative to the current position of the file,Whence::Endis relative to the end of the file.
Equivalent to sys::ffi::playdate_file::seek
Sourcepub fn read(
&self,
file: &mut impl AnyFile,
to: &mut Vec<u8>,
len: c_uint,
) -> Result<c_uint, Error>
pub fn read( &self, file: &mut impl AnyFile, to: &mut Vec<u8>, len: c_uint, ) -> Result<c_uint, Error>
Reads up to len bytes from the file into the buffer to.
Returns the number of bytes read (0 indicating end of file).
Caution: Vector must be prefilled with 0s.
let mut buf = Vec::<u8>::with_capacity(size);
buf.resize(size, 0);
fs.read(&mut file, &mut buf, size)?;Equivalent to sys::ffi::playdate_file::read
Sourcepub fn write(
&self,
file: &mut impl AnyFile,
from: &[u8],
) -> Result<c_uint, Error>
pub fn write( &self, file: &mut impl AnyFile, from: &[u8], ) -> Result<c_uint, Error>
Writes the buffer of bytes buf to the file.
Returns the number of bytes written.
Equivalent to sys::ffi::playdate_file::write
Sourcepub fn flush(&self, file: &mut impl AnyFile) -> Result<c_uint, Error>
pub fn flush(&self, file: &mut impl AnyFile) -> Result<c_uint, Error>
Flushes the output buffer of file immediately.
Returns the number of bytes written.
Equivalent to sys::ffi::playdate_file::flush
Sourcepub fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<FileStat, ApiError>
pub fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<FileStat, ApiError>
Populates the FileStat stat with information about the file at path.
Equivalent to sys::ffi::playdate_file::stat
Sourcepub fn metadata_to<P: AsRef<Path>>(
&self,
path: P,
metadata: &mut FileStat,
) -> Result<(), ApiError>
pub fn metadata_to<P: AsRef<Path>>( &self, path: P, metadata: &mut FileStat, ) -> Result<(), ApiError>
Writes into the given metadata information about the file at path.
Equivalent to sys::ffi::playdate_file::stat
Sourcepub fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
pub fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
Creates the given path in the Data/<gameid> folder.
It does not create intermediate folders.
Equivalent to sys::ffi::playdate_file::mkdir
Sourcepub fn remove<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
pub fn remove<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
Deletes the file at path. Directory is a file too, definitely.
See also remove_dir_all.
Equivalent to sys::ffi::playdate_file::unlink
Sourcepub fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
pub fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<(), ApiError>
Deletes the file at path.
If the path is a folder, this deletes everything inside the folder
(including folders, folders inside those, and so on) as well as the folder itself.
Equivalent to sys::ffi::playdate_file::unlink
Sourcepub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
from: P,
to: Q,
) -> Result<(), ApiError>
pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>( &self, from: P, to: Q, ) -> Result<(), ApiError>
Renames the file at from to to.
It will overwrite the file at to.
It does not create intermediate folders.
Equivalent to sys::ffi::playdate_file::rename
Sourcepub fn read_dir<P, Fn>(
&self,
path: P,
callback: Fn,
include_hidden: bool,
) -> Result<(), ApiError>where
P: AsRef<Path>,
Fn: FnMut(String),
pub fn read_dir<P, Fn>(
&self,
path: P,
callback: Fn,
include_hidden: bool,
) -> Result<(), ApiError>where
P: AsRef<Path>,
Fn: FnMut(String),
Calls the given callback function for every file at path.
Subfolders are indicated by a trailing slash ‘/’ in filename.
This method does not recurse into subfolders.
If include_hidden is set, files beginning with a period will be included;
otherwise, they are skipped.
Returns error if no folder exists at path or it can’t be opened.
Equivalent to sys::ffi::playdate_file::listfiles
Trait Implementations§
impl<Api: Copy> Copy for Fs<Api>
Auto Trait Implementations§
impl<Api> Freeze for Fs<Api>where
Api: Freeze,
impl<Api> RefUnwindSafe for Fs<Api>where
Api: RefUnwindSafe,
impl<Api> Send for Fs<Api>where
Api: Send,
impl<Api> Sync for Fs<Api>where
Api: Sync,
impl<Api> Unpin for Fs<Api>where
Api: Unpin,
impl<Api> UnwindSafe for Fs<Api>where
Api: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
§impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.