Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement string adapter for model and policy #342

Closed
wants to merge 2 commits into from

Conversation

sanbei101
Copy link

This pull request introduces a new trait TryIntoModelFromStr and integrates it into the existing codebase. The main changes include adding the new trait, implementing it for &'static str, and updating the CoreApi and Enforcer to support the new trait. Additionally, new test cases have been added to ensure the functionality works as expected.

Introduction of TryIntoModelFromStr trait:

  • src/convert.rs: Added TryIntoModelFromStr trait and implemented it for &'static str

Integration into CoreApi:

  • src/core_api.rs: Updated imports and added methods new_raw_from_str and new_from_str to the CoreApi trait.

Integration into Enforcer:

  • src/enforcer.rs: Updated imports and implemented the new methods new_raw_from_str and new_from_str in the Enforcer struct.

Testing:

  • [src/enforcer.rs]: Added a new test case test_get_and_set_model_from_str to validate the new functionality.

@CLAassistant
Copy link

CLAassistant commented Oct 5, 2024

CLA assistant check
All committers have signed the CLA.

@sanbei101 sanbei101 changed the title feat: implement string adapter for model and policy (casbin#331) feat: implement string adapter for model and policy (casbin-rs#331) Oct 5, 2024
@sanbei101 sanbei101 changed the title feat: implement string adapter for model and policy (casbin-rs#331) feat: implement string adapter for model and policy [#331](https://github.com/casbin/casbin-rs/issues/331) Oct 5, 2024
@sanbei101 sanbei101 changed the title feat: implement string adapter for model and policy [#331](https://github.com/casbin/casbin-rs/issues/331) feat: implement string adapter for model and policy Oct 5, 2024
Copy link

github-actions bot commented Oct 5, 2024

Benchmark for c5a05d3

Click to view benchmark
Test PR Benchmark Master Benchmark %
b_benchmark_rbac_model_large 10.0±0.03ms 9.9±0.06ms +1.01%
benchmark priority model 4.2±0.07µs 4.2±0.05µs 0.00%
benchmark_abac_model 2.5±0.05µs 2.5±0.03µs 0.00%
benchmark_basic_model 3.8±0.07µs 3.8±0.09µs 0.00%
benchmark_key_match 7.1±0.16µs 7.1±0.14µs 0.00%
benchmark_raw 0.0±0.00ns 0.0±0.00ns NaN%
benchmark_rbac_model 6.1±0.10µs 6.2±0.10µs -1.61%
benchmark_rbac_model_medium 917.1±12.59µs 846.3±9.78µs +8.37%
benchmark_rbac_model_with_domains 6.0±0.11µs 6.0±0.10µs 0.00%
benchmark_rbac_with_deny 8.7±0.13µs 8.7±0.08µs 0.00%
benchmark_rbac_with_resource_roles 4.5±0.04µs 4.5±0.04µs 0.00%
benchmark_role_manager_large 4.5±0.06ms 4.5±0.04ms 0.00%
benchmark_role_manager_medium 306.0±7.46µs 303.7±4.45µs +0.76%
benchmark_role_manager_small 92.2±2.32µs 96.1±6.76µs -4.06%

@sanbei101 sanbei101 deleted the branch casbin:master October 5, 2024 16:36
@sanbei101 sanbei101 closed this Oct 5, 2024
@sanbei101 sanbei101 deleted the master branch October 5, 2024 16:36
Copy link

github-actions bot commented Oct 5, 2024

Benchmark for c5a05d3

Click to view benchmark
Test PR Benchmark Master Benchmark %
b_benchmark_rbac_model_large 9.9±0.05ms 10.3±0.03ms -3.88%
benchmark priority model 4.4±0.06µs 4.4±0.07µs 0.00%
benchmark_abac_model 2.6±0.03µs 2.6±0.04µs 0.00%
benchmark_basic_model 4.0±0.05µs 4.0±0.07µs 0.00%
benchmark_key_match 7.3±0.05µs 7.3±0.08µs 0.00%
benchmark_raw 0.0±0.00ns 0.0±0.00ns NaN%
benchmark_rbac_model 6.3±0.09µs 6.4±0.04µs -1.56%
benchmark_rbac_model_medium 835.8±10.08µs 831.7±11.53µs +0.49%
benchmark_rbac_model_with_domains 6.2±0.07µs 6.2±0.12µs 0.00%
benchmark_rbac_with_deny 8.7±0.14µs 8.8±0.08µs -1.14%
benchmark_rbac_with_resource_roles 4.6±0.05µs 4.6±0.05µs 0.00%
benchmark_role_manager_large 4.6±0.13ms 4.6±0.07ms 0.00%
benchmark_role_manager_medium 303.0±4.46µs 310.3±5.20µs -2.35%
benchmark_role_manager_small 91.3±1.12µs 90.1±1.31µs +1.33%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants