Filesystem

Struct Filesystem 

Source
pub struct Filesystem { /* private fields */ }
Expand description

Abstraction over a filesystem.

Implementations§

Source§

impl Filesystem

Source

pub async fn new<T: AdapterInit>(config: T::Config) -> Result<Self, T::Error>

Source

pub fn from_adapter<T: Adapter + 'static>(adapter: T) -> Self

Create a new filesystem instance.

Source

pub async fn file_exists(&self, path: &Path) -> Result<bool>

Check if a file exists.

§Errors

This function will return an error if the adapter fails to check if the file exists.

Source

pub async fn directory_exists(&self, path: &Path) -> Result<bool>

Check if a directory exists.

§Errors

This function will return an error if the adapter fails to check if the directory exists.

Source

pub async fn has(&self, path: &Path) -> Result<bool>

Check if a file or directory exists.

§Errors

This function will return an error if the adapter fails to check if the file or directory exists.

Source

pub async fn write(&mut self, path: &Path, contents: &[u8]) -> Result<()>

Write a file.

§Errors

This function will return an error if the adapter fails to write the file.

Source

pub async fn read<R: TryFrom<Contents>>(&mut self, path: &Path) -> Result<R>

Get the contents of a file.

§Errors

This function will return an error if the adapter fails to read the file.

Source

pub async fn delete(&mut self, path: &Path) -> Result<()>

Delete a file.

§Errors

This function will return an error if the adapter fails to delete the file or directory.

Source

pub async fn delete_directory(&mut self, path: &Path) -> Result<()>

Delete a directory.

§Errors

This function will return an error if the adapter fails to delete the directory.

Source

pub async fn create_directory(&mut self, path: &Path) -> Result<()>

Create a directory.

§Errors

This function will return an error if the adapter fails to create the directory.

Source

pub async fn list_contents( &self, path: &Path, deep: bool, ) -> Result<Vec<PathBuf>>

Get a list of files in a directory (optionally recursively).

§Errors

This function will return an error if the adapter fails to list the contents of the directory.

Source

pub async fn move(&mut self, source: &Path, destination: &Path) -> Result<()>

Move a file.

§Errors

This function will return an error if the adapter fails to move the file.

Source

pub async fn copy(&mut self, source: &Path, destination: &Path) -> Result<()>

Copy a file.

§Errors

This function will return an error if the adapter fails to copy the file.

Source

pub async fn last_modified(&self, path: &Path) -> Result<SystemTime>

Get the date and time the file was last modified at.

§Errors

This function will return an error if the adapter fails to get the last modified date and time.

Source

pub async fn file_size(&self, path: &Path) -> Result<u64>

Get the size of the file.

§Errors

This function will return an error if the adapter fails to get the file size.

Source

pub async fn mime_type(&self, path: &Path) -> Result<Mime>

Get the mime type of the file.

§Errors

This function will return an error if the adapter fails to get the mime type.

Source

pub async fn set_visibility( &mut self, path: &Path, visibility: Visibility, ) -> Result<()>

Set the visibility of the file.

§Errors

This function will return an error if the adapter fails to set the visibility.

Source

pub async fn visibility(&self, path: &Path) -> Result<Visibility>

Get the visibility of the file.

§Errors

This function will return an error if the adapter fails to get the visibility.

Source

pub async fn checksum(&self, path: &Path) -> Result<String>

Get the checksum of the file.

§Errors

This function will return an error if the adapter fails to get the checksum.

Trait Implementations§

Source§

impl Debug for Filesystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,