string-adapter

Crates.iostring-adapter
lib.rsstring-adapter
version
sourcesrc
created_at2024-12-28 16:45:23.336024+00
updated_at2024-12-28 16:45:23.336024+00
descriptionString adapter for casbin-rs
homepagehttps://github.com/casbin-rs/string-adapter
repositoryhttps://github.com/casbin-rs/string-adapter
max_upload_size
id1497610
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(hsluoyz)

documentation

README

string-adapter

Crates.io Docs CI codecov

String Adapter is a String adapter for casbin-rs. With this library, Casbin can load policy from String.

Install

Add the following to Cargo.toml:

string-adapter = { version = "1.1.0", default-features = false, features = ["runtime-tokio"]}
tokio = { version = "1.42.0", features = ["macros"] }

Example

use casbin::{CoreApi, DefaultModel, Enforcer, Result};
use string_adapter::StringAdapter;

#[tokio::main]
async fn main() -> Result<()> {
    let m = DefaultModel::from_file("examples/rbac_model.conf").await?;

    let a = StringAdapter::new(
        r#"
        p, alice, data1, read
        p, bob, data2, write
        p, data2_admin, data2, read
        p, data2_admin, data2, write
        g, alice, data2_admin
        "#,
    );

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

    Ok(())
}

Features

  • runtime-async-std: Use async-std as the runtime.
  • runtime-tokio: Use tokio as the runtime (default).
Commit count: 7

cargo fmt