An adapter designed to work with casbin-rs which is fully asynchronous
.
Add it to Cargo.toml
casbin = { version = "0.4.3" }
sqlx-adapter = { version = "0.1.0", features = ["postgres"] }
async-std = "1.5.0"
Rename sample.env
to env
DATABASE_URL=postgres://casbin_rs:casbin_rs@localhost:5432/casbin
POOL_SIZE=8
```rust use casbin::prelude::*; use sqlx_adapter::SqlxAdapter;
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(())
}
```
postgres
mysql
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.