Integrating PliantDb Locally

PliantDb supports multiple databases and multiple schemas. However, for many applications, you only need a single database.

If you're only wanting a single database, the setup is straightforward: (from pliantdb/examples/

let db = Database::<Message>::open_local(

Under the hood, PliantDb is creating a multi-database Storage with a local Database named default for you. If you need to switch to a multi-database model, you can open the storage and access the default database: (adapted from pliantdb/examples/

let storage = Storage::open_local(
let db = storage.database::<Message>("default").await?;

You can register multiple schemas so that databases can be purpose-built.

Common Traits

To help your code transition between different modes of accessing PliantDb, you can use these common traits to make your methods accept any style of PliantDb access.

For example, pliantdb/examples/ uses this helper method to insert a record:

async fn insert_a_message<C: Connection>(
    connection: &C,
    value: &str,
) -> anyhow::Result<()> {
        .push(&Message {
            contents: String::from(value),
            timestamp: SystemTime::now(),