You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deref inheritance is an anti-pattern in rust because it's just passing actions/tasks to specific field. That means in our function we'll never be able to get child's reference.
So I propose to have better design and remove the usage of Deref in CachedEnforcer.
What can we do?
I think we can use trait inheritance, that means we should have a base/parent trait which can be called as CoreApi.
Then imple<T> InternalApi for T: CoreApi, impl<T> MgmtApi for T: InternalApi, Impl<T> RbacApi for T: MgmtApi
So finally for different types of enforcers they just need to implement CoreApi to get all the management functions.
How can we have different behaviours for different Enforcers?
No idea for now.
CachedEnforcer will have extra functions comparing to normal enforcers
SyncedEnforcer is a wrapper over Arc<RwLock<Enforcer>> or Arc<RwLock<CachedEnforcer>>
The text was updated successfully, but these errors were encountered:
Deref inheritance is an anti-pattern in rust because it's just passing actions/tasks to specific field. That means in our function we'll never be able to get
child
's reference.So I propose to have better design and remove the usage of
Deref
inCachedEnforcer
.What can we do?
I think we can use trait inheritance, that means we should have a base/parent trait which can be called as
CoreApi
.Then
imple<T> InternalApi for T: CoreApi
,impl<T> MgmtApi for T: InternalApi
,Impl<T> RbacApi for T: MgmtApi
So finally for different types of enforcers they just need to implement
CoreApi
to get all the management functions.How can we have different behaviours for different Enforcers?
No idea for now.
CachedEnforcer will have extra functions comparing to normal enforcers
SyncedEnforcer is a wrapper over
Arc<RwLock<Enforcer>>
orArc<RwLock<CachedEnforcer>>
The text was updated successfully, but these errors were encountered: