Struct oc_wasm_opencomputers::filesystem::Locked
source · [−]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
sourceimpl<'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
BadComponentStorageReadOnlyis returned if this filesystem has a label that cannot be changed.Unsupportedis 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 size(&mut self, path: &str) -> Result<u64, Error>
pub async fn size(&mut self, path: &str) -> Result<u64, Error>
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
BadComponentBadFilenameFailedis 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
BadComponentBadFilenameFailedis 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
BadComponentBadFilenameFailedis 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
BadComponentis returned if the filesystem does not exist, is inaccessible, or is not a filesystem.TooManyDescriptorsFailedis returned if the path is a directory, the parent of the path is not a directory, or the filesystem is read-only.
Auto Trait Implementations
impl<'invoker, 'buffer, B> RefUnwindSafe for Locked<'invoker, 'buffer, B> where
B: RefUnwindSafe,
impl<'invoker, 'buffer, B> Send for Locked<'invoker, 'buffer, B> where
B: Send,
impl<'invoker, 'buffer, B> Sync for Locked<'invoker, 'buffer, B> where
B: Sync,
impl<'invoker, 'buffer, B> Unpin for Locked<'invoker, 'buffer, B>
impl<'invoker, 'buffer, B> !UnwindSafe for Locked<'invoker, 'buffer, B>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more