DiskDriver

Struct DiskDriver 

Source
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

Source

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

Source§

fn clone(&self) -> DiskDriver

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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,

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,

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,

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,

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,

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,

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.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.