sqlx-adapter

Build Status

An adapter designed to work with casbin-rs which is fully asynchronous.

Install

Add it to Cargo.toml

casbin = { version = "0.4.3" } sqlx-adapter = { version = "0.1.0", features = ["postgres"] } async-std = "1.5.0"

Configure

Rename sample.env to env

DATABASE_URL=postgres://casbin_rs:casbin_rs@localhost:5432/casbin POOL_SIZE=8

Example

```rust use casbin::prelude::*; use sqlx_adapter::SqlxAdapter;

[async_std::main]

async fn main() -> Result<()> { let m = DefaultModel::fromfile("examples/rbacmodel.conf").await?;

let a = SqlxAdapter::new().await?;
let mut e = Enforcer::new(m, a).await?;

Ok(())

}

```

Features

Attention: postgres and mysql are mutual exclusive which means that you can only activate one of them. Currently we don't have support for sqlite, it may be added in the near future.