Basteh


Crates.io version docs.rs docs actions status Codecov Crates.io


Note The main branch includes many breaking changes, switch to v0.3 branch for the released version.


Basteh(previously actix-storage) is a type erased wrapper around some key-value storages to provide common operations.

Install

Basteh is meant to be used alongside one the implementer crates, ex:

```toml

Cargo.toml

[dependencies] basteh = "0.4.0-alpha.3" basteh-memory = "0.4.0-alpha.3" ```

Usage

After you picked a backend:

```rust,ignore use basteh::{Storage, Format}; use basteh_memory::MemoryBackend;

async fn makestorage() -> Storage { // Intialize the implementer according to its docs let store = MemoryBackend::startdefault();

// Give it to the Storage struct let storage = Storage::build().store(store).finish();

// Or if it doesn't support expiring functionality // it will give errors if those methods are called let storage = Storage::build().store(store).no_expiry().finish();

// It is also possible to feed a seprate expiry, // as long as it works on the same storage backend let storage = Storage::build().store(store).expiry(expiry).finish();

storage } ```

Implementations

basteh-memory docs.rs docs

basteh-sled docs.rs docs

basteh-redis docs.rs docs

Use cases

It can be usefull when:

  1. You don't know which key-value database you'll need later.
  2. You can't afford the long time compilation of some dbs while developing.
  3. You're writing an extension library and need to support multiple storage backends.

Examples

There are bunch of examples in the examples folder, very basic ones thought, but it will give you the idea.

License

This project is licensed under either of

at your option.