Struct playdate::fs::prelude::File

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

Implementations§

source§

impl File

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> File<Api>
where Api: Api,

source

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

source

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

source

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

source

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

source

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

source

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

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> AsRaw for File<Api>
where Api: Api,

§

type Type = c_void

source§

unsafe fn as_raw(&self) -> *mut <File<Api> as AsRaw>::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 for File<Api>
where Api: Debug + Api,

source§

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

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

impl<Api> Drop for File<Api>
where Api: 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.