pub trait StoreFile {
type FileReader: StoreFileReader;
type FileWriter: StoreFileWriter;
type Metadata: StoreMetadata;
// Required methods
fn path(&self) -> &Path;
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>>;
fn delete(&self) -> impl Future<Output = Result<()>>;
// Provided method
fn filename(&self) -> Option<Cow<'_, str>> { ... }
}
Expand description
Trait representing a file in the storage system.
Required Associated Types§
Sourcetype FileReader: StoreFileReader
type FileReader: StoreFileReader
Associated type for the reader that reads the file’s content.
Sourcetype FileWriter: StoreFileWriter
type FileWriter: StoreFileWriter
Associated type for the reader that reads the file’s content.
Sourcetype Metadata: StoreMetadata
type Metadata: StoreMetadata
Associated type for the metadata associated with the file.
Required Methods§
Sourcefn exists(&self) -> impl Future<Output = Result<bool>>
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
.
Sourcefn metadata(&self) -> impl Future<Output = Result<Self::Metadata>>
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.).
Sourcefn read<R: RangeBounds<u64>>(
&self,
range: R,
) -> impl Future<Output = Result<Self::FileReader>>
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.
Sourcefn write(
&self,
options: WriteOptions,
) -> impl Future<Output = Result<Self::FileWriter>>
fn write( &self, options: WriteOptions, ) -> impl Future<Output = Result<Self::FileWriter>>
Creates a writer
Provided Methods§
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.