Skip to content

Commit

Permalink
Feat: add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerchai committed Aug 25, 2020
1 parent 06a01d1 commit 14c33c8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/casbin_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ pub enum CasbinCmd {
Enforce(Vec<String>),
AddPolicy(Vec<String>),
AddPolicies(Vec<Vec<String>>),
AddNamedPolicy(String, Vec<String>),
AddNamedPolicies(String, Vec<Vec<String>>),
AddGroupingPolicy(Vec<String>),
AddGroupingPolicies(Vec<Vec<String>>),
AddNamedGroupingPolicy(String, Vec<String>),
AddNamedGroupingPolicies(String, Vec<Vec<String>>),
RemovePolicy(Vec<String>),
RemovePolicies(Vec<Vec<String>>),
RemoveFilteredPolicy(usize, Vec<String>),
Expand All @@ -29,6 +35,12 @@ pub enum CasbinResult {
Enforce(bool),
AddPolicy(bool),
AddPolicies(bool),
AddNamedPolicy(bool),
AddNamedPolicies(bool),
AddGroupingPolicy(bool),
AddGroupingPolicies(bool),
AddNamedGroupingPolicy(bool),
AddNamedGroupingPolicies(bool),
RemovePolicy(bool),
RemovePolicies(bool),
RemoveFilteredPolicy(bool),
Expand Down Expand Up @@ -104,6 +116,12 @@ impl<T: IEnforcer + 'static> Handler<CasbinCmd> for CasbinActor<T> {
.add_policies(policy)
.await
.map(CasbinResult::AddPolicies),
CasbinCmd::AddNamedPolicy(ptype, policy) => lock.add_named_policy(&ptype,policy).await.map(CasbinResult::AddNamedPolicy),
CasbinCmd::AddNamedPolicies(ptype, policy) => lock.add_named_policies(&ptype,policy).await.map(CasbinResult::AddNamedPolicies),
CasbinCmd::AddGroupingPolicy(policy) => lock.add_grouping_policy(policy).await.map(CasbinResult::AddGroupingPolicy),
CasbinCmd::AddGroupingPolicies(policy) => lock.add_grouping_policies(policy).await.map(CasbinResult::AddGroupingPolicies),
CasbinCmd::AddNamedGroupingPolicy(ptype, policy) => lock.add_named_grouping_policy(&ptype, policy).await.map(CasbinResult::AddNamedGroupingPolicy),
CasbinCmd::AddNamedGroupingPolicies(ptype, policy) => lock.add_named_grouping_policies(&ptype, policy).await.map(CasbinResult::AddNamedGroupingPolicies),
CasbinCmd::RemovePolicy(policy) => lock
.remove_policy(policy)
.await
Expand Down

0 comments on commit 14c33c8

Please sign in to comment.