pub struct FxFile { /* private fields */ }Expand description
FxFile represents an open connection to a file.
Implementations§
Source§impl FxFile
impl FxFile
Sourcepub async fn create_connection_async(
this: OpenedNode<FxFile>,
scope: ExecutionScope,
flags: impl ProtocolsExt,
object_request: ObjectRequestRef<'_>,
) -> Result<(), Status>
pub async fn create_connection_async( this: OpenedNode<FxFile>, scope: ExecutionScope, flags: impl ProtocolsExt, object_request: ObjectRequestRef<'_>, ) -> Result<(), Status>
Creates a new connection on the given scope. May take a read lock on the object.
Sourcepub fn open_as_temporary(self: Arc<Self>) -> OpenedNode<dyn FxNode>
pub fn open_as_temporary(self: Arc<Self>) -> OpenedNode<dyn FxNode>
Open the file as a temporary. The file must have just been created with no other open counts.
Sourcepub fn mark_as_permanent(&self)
pub fn mark_as_permanent(&self)
Mark the state as permanent (to be used when the file is currently marked as temporary).
pub fn is_verified_file(&self) -> bool
pub fn handle(&self) -> &PagedObjectHandle
Sourcepub fn into_opened_node(self: Arc<Self>) -> Option<OpenedNode<FxFile>>
pub fn into_opened_node(self: Arc<Self>) -> Option<OpenedNode<FxFile>>
If this instance has not been marked to be purged, returns an OpenedNode instance. If marked for purging, returns None.
Sourcepub async fn flush(
this: &OpenedNode<FxFile>,
flush_type: FlushType,
) -> Result<(), Error>
pub async fn flush( this: &OpenedNode<FxFile>, flush_type: FlushType, ) -> Result<(), Error>
Persists any unflushed data to disk.
Flush may be triggered as a background task so this requires an OpenedNode to
ensure that we don’t accidentally try to flush a file handle that is in the process of
being removed. (See use of cache in FxVolume::flush_all_files.)
pub fn get_block_size(&self) -> u64
pub async fn is_allocated( &self, start_offset: u64, ) -> Result<(bool, u64), Status>
pub async fn write_at_uncached( &self, offset: u64, content: &[u8], ) -> Result<u64, Status>
pub async fn read_at_uncached( &self, offset: u64, buffer: &mut [u8], ) -> Result<u64, Status>
pub fn get_size_uncached(&self) -> u64
Sourcepub fn force_clean(&self)
pub fn force_clean(&self)
Forcibly marks the file as clean.
Trait Implementations§
Source§impl File for FxFile
impl File for FxFile
fn writable(&self) -> bool
Source§async fn open_file(&self, _options: &FileOptions) -> Result<(), Status>
async fn open_file(&self, _options: &FileOptions) -> Result<(), Status>
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(): Read moreSource§async fn truncate(&self, length: u64) -> Result<(), Status>
async fn truncate(&self, length: u64) -> Result<(), Status>
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§async fn enable_verity(
&self,
options: VerificationOptions,
) -> Result<(), Status>
async fn enable_verity( &self, options: VerificationOptions, ) -> Result<(), Status>
Set the merkle tree and the descriptor for this file and mark the file as fsverity-enabled.
Source§async fn get_backing_memory(&self, flags: VmoFlags) -> Result<Vmo, Status>
async fn get_backing_memory(&self, flags: VmoFlags) -> Result<Vmo, Status>
Get a VMO representing this file.
If not supported by the underlying filesystem, should return Err(NOT_SUPPORTED).
Source§async fn get_size(&self) -> Result<u64, Status>
async fn get_size(&self) -> Result<u64, Status>
Get the size of this file.
This is used to calculate seek offset relative to the end.
Source§async fn update_attributes(
&self,
attributes: MutableNodeAttributes,
) -> Result<(), Status>
async fn update_attributes( &self, attributes: MutableNodeAttributes, ) -> Result<(), Status>
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§async fn allocate(
&self,
offset: u64,
length: u64,
_mode: AllocateMode,
) -> Result<(), Status>
async fn allocate( &self, offset: u64, length: u64, _mode: AllocateMode, ) -> Result<(), Status>
Preallocate disk space for this range.
Source§async fn sync(&self, mode: SyncMode) -> Result<(), Status>
async fn sync(&self, mode: SyncMode) -> Result<(), Status>
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.
fn executable(&self) -> bool
Source§impl FxNode for FxFile
impl FxNode for FxFile
fn object_id(&self) -> u64
fn parent(&self) -> Option<Arc<FxDirectory>>
fn set_parent(&self, _parent: Arc<FxDirectory>)
fn open_count_add_one(&self)
Source§fn open_count_sub_one(self: Arc<Self>)
fn open_count_sub_one(self: Arc<Self>)
Atomically check if this brought the count to zero while the node is
marked for purge. If so, this must queue the node for tombstone the node.
fn object_descriptor(&self) -> ObjectDescriptor
Source§fn terminate(&self)
fn terminate(&self)
Called when the filesystem is shutting down. Implementations should break any strong
reference cycles that would prevent the node from being dropped.
Source§fn mark_to_be_purged(self: Arc<Self>)
fn mark_to_be_purged(self: Arc<Self>)
Marks the object to be purged. Queues the node for tombstone if open count is zero.
Source§impl GetEntryInfo for FxFile
impl GetEntryInfo for FxFile
Source§fn entry_info(&self) -> EntryInfo
fn entry_info(&self) -> EntryInfo
This method is used to populate ReadDirents() output.
Source§impl Node for FxFile
impl Node for FxFile
Source§async fn get_attributes(
&self,
requested_attributes: NodeAttributesQuery,
) -> Result<NodeAttributes2, Status>
async fn get_attributes( &self, requested_attributes: NodeAttributesQuery, ) -> Result<NodeAttributes2, Status>
Returns node attributes (io2).
Source§fn will_clone(&self)
fn will_clone(&self)
Called when the node is about to be cloned (and also by the default implementation of
will_open_as_node). Implementations that perform their own open count can use this. Each
call to
will_clone will be accompanied by an eventual call to close.async fn link_into( self: Arc<Self>, destination_dir: Arc<dyn MutableDirectory>, name: Name, ) -> Result<(), Status>
Source§fn query_filesystem(&self) -> Result<FilesystemInfo, Status>
fn query_filesystem(&self) -> Result<FilesystemInfo, Status>
Returns information about the filesystem and/or volume.
Source§async fn list_extended_attributes(&self) -> Result<Vec<Vec<u8>>, Status>
async fn list_extended_attributes(&self) -> Result<Vec<Vec<u8>>, Status>
List extended attributes.
Source§async fn get_extended_attribute(&self, name: Vec<u8>) -> Result<Vec<u8>, Status>
async fn get_extended_attribute(&self, name: Vec<u8>) -> Result<Vec<u8>, Status>
Get the value for an extended attribute.
Source§async fn set_extended_attribute(
&self,
name: Vec<u8>,
value: Vec<u8>,
mode: SetExtendedAttributeMode,
) -> Result<(), Status>
async fn set_extended_attribute( &self, name: Vec<u8>, value: Vec<u8>, mode: SetExtendedAttributeMode, ) -> Result<(), Status>
Set the value for an extended attribute.
Source§async fn remove_extended_attribute(&self, name: Vec<u8>) -> Result<(), Status>
async fn remove_extended_attribute(&self, name: Vec<u8>) -> Result<(), Status>
Remove the value for an extended attribute.
Source§fn will_open_as_node(&self) -> Result<(), Status>
fn will_open_as_node(&self) -> Result<(), Status>
Called when the node is about to be opened as the node protocol. Implementers can use this
to perform any initialization or reference counting. Errors here will result in the open
failing. By default, this forwards to the infallible will_clone.
Source§fn open_as_node(
self: Arc<Self>,
scope: ExecutionScope,
options: NodeOptions,
object_request: &mut ObjectRequest,
) -> Result<(), Status>where
Self: Sized,
fn open_as_node(
self: Arc<Self>,
scope: ExecutionScope,
options: NodeOptions,
object_request: &mut ObjectRequest,
) -> Result<(), Status>where
Self: Sized,
Opens the node using the node protocol.
Source§impl PagerBacked for FxFile
impl PagerBacked for FxFile
Source§fn pager_packet_receiver_registration(
&self,
) -> &PagerPacketReceiverRegistration<Self>
fn pager_packet_receiver_registration( &self, ) -> &PagerPacketReceiverRegistration<Self>
The receiver registration returned from
Pager::create_vmo.Source§fn vmo(&self) -> &Vmo
fn vmo(&self) -> &Vmo
The pager backed VMO that this object is handling packets for. The VMO must be created with
Pager::create_vmo.Source§fn page_in(self: Arc<Self>, range: PageInRange<Self>)
fn page_in(self: Arc<Self>, range: PageInRange<Self>)
Called by the pager when a
ZX_PAGER_VMO_READ packet is received for the VMO. The
implementation must respond by calling either PageInRange::supply_pages or
PageInRange::report_failure.Source§fn mark_dirty(self: Arc<Self>, range: MarkDirtyRange<Self>)
fn mark_dirty(self: Arc<Self>, range: MarkDirtyRange<Self>)
Called by the pager when a
ZX_PAGER_VMO_DIRTY packet is received for the VMO. The
implementation must respond by calling either MarkDirtyRange::dirty_pages or
MarkDirtyRange::report_failure.Source§fn on_zero_children(self: Arc<Self>)
fn on_zero_children(self: Arc<Self>)
Called by the pager to indicate there are no more VMO children.
Source§fn byte_size(&self) -> u64
fn byte_size(&self) -> u64
Total bytes readable. Anything reads over this will be zero padded in the VMO.
Source§async fn aligned_read(&self, range: Range<u64>) -> Result<Buffer<'_>, Error>
async fn aligned_read(&self, range: Range<u64>) -> Result<Buffer<'_>, Error>
Reads one or more blocks into a buffer and returns it. This method is called by
default_page_in and aligned_byte_range will always be aligned to the read_ahead_size
past to default_page_in unless that would extend beyond self.byte_size(), in which case,
aligned_byte_range will end at self.byte_size()’s next page multiple. The returned
buffer must be at least as large as the requested range. Only the requested range will be
supplied to the pager.Source§impl ToWeakNode for FxFile
impl ToWeakNode for FxFile
fn to_weak_node(self: Arc<Self>) -> WeakNode
Auto Trait Implementations§
impl !Freeze for FxFile
impl !RefUnwindSafe for FxFile
impl Send for FxFile
impl Sync for FxFile
impl Unpin for FxFile
impl UnsafeUnpin for FxFile
impl !UnwindSafe for FxFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
Converts the given service transport handle of type
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more