pub struct File<Api = Default>(/* private fields */)
where
Api: Api;
Implementations§
source§impl File
impl File
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> File<Api>where
Api: Api,
impl<Api> File<Api>where
Api: Api,
sourcepub fn open<P>(path: P, data_dir: bool) -> Result<File<Api>, Error<Error>>where
P: AsRef<str>,
Api: Default,
pub fn open<P>(path: P, data_dir: bool) -> Result<File<Api>, Error<Error>>where
P: AsRef<str>,
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>(
api: Api,
path: P,
data_dir: bool
) -> Result<File<Api>, Error<Error>>where
P: AsRef<str>,
pub fn open_with<P>(
api: Api,
path: P,
data_dir: bool
) -> Result<File<Api>, Error<Error>>where
P: AsRef<str>,
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: u32) -> Result<u32, Error>
pub fn read(&mut self, to: &mut Vec<u8>, len: u32) -> Result<u32, 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<u32, Error>
pub fn write(&mut self, from: &[u8]) -> Result<u32, 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<u32, Error>
pub fn flush(&mut self) -> Result<u32, 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<u32, Error>
pub fn tell(&mut self) -> Result<u32, 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> Freeze for File<Api>where
Api: Freeze,
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.