Struct flysystem::Filesystem
source · pub struct Filesystem<T: Adapter> { /* private fields */ }Expand description
Abstraction over a filesystem.
Implementations§
source§impl<T: Adapter> Filesystem<T>
impl<T: Adapter> Filesystem<T>
sourcepub async fn new(config: T::Config) -> Result<Self, T::Error>
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.
sourcepub async fn file_exists(&self, path: &Path) -> Result<bool, T::Error>
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.
sourcepub async fn directory_exists(&self, path: &Path) -> Result<bool, T::Error>
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.
sourcepub async fn has(&self, path: &Path) -> Result<bool, T::Error>
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.
sourcepub async fn write<C: AsRef<[u8]> + Send>(
&mut self,
path: &Path,
contents: C
) -> Result<(), T::Error>
pub async fn write<C: AsRef<[u8]> + Send>( &mut self, path: &Path, contents: C ) -> Result<(), T::Error>
sourcepub async fn read<R: TryFrom<Contents>>(
&mut self,
path: &Path
) -> Result<R, T::Error>
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.
sourcepub async fn delete(&mut self, path: &Path) -> Result<(), T::Error>
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.
sourcepub async fn delete_directory(&mut self, path: &Path) -> Result<(), T::Error>
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.
sourcepub async fn create_directory(&mut self, path: &Path) -> Result<(), T::Error>
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.
sourcepub async fn list_contents(
&self,
path: &Path,
deep: bool
) -> Result<Vec<PathBuf>, T::Error>
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.
sourcepub async fn last_modified(&self, path: &Path) -> Result<SystemTime, T::Error>
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.
sourcepub async fn file_size(&self, path: &Path) -> Result<u64, T::Error>
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.
sourcepub async fn mime_type(&self, path: &Path) -> Result<Mime, T::Error>
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.
sourcepub async fn set_visibility(
&mut self,
path: &Path,
visibility: Visibility
) -> Result<(), T::Error>
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.
sourcepub async fn visibility(&self, path: &Path) -> Result<Visibility, T::Error>
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§impl<T: Adapter + PublicUrlGenerator> Filesystem<T>
impl<T: Adapter + PublicUrlGenerator> Filesystem<T>
sourcepub async fn public_url(
&self,
path: &Path
) -> Result<String, <T as PublicUrlGenerator>::Error>
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>
impl<T: Adapter + TemporaryUrlGenerator> Filesystem<T>
sourcepub async fn temporary_url(
&self,
path: &Path,
expires_in: Duration
) -> Result<String, <T as TemporaryUrlGenerator>::Error>
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.