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

remove clones and string allocs, use macro for model retreval #87

Merged
merged 1 commit into from
Apr 6, 2020
Merged

remove clones and string allocs, use macro for model retreval #87

merged 1 commit into from
Apr 6, 2020

Conversation

DevinR528
Copy link
Contributor

@DevinR528 DevinR528 commented Apr 5, 2020

In the FileAdapter when the method is unimplemented like add_policy instead of returning Ok(true) would false be a better signal or even panic!("this is not available for 'FileAdapter') maybe?

@codecov
Copy link

codecov bot commented Apr 5, 2020

Codecov Report

Merging #87 into master will increase coverage by 1.44%.
The diff coverage is 87.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage   79.45%   80.89%   +1.44%     
==========================================
  Files          21       21              
  Lines        2745     2712      -33     
==========================================
+ Hits         2181     2194      +13     
+ Misses        564      518      -46     
Impacted Files Coverage Δ
src/adapter/file_adapter.rs 47.91% <ø> (ø)
src/enforcer.rs 91.19% <87.50%> (+10.20%) ⬆️
src/config.rs 92.10% <100.00%> (-0.06%) ⬇️
src/model/mod.rs 35.71% <0.00%> (+7.14%) ⬆️
src/adapter/mod.rs 25.00% <0.00%> (+12.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 301420c...3d5ff7e. Read the comment docs.

@GopherJ
Copy link
Member

GopherJ commented Apr 5, 2020

lgtm. It seems much more clear when we have only one commit for specific things.

I also think it may cause some confusion if we return Ok(true) in FileAdapter, I'm not sure if we should implement thoses functions. The other languages didn't implement them so I think for now we just keep it like this.

However we cannot return Ok(false) because the new change in src/internal_api.rs:

if self.auto_save && !self.adapter.add_policy(sec, ptype, rule.clone()).await? {

Why I did this is because:

casbin/casbin#415

If we do panic then we will also need to recover from it. Do you have some ideas on this?


let file = FileAdapter::new("examples/basic_policy.csv");
let mem = MemoryAdapter::default();
let mut e = Enforcer::new(Box::new(m), Box::new(file)).await.unwrap();
Copy link
Member

@GopherJ GopherJ Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here We don't need Box anymore

Copy link
Contributor

@xcaptain xcaptain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a lot of nice changes, great job!

@GopherJ GopherJ merged commit a9d5d1e into casbin:master Apr 6, 2020
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.

3 participants