Trait StoreFile

Source
pub trait StoreFile {
    type FileReader: StoreFileReader;
    type FileWriter: StoreFileWriter;
    type Metadata: StoreMetadata;

    // Required methods
    fn filename(&self) -> Option<Cow<'_, str>>;
    fn exists(&self) -> impl Future<Output = Result<bool>>;
    fn metadata(&self) -> impl Future<Output = Result<Self::Metadata>>;
    fn read<R: RangeBounds<u64>>(
        &self,
        range: R,
    ) -> impl Future<Output = Result<Self::FileReader>>;
    fn write(
        &self,
        options: WriteOptions,
    ) -> impl Future<Output = Result<Self::FileWriter>>;
}
Expand description

Trait representing a file in the storage system.

Required Associated Types§

Source

type FileReader: StoreFileReader

Associated type for the reader that reads the file’s content.

Source

type FileWriter: StoreFileWriter

Associated type for the reader that reads the file’s content.

Source

type Metadata: StoreMetadata

Associated type for the metadata associated with the file.

Required Methods§

Source

fn filename(&self) -> Option<Cow<'_, str>>

Returns the file’s name if it exists.

This method returns an Option containing the file’s name.

Source

fn exists(&self) -> impl Future<Output = Result<bool>>

Checks if the file exists.

Returns a future that resolves to true if the file exists, otherwise false.

Source

fn metadata(&self) -> impl Future<Output = Result<Self::Metadata>>

Retrieves the metadata of the file.

Returns a future that resolves to the file’s metadata (size, creation time, etc.).

Source

fn read<R: RangeBounds<u64>>( &self, range: R, ) -> impl Future<Output = Result<Self::FileReader>>

Reads a portion of the file’s content, specified by a byte range.

Returns a future that resolves to a reader that can read the specified range of the file.

Source

fn write( &self, options: WriteOptions, ) -> impl Future<Output = Result<Self::FileWriter>>

Creates a writer

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§