Trait StorageBackend

Source
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§

Source

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.

Source

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§

Source

fn create(&self) -> Result<Box<dyn FileWriter>, StorageError>

Creates a new persistent file used for writing data. The backend selects a name.

Source

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

Source

pub fn new( config: &StorageConfig, options: &StorageOptions, ) -> Result<Rc<Self>, StorageError>

Creates and returns a new backend configured according to config and options.

Implementors§