pub struct Filesystem { /* private fields */ }Expand description
Abstraction over a filesystem.
Implementations§
source§impl Filesystem
impl Filesystem
pub async fn new<T: AdapterInit>(config: T::Config) -> Result<Self, T::Error>
sourcepub fn from_adapter<T: Adapter + 'static>(adapter: T) -> Self
pub fn from_adapter<T: Adapter + 'static>(adapter: T) -> Self
Create a new filesystem instance.
sourcepub async fn file_exists(&self, path: &Path) -> Result<bool>
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.
sourcepub async fn directory_exists(&self, path: &Path) -> Result<bool>
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.
sourcepub async fn has(&self, path: &Path) -> Result<bool>
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.
sourcepub async fn read<R: TryFrom<Contents>>(&mut self, path: &Path) -> Result<R>
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.
sourcepub async fn delete(&mut self, path: &Path) -> Result<()>
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.
sourcepub async fn delete_directory(&mut self, path: &Path) -> Result<()>
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.
sourcepub async fn create_directory(&mut self, path: &Path) -> Result<()>
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.
sourcepub async fn list_contents(
&self,
path: &Path,
deep: bool,
) -> Result<Vec<PathBuf>>
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.
sourcepub async fn last_modified(&self, path: &Path) -> Result<SystemTime>
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.
sourcepub async fn file_size(&self, path: &Path) -> Result<u64>
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.
sourcepub async fn mime_type(&self, path: &Path) -> Result<Mime>
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.
sourcepub async fn set_visibility(
&mut self,
path: &Path,
visibility: Visibility,
) -> Result<()>
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.
sourcepub async fn visibility(&self, path: &Path) -> Result<Visibility>
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.