casbin / casbin-rs

An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
https://casbin.org
Apache License 2.0
863 stars 74 forks source link

feat: add StringAdapter to file adapter module #344

Closed sanbei101 closed 1 month ago

sanbei101 commented 1 month ago

This pull request introduces a new StringAdapter to handle policy strings directly, along with necessary integrations and updates to the existing codebase. The most important changes include the addition of the StringAdapter struct and its implementation, updates to the adapter module to include the new adapter, and modifications to the main library file to use the new adapter.

Introduction of StringAdapter:

Module updates:

Library updates:

github-actions[bot] commented 1 month ago

Benchmark for c5a05d3

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | b_benchmark_rbac_model_large | 10.3±0.10ms | 10.4±0.12ms | -0.96% | | benchmark priority model | 4.3±0.08µs | 4.3±0.08µs | 0.00% | | benchmark_abac_model | 2.6±0.05µs | 2.6±0.10µs | 0.00% | | benchmark_basic_model | 3.9±0.07µs | 3.9±0.04µs | 0.00% | | benchmark_key_match | 7.3±0.15µs | **7.2±0.09µs** | **+1.39%** | | benchmark_raw | 0.0±0.00ns | 0.0±0.00ns | NaN% | | benchmark_rbac_model | 6.5±0.15µs | **6.2±0.06µs** | **+4.84%** | | benchmark_rbac_model_medium | 910.7±11.30µs | 914.7±14.55µs | -0.44% | | benchmark_rbac_model_with_domains | 6.1±0.10µs | 6.1±0.11µs | 0.00% | | benchmark_rbac_with_deny | **8.8±0.15µs** | 9.1±0.11µs | **-3.30%** | | benchmark_rbac_with_resource_roles | 4.5±0.11µs | 4.5±0.09µs | 0.00% | | benchmark_role_manager_large | 4.6±0.03ms | 4.6±0.26ms | 0.00% | | benchmark_role_manager_medium | 308.9±3.22µs | **305.4±3.18µs** | **+1.15%** | | benchmark_role_manager_small | 94.2±1.09µs | **91.9±1.66µs** | **+2.50%** |