Struct 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§

Source§

impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>

Source

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
Source

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
Source

pub async fn is_read_only(&mut self) -> Result<bool, Error>

Returns whether the filesystem is read-only.

§Errors
Source

pub async fn get_space_total(&mut self) -> Result<u64, Error>

Returns the total capacity of the filesystem, in bytes.

§Errors
Source

pub async fn get_space_used(&mut self) -> Result<u64, Error>

Returns the size of all files the filesystem, in bytes.

§Errors
Source

pub async fn exists(&mut self, path: &str) -> Result<bool, Error>

Returns whether a file or directory of the given name exists.

§Errors
Source

pub async fn size(&mut self, path: &str) -> Result<u64, Error>

Returns the size of a file.

If the path does not exist or is a directory, zero is returned.

§Errors
Source

pub async fn is_directory(&mut self, path: &str) -> Result<bool, Error>

Returns whether a path refers to an existing directory.

§Errors
Source

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
Source

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
Source

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).
Source

pub async fn remove(&mut self, path: &str) -> Result<(), Error>

Removes a file or directory and its contents.

§Errors
Source

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).
Source

pub async fn open_read(&mut self, path: &str) -> Result<ReadHandle, Error>

Opens a file in read mode.

§Errors
Source

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.

Auto Trait Implementations§

§

impl<'invoker, 'buffer, B> Freeze for Locked<'invoker, 'buffer, B>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.