File

Struct File 

Source
pub struct File<Api: Api = Default>(/* private fields */);

Implementations§

Source§

impl File<Default>

Source

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>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn close(self) -> Result<(), Error>

Closes this file.

Equivalent to sys::ffi::playdate_file::close

Trait Implementations§

Source§

impl<Api: Api> AsRaw for File<Api>

Source§

type Type = c_void

Source§

unsafe fn as_raw(&self) -> *mut Self::Type

This method ia actually safe. Unsafety is because so we’re removing owners lifetime that used by some API parts.
Source§

impl<Api: Debug + Api> Debug for File<Api>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Api: Api> Drop for File<Api>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AnyFile for T
where 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.