Struct tartan_uefi::proto::File

source ·
#[repr(C)]
pub struct File { pub revision: u64, /* private fields */ }
Expand description

Protocol for accessing a file or directory.

Fields§

§revision: u64

Implemented revision of the File protocol.

Implementations§

source§

impl File

source

pub const MIN_REVISION: u32 = 65_536u32

Minimum supported SimpleFileSystem::revision. Future versions are guaranteed to be backwards-compatible.

source

pub fn open( &self, path: &[u16], mode: FileMode, attributes: FileAttributes ) -> Result<&File, Status>

Get a handle to a new file, relative to the directory represented by the current instance.

path uses the Windows path format without a drive name, e.g. \FOO\BAR.TXT or ..\QUUX.DAT.

attributes is only used if the file is created.

§Errors

This method can fail for many reasons, including standard I/O issues like device errors or resource exhaustion. It can also fail if access is denied or there was an attempt to write to read-only media.

§Panics

Panics if path is empty or does not end in a null character.

source

pub fn close(&self)

Flush and close the file or directory represented by the current instance.

§Panics

Panics if the firmware does not behave according to the spec.

source

pub fn delete(&self) -> Status

Delete the file or directory represented by the current instance.

§Errors

This method cannot fail with an error, but it will return Status::WarnDeleteFailure if the file could not be deleted.

source

pub fn read(&self, buffer: &mut [u8]) -> Result<usize, Status>

Read file contents or a directory entry into the buffer.

If this is a file, it will read up to buffer.len() bytes. If it is a directory, it will read a single directory entry if that entry can fit in the buffer.

On success, returns the number of bytes actually read.

§Errors

This method can fail for many reasons, including standard I/O issues like device errors or resource exhaustion. In addition, it will return:

source

pub fn write(&self, buffer: &[u8]) -> Result<usize, Status>

Write the contents of buffer out to the current position.

On success, returns the number of bytes actually written, which will always be the full buffer.

§Errors

This method can fail for many reasons, including standard I/O issues like device errors or resource exhaustion. It addition, it will return:

  • Status::Unsupported if this is a directory.
  • Status::AccessDenied if the file is in read-only mode.
source

pub fn get_position(&self) -> Result<u64, Status>

Get the handle’s current position in the file.

§Errors

This function will fail with:

source

pub fn set_position(&self, position: u64) -> Result

Set the handle’s current position in the file.

If the position is u64::MAX, this will seek to the end of the file. Otherwise, it seeks to the absolute position in bytes. If the position is greater than the current file size, the file will grow to the given size.

§Errors

This function will fail with:

source

pub fn flush(&self) -> Result

Write any buffered changes.

§Errors

This method can fail for many reasons, including standard I/O issues like device errors or resource exhaustion. It can also fail if access is denied or there was an attempt to write to read-only media.

Auto Trait Implementations§

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.