Trait vfs::file::File

source ·
pub trait File: Node {
Show 16 methods // Required methods fn open_file( &self, options: &FileOptions, ) -> impl Future<Output = Result<(), Status>> + Send; fn truncate( &self, length: u64, ) -> impl Future<Output = Result<(), Status>> + Send; fn get_backing_memory( &self, flags: VmoFlags, ) -> impl Future<Output = Result<Vmo, Status>> + Send; fn get_size(&self) -> impl Future<Output = Result<u64, Status>> + Send; fn update_attributes( &self, attributes: MutableNodeAttributes, ) -> impl Future<Output = Result<(), Status>> + Send; fn sync( &self, mode: SyncMode, ) -> impl Future<Output = Result<(), Status>> + Send; // Provided methods fn readable(&self) -> bool { ... } fn writable(&self) -> bool { ... } fn executable(&self) -> bool { ... } fn list_extended_attributes( &self, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Status>> + Send { ... } fn get_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<Vec<u8>, Status>> + Send { ... } fn set_extended_attribute( &self, _name: Vec<u8>, _value: Vec<u8>, _mode: SetExtendedAttributeMode, ) -> impl Future<Output = Result<(), Status>> + Send { ... } fn remove_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<(), Status>> + Send { ... } fn allocate( &self, _offset: u64, _length: u64, _mode: AllocateMode, ) -> impl Future<Output = Result<(), Status>> + Send { ... } fn enable_verity( &self, _options: VerificationOptions, ) -> impl Future<Output = Result<(), Status>> + Send { ... } fn event(&self) -> Result<Option<Event>, Status> { ... }
}
Expand description

Trait used for all files.

Required Methods§

source

fn open_file( &self, options: &FileOptions, ) -> impl Future<Output = Result<(), Status>> + Send

Called when the file is going to be accessed, typically by a new connection. Flags is the same as the flags passed to fidl_fuchsia_io.Node/Open. The following flags are handled by the connection and do not need to be handled inside open():

  • OPEN_FLAG_TRUNCATE - A call to truncate() will be made immediately after open().
  • OPEN_FLAG_DESCRIBE - The OnOpen event is sent before any other requests are received from the file’s client.
source

fn truncate( &self, length: u64, ) -> impl Future<Output = Result<(), Status>> + Send

Truncate the file to length. If there are pending attributes to update (see update_attributes), they should also be flushed at this time. Otherwise, no attributes should be updated, other than size as needed.

source

fn get_backing_memory( &self, flags: VmoFlags, ) -> impl Future<Output = Result<Vmo, Status>> + Send

Get a VMO representing this file. If not supported by the underlying filesystem, should return Err(NOT_SUPPORTED).

source

fn get_size(&self) -> impl Future<Output = Result<u64, Status>> + Send

Get the size of this file. This is used to calculate seek offset relative to the end.

source

fn update_attributes( &self, attributes: MutableNodeAttributes, ) -> impl Future<Output = Result<(), Status>> + Send

Set the mutable attributes of this file based on the values in attributes. If the file does not support updating all of the specified attributes, implementations should fail with ZX_ERR_NOT_SUPPORTED.

source

fn sync( &self, mode: SyncMode, ) -> impl Future<Output = Result<(), Status>> + Send

Sync this file’s contents to the storage medium (probably disk). This does not necessarily guarantee that the file will be completely written to disk once the call returns. It merely guarantees that any changes to the file have been propagated to the next layer in the storage stack.

Provided Methods§

source

fn readable(&self) -> bool

Capabilities:

source

fn writable(&self) -> bool

source

fn executable(&self) -> bool

source

fn list_extended_attributes( &self, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Status>> + Send

List this files extended attributes.

source

fn get_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<Vec<u8>, Status>> + Send

Get the value for an extended attribute.

source

fn set_extended_attribute( &self, _name: Vec<u8>, _value: Vec<u8>, _mode: SetExtendedAttributeMode, ) -> impl Future<Output = Result<(), Status>> + Send

Set the value for an extended attribute.

source

fn remove_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<(), Status>> + Send

Remove the value for an extended attribute.

source

fn allocate( &self, _offset: u64, _length: u64, _mode: AllocateMode, ) -> impl Future<Output = Result<(), Status>> + Send

Preallocate disk space for this range.

source

fn enable_verity( &self, _options: VerificationOptions, ) -> impl Future<Output = Result<(), Status>> + Send

Set the merkle tree and the descriptor for this file and mark the file as fsverity-enabled.

source

fn event(&self) -> Result<Option<Event>, Status>

Returns an optional event for the file which signals fuchsia.io2.FileSignal events to clients (e.g. when a file becomes readable). See fuchsia.io2.File.Describe.

Object Safety§

This trait is not object safe.

Implementors§