pub struct Locked<'invoker, 'buffer, B: Buffer> { /* private fields */ }
Expand description
A filesystem component on which methods can be invoked.
This type combines a filesystem address, an Invoker
that can be used to make method calls,
and a scratch buffer used to perform CBOR encoding and decoding. A value of this type can be
created by calling Filesystem::lock
, and it can be dropped to return the borrow of the
invoker and buffer to the caller so they can be reused for other purposes.
The 'invoker
lifetime is the lifetime of the invoker. The 'buffer
lifetime is the lifetime
of the buffer. The B
type is the type of scratch buffer to use.
Implementations§
Source§impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
Sourcepub async fn get_label(self) -> Result<Option<&'buffer str>, Error>
pub async fn get_label(self) -> Result<Option<&'buffer str>, Error>
Returns the filesystem’s label, if it has one.
The returned string slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
Sourcepub async fn set_label(
self,
label: Option<&str>,
) -> Result<Option<&'buffer str>, Error>
pub async fn set_label( self, label: Option<&str>, ) -> Result<Option<&'buffer str>, Error>
Sets or clears the filesystem’s label and returns the new label, which may be truncated.
The returned string slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
BadComponent
StorageReadOnly
is returned if this filesystem has a label that cannot be changed.TooManyDescriptors
Unsupported
is returned if this filesystem does not support labels.
Sourcepub async fn is_read_only(&mut self) -> Result<bool, Error>
pub async fn is_read_only(&mut self) -> Result<bool, Error>
Sourcepub async fn get_space_total(&mut self) -> Result<u64, Error>
pub async fn get_space_total(&mut self) -> Result<u64, Error>
Sourcepub async fn get_space_used(&mut self) -> Result<u64, Error>
pub async fn get_space_used(&mut self) -> Result<u64, Error>
Sourcepub async fn exists(&mut self, path: &str) -> Result<bool, Error>
pub async fn exists(&mut self, path: &str) -> Result<bool, Error>
Returns whether a file or directory of the given name exists.
§Errors
Sourcepub async fn size(&mut self, path: &str) -> Result<u64, Error>
pub async fn size(&mut self, path: &str) -> Result<u64, Error>
Sourcepub async fn is_directory(&mut self, path: &str) -> Result<bool, Error>
pub async fn is_directory(&mut self, path: &str) -> Result<bool, Error>
Returns whether a path refers to an existing directory.
§Errors
Sourcepub async fn last_modified(&mut self, path: &str) -> Result<u64, Error>
pub async fn last_modified(&mut self, path: &str) -> Result<u64, Error>
Returns the last modification time of a file, or the creation time of a directory, in milliseconds since the UNIX epoch.
If the path does not exist, zero is returned. Zero may also be returned on certain filesystems which do not track modification times, such as virtual filesystems.
§Errors
Sourcepub async fn list(
self,
path: &str,
) -> Result<Vec<DirectoryEntry<'buffer>>, Error>
pub async fn list( self, path: &str, ) -> Result<Vec<DirectoryEntry<'buffer>>, Error>
Returns the objects contained within a directory.
If the name refers to a file rather than a directory, a single entry is returned specifying the file itself.
The returned string slices point into, and therefore retain ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
Sourcepub async fn make_directory(&mut self, path: &str) -> Result<(), Error>
pub async fn make_directory(&mut self, path: &str) -> Result<(), Error>
Creates a directory and, if missing, its parents.
§Errors
BadComponent
BadFilename
TooManyDescriptors
Failed
is returned if the target directory already exists, or if a directory on the path cannot be created (typically due to lack of space, an intermediate path component being an existing file, or the filesystem being read-only).
Sourcepub async fn remove(&mut self, path: &str) -> Result<(), Error>
pub async fn remove(&mut self, path: &str) -> Result<(), Error>
Removes a file or directory and its contents.
§Errors
BadComponent
BadFilename
TooManyDescriptors
Failed
is returned if the removal fails (typically due to the path not existing or the filesystem being read-only).
Sourcepub async fn rename(
&mut self,
source: &str,
destination: &str,
) -> Result<(), Error>
pub async fn rename( &mut self, source: &str, destination: &str, ) -> Result<(), Error>
Renames a file or directory.
§Errors
BadComponent
BadFilename
TooManyDescriptors
Failed
is returned if the rename fails (typically due to the source path not existing, the destination path existing and being of a different type than the source, the destination being a non-empty directory, or the filesystem being read-only).
Sourcepub async fn open_write(
&mut self,
path: &str,
mode: WriteMode,
) -> Result<WriteHandle, Error>
pub async fn open_write( &mut self, path: &str, mode: WriteMode, ) -> Result<WriteHandle, Error>
Opens a file in write mode.
§Errors
BadComponent
is returned if the filesystem does not exist, is inaccessible, or is not a filesystem.TooManyDescriptors
Failed
is returned if the path is a directory, the parent of the path is not a directory, or the filesystem is read-only.