pub struct DiskDriver { /* private fields */ }Expand description
The DiskDriver struct represents a disk-based implementation of the
Driver trait.
It provides methods for interacting with files and directories on the disk.
Implementations§
Source§impl DiskDriver
impl DiskDriver
Sourcepub async fn new(config: Config) -> DriverResult<Self>
pub async fn new(config: Config) -> DriverResult<Self>
Initializes a new DiskDriver instance with the specified
configuration.
If the specified location does not exist, it creates the necessary directories.
§Errors
Returns an error if the initialization fails, such as being unable to create the required directories.
Trait Implementations§
Source§impl Clone for DiskDriver
impl Clone for DiskDriver
Source§fn clone(&self) -> DiskDriver
fn clone(&self) -> DiskDriver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Driver for DiskDriver
impl Driver for DiskDriver
Source§fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads the contents of a file at the specified path within the disk-based storage.
§Errors
Returns an error if there is an issue reading from the file or decoding its contents.
Source§fn file_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn file_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Checks if a file exists at the specified path within the disk-based storage.
If the path does not point to a file, the method returns Ok(false).
Otherwise, it checks if the file exists and returns the result.
§Errors
Returns an error if there is an issue checking the existence of the file.
Source§fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
content: Vec<u8>,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
content: Vec<u8>,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes the provided content to a file at the specified path within the disk-based storage.
If the directory structure leading to the file does not exist, it creates the necessary directories.
§Errors
Returns an error if there is any issue creating directories, writing to the file, or handling other I/O-related errors.
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes the file at the specified path within the disk-based storage.
§Errors
Returns an error if the file does not exist or if there is any issue deleting the file.
If the file does not exist, the error variant
DriverError::ResourceNotFound is returned.
Source§fn delete_directory<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_directory<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes the directory and its contents at the specified path within the disk-based storage.
§Errors
Returns an error if the directory does not exist or if there is any issue deleting the directory.
If the directory does not exist, the error variant
DriverError::DirectoryNotFound is returned.
Source§fn last_modified<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<SystemTime>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn last_modified<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = DriverResult<SystemTime>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves the last modification time of the file at the specified path within the disk-based storage. # Errors
Returns an error if the file does not exist or if there is any issue retrieving the last modification time.
If the file does not exist, the error variant
DriverError::ResourceNotFound is returned.