pub trait StorageBackend {
// Required methods
fn create_named(
&self,
name: &Path,
) -> Result<Box<dyn FileWriter>, StorageError>;
fn open(&self, name: &Path) -> Result<Arc<dyn FileReader>, StorageError>;
// Provided methods
fn create(&self) -> Result<Box<dyn FileWriter>, StorageError> { ... }
fn create_with_prefix(
&self,
prefix: &str,
) -> Result<Box<dyn FileWriter>, StorageError> { ... }
}Expand description
A storage backend.
Required Methods§
Sourcefn create_named(&self, name: &Path) -> Result<Box<dyn FileWriter>, StorageError>
fn create_named(&self, name: &Path) -> Result<Box<dyn FileWriter>, StorageError>
Create a new file with the given name, which is relative to the
backend’s base directory.
Sourcefn open(&self, name: &Path) -> Result<Arc<dyn FileReader>, StorageError>
fn open(&self, name: &Path) -> Result<Arc<dyn FileReader>, StorageError>
Opens a file for reading. The file name is relative to the base of
the storage backend.
Provided Methods§
Sourcefn create(&self) -> Result<Box<dyn FileWriter>, StorageError>
fn create(&self) -> Result<Box<dyn FileWriter>, StorageError>
Creates a new persistent file used for writing data. The backend selects a name.
Sourcefn create_with_prefix(
&self,
prefix: &str,
) -> Result<Box<dyn FileWriter>, StorageError>
fn create_with_prefix( &self, prefix: &str, ) -> Result<Box<dyn FileWriter>, StorageError>
Creates a new persistent file used for writing data, giving the file’s
name the specified prefix. See also create.
Implementations§
Source§impl dyn StorageBackend
impl dyn StorageBackend
Sourcepub fn new(
config: &StorageConfig,
options: &StorageOptions,
) -> Result<Rc<Self>, StorageError>
pub fn new( config: &StorageConfig, options: &StorageOptions, ) -> Result<Rc<Self>, StorageError>
Creates and returns a new backend configured according to config and options.