Trait uefi::proto::media::file::File

source ·
pub trait File: Sized {
    // Required methods
    fn is_regular_file(&self) -> Result<bool>;
    fn is_directory(&self) -> Result<bool>;

    // Provided methods
    fn open(
        &mut self,
        filename: &CStr16,
        open_mode: FileMode,
        attributes: FileAttribute
    ) -> Result<FileHandle> { ... }
    fn close(self) { ... }
    fn delete(self) -> Result { ... }
    fn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
        &mut self,
        buffer: &'buf mut [u8]
    ) -> Result<&'buf mut Info, Option<usize>> { ... }
    fn set_info<Info: FileProtocolInfo + ?Sized>(
        &mut self,
        info: &Info
    ) -> Result { ... }
    fn flush(&mut self) -> Result { ... }
    fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>(
        &mut self
    ) -> Result<Box<Info>> { ... }
    fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>(
        &mut self,
        allocator: A
    ) -> Result<Box<Info>> { ... }
}
Expand description

Common interface to FileHandle, RegularFile, and Directory.

File contains all functionality that is safe to perform on any type of file handle.

Required Methods§

source

fn is_regular_file(&self) -> Result<bool>

Returns if the underlying file is a regular file. The result is an error if the underlying file was already closed or deleted.

UEFI file system protocol only knows “regular files” and “directories”.

source

fn is_directory(&self) -> Result<bool>

Returns if the underlying file is a directory. The result is an error if the underlying file was already closed or deleted.

UEFI file system protocol only knows “regular files” and “directories”.

Provided Methods§

source

fn open( &mut self, filename: &CStr16, open_mode: FileMode, attributes: FileAttribute ) -> Result<FileHandle>

Try to open a file relative to this file.

§Arguments
  • filename Path of file to open, relative to this file
  • open_mode The mode to open the file with
  • attributes Only valid when FILE_MODE_CREATE is used as a mode
§Errors

See section EFI_FILE_PROTOCOL.Open() in the UEFI Specification for more details. Note that INVALID_PARAMETER is not listed in the specification as one of the errors returned by this function, but some implementations (such as EDK2) perform additional validation and may return that status for invalid inputs.

source

fn close(self)

Close this file handle. Same as dropping this structure.

source

fn delete(self) -> Result

Closes and deletes this file

§Warnings

See section EFI_FILE_PROTOCOL.Delete() in the UEFI Specification for more details.

source

fn get_info<'buf, Info: FileProtocolInfo + ?Sized>( &mut self, buffer: &'buf mut [u8] ) -> Result<&'buf mut Info, Option<usize>>

Queries some information about a file

The information will be written into a user-provided buffer. If the buffer is too small, the required buffer size will be returned as part of the error.

The buffer must be aligned on an <Info as Align>::alignment() boundary.

§Arguments
  • buffer Buffer that the information should be written into
§Errors

See section EFI_FILE_PROTOCOL.GetInfo() in the UEFI Specification for more details.

source

fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result

Sets some information about a file

There are various restrictions on the information that may be modified using this method. The simplest one is that it is usually not possible to call it on read-only media. Further restrictions specific to a given information type are described in the corresponding FileProtocolInfo type documentation.

§Arguments
  • info Info that should be set for the file
§Errors

See section EFI_FILE_PROTOCOL.SetInfo() in the UEFI Specification for more details.

source

fn flush(&mut self) -> Result

Flushes all modified data associated with the file handle to the device

§Errors

See section EFI_FILE_PROTOCOL.Flush() in the UEFI Specification for more details.

source

fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>( &mut self ) -> Result<Box<Info>>

Available on crate feature alloc only.

Read the dynamically allocated info for a file.

source

fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>( &mut self, allocator: A ) -> Result<Box<Info>>

Available on crate features unstable and alloc only.

Read the dynamically allocated info for a file.

Object Safety§

This trait is not object safe.

Implementors§