StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Send
    + Sized
    + Sync
    + 'static {
    type ConfigBuilder: Default + DeserializeOwned + Into<Self::Config>;
    type Config: Clone + Send + Sync;
    type Error: Error + Send;

    // Required methods
    fn start(config: Self::Config) -> Result<Self, Self::Error>;
    fn shutdown(self) -> Result<(), Self::Error>;
    fn size(&self) -> Result<Option<usize>, Self::Error>;
    fn get_health(&self) -> Result<Option<StorageHealth>, Self::Error>;
    fn set_health(&self, health: StorageHealth) -> Result<(), Self::Error>;
}
Expand description

Trait to be implemented on a storage backend. Determines how to start and shutdown the backend.

Required Associated Types§

Source

type ConfigBuilder: Default + DeserializeOwned + Into<Self::Config>

Helps build the associated Config.

Source

type Config: Clone + Send + Sync

Holds the backend options.

Source

type Error: Error + Send

Returned on failed operations.

Required Methods§

Source

fn start(config: Self::Config) -> Result<Self, Self::Error>

Initializes and starts the backend.

Source

fn shutdown(self) -> Result<(), Self::Error>

Shutdowns the backend.

Source

fn size(&self) -> Result<Option<usize>, Self::Error>

Returns the size of the database in bytes. Not all backends may be able to provide this operation.

Source

fn get_health(&self) -> Result<Option<StorageHealth>, Self::Error>

Returns the health status of the database. Not all backends may be able to provide this operation.

Source

fn set_health(&self, health: StorageHealth) -> Result<(), Self::Error>

Sets the health status of the database. Not all backends may be able to provide this operation.

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§