Struct flysystem::Filesystem

source ·
pub struct Filesystem<T: Adapter> { /* private fields */ }
Expand description

Abstraction over a filesystem.

Implementations§

source§

impl<T: Adapter> Filesystem<T>

source

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

Create a new filesystem instance.

Errors

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

source

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

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, T::Error>

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, T::Error>

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<C: AsRef<[u8]> + Send>( &mut self, path: &Path, contents: C ) -> Result<(), T::Error>

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, T::Error>

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<(), T::Error>

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<(), T::Error>

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<(), T::Error>

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>, T::Error>

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<(), T::Error>

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<(), T::Error>

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, T::Error>

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, T::Error>

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, T::Error>

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<(), T::Error>

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, T::Error>

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, T::Error>

Get the checksum of the file.

Errors

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

source§

impl<T: Adapter + PublicUrlGenerator> Filesystem<T>

source

pub async fn public_url( &self, path: &Path ) -> Result<String, <T as PublicUrlGenerator>::Error>

Get the public URL of the file.

Errors

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

source§

impl<T: Adapter + TemporaryUrlGenerator> Filesystem<T>

source

pub async fn temporary_url( &self, path: &Path, expires_in: Duration ) -> Result<String, <T as TemporaryUrlGenerator>::Error>

Get a temporary URL of the file.

Errors

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

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Filesystem<T>
where T: RefUnwindSafe,

§

impl<T> Send for Filesystem<T>

§

impl<T> Sync for Filesystem<T>

§

impl<T> Unpin for Filesystem<T>
where T: Unpin,

§

impl<T> UnwindSafe for Filesystem<T>
where T: UnwindSafe,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more