Struct playdate_fs::file::File
source · pub struct File<Api: Api = Default>(/* private fields */);Implementations§
source§impl File<Default>
impl File<Default>
sourcepub fn options() -> impl OpenOptions + FileOptionsExt
pub fn options() -> impl OpenOptions + FileOptionsExt
Creates a blank new set of options ready for configuration. All options are initially set to false.
It is equivalent to FileOptions::new().
source§impl<Api: Api> File<Api>
impl<Api: Api> File<Api>
sourcepub fn open<P: AsRef<Path>>(
path: P,
data_dir: bool
) -> Result<File<Api>, ApiError>where
Api: Default,
pub fn open<P: AsRef<Path>>( path: P, data_dir: bool ) -> Result<File<Api>, ApiError>where Api: Default,
Attempts to open a file in read-only mode.
See the OpenOptions::open method and official docs for more details.
Equivalent to sys::ffi::playdate_file::open
sourcepub fn open_with<P: AsRef<Path>>(
api: Api,
path: P,
data_dir: bool
) -> Result<File<Api>, ApiError>
pub fn open_with<P: AsRef<Path>>( api: Api, path: P, data_dir: bool ) -> Result<File<Api>, ApiError>
Attempts to open a file in read-only mode, using the given api.
See the OpenOptions::open method and official docs for more details.
Equivalent to sys::ffi::playdate_file::open
sourcepub fn read(&mut self, to: &mut Vec<u8>, len: c_uint) -> Result<c_uint, Error>
pub fn read(&mut self, to: &mut Vec<u8>, len: c_uint) -> Result<c_uint, Error>
Reads up to len bytes from the file into the buffer buf.
Returns the number of bytes read (0 indicating end of file).
Equivalent to sys::ffi::playdate_file::read
sourcepub fn write(&mut self, from: &[u8]) -> Result<c_uint, Error>
pub fn write(&mut self, 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(&mut self) -> Result<c_uint, Error>
pub fn flush(&mut self) -> 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 tell(&mut self) -> Result<c_uint, Error>
pub fn tell(&mut self) -> Result<c_uint, Error>
Returns the current read/write offset in the given file handle.
Equivalent to sys::ffi::playdate_file::tell
sourcepub fn seek(&mut self, pos: SeekFrom) -> Result<(), Error>
pub fn seek(&mut self, pos: SeekFrom) -> Result<(), Error>
Sets the read/write offset in the file to pos.
Equivalent to sys::ffi::playdate_file::seek
sourcepub fn close(self) -> Result<(), Error>
pub fn close(self) -> Result<(), Error>
Closes this file.
Equivalent to sys::ffi::playdate_file::close
Trait Implementations§
Auto Trait Implementations§
impl<Api> RefUnwindSafe for File<Api>where Api: RefUnwindSafe,
impl<Api = Default> !Send for File<Api>
impl<Api = Default> !Sync for File<Api>
impl<Api> Unpin for File<Api>where Api: Unpin,
impl<Api> UnwindSafe for File<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, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere U: From<T>,
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,
impl<T> AnyFile for Twhere T: AsRaw<Type = c_void>,
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.