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§
sourcefn open_file(
&self,
options: &FileOptions,
) -> impl Future<Output = Result<(), Status>> + Send
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.
sourcefn truncate(
&self,
length: u64,
) -> impl Future<Output = Result<(), Status>> + Send
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.
sourcefn get_backing_memory(
&self,
flags: VmoFlags,
) -> impl Future<Output = Result<Vmo, Status>> + Send
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).
sourcefn get_size(&self) -> impl Future<Output = Result<u64, Status>> + Send
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.
sourcefn update_attributes(
&self,
attributes: MutableNodeAttributes,
) -> impl Future<Output = Result<(), Status>> + Send
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
.
sourcefn sync(
&self,
mode: SyncMode,
) -> impl Future<Output = Result<(), Status>> + Send
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§
fn writable(&self) -> bool
fn executable(&self) -> bool
sourcefn list_extended_attributes(
&self,
) -> impl Future<Output = Result<Vec<Vec<u8>>, Status>> + Send
fn list_extended_attributes( &self, ) -> impl Future<Output = Result<Vec<Vec<u8>>, Status>> + Send
List this files extended attributes.
sourcefn get_extended_attribute(
&self,
_name: Vec<u8>,
) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
fn get_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<Vec<u8>, Status>> + Send
Get the value for an extended attribute.
sourcefn set_extended_attribute(
&self,
_name: Vec<u8>,
_value: Vec<u8>,
_mode: SetExtendedAttributeMode,
) -> impl Future<Output = Result<(), Status>> + Send
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.
sourcefn remove_extended_attribute(
&self,
_name: Vec<u8>,
) -> impl Future<Output = Result<(), Status>> + Send
fn remove_extended_attribute( &self, _name: Vec<u8>, ) -> impl Future<Output = Result<(), Status>> + Send
Remove the value for an extended attribute.
sourcefn allocate(
&self,
_offset: u64,
_length: u64,
_mode: AllocateMode,
) -> impl Future<Output = Result<(), Status>> + Send
fn allocate( &self, _offset: u64, _length: u64, _mode: AllocateMode, ) -> impl Future<Output = Result<(), Status>> + Send
Preallocate disk space for this range.
sourcefn enable_verity(
&self,
_options: VerificationOptions,
) -> impl Future<Output = Result<(), Status>> + Send
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.