Open SiddheshKanawade opened 1 year ago
@hsluoyz @hackerchai @PsiACE please help
I tried to send the adapter as wrapped under RefCell
but since its not thread safe, I am unable to use it.
The major cause of error is due to &Box<dyn Adapter>
instead of Box<dyn Adapter>
on calling by key from hashmap. As of now, I am able to thing of the following possible approaches:
Box<dyn Adapter>
casbin-rs
as that it can implement TryIntoAdapter
for Arc<Mutex<T>>
.In this first approach, I think we will loose the optimisation and hence was planning to go with the second one. @hsluoyz @hackerchai is it fine if I make some changes in casbin-rs
?
Until then I will try to close the other issues in sqlx-adapter and casbin-actix-auth
Update: sqlx adapter issue has been resolved
@hackerchai @hsluoyz can you please comment on above issue and give your views. I have tried every possible thing I could think of, adapter doesn’t have clone or copy traits implemented, hence can’t directly copy it without taking reference.
@SiddheshKanawade plz contact @hackerchai
@SiddheshKanawade plz contact @hackerchai
Will dm him too, it seems he isn’t active over here recently. Till then I am working on diesel adapter #66
I am trying to draft the
new_enforcer
, which is as below:Here I am getting error in
self.get_adapter()
andself.add_enforcer()
function, the error message is as follows:After the initial research I was able to figure out that this is due to the & reference from the
get_adapter
function, which is as below:Here,
adapter_map
is a hashmap:When we take any value from the hashmap, we get the reference of that value rather than the copy of the value. In short, when we do
self.adapter_map.get(&handle)
, we get&Box<dyn Adapter>
and notBox<dyn Adapter>
. Since Copy trait is not implemented for Adapter in thecasbin-rs
, we can't use methods liketo_owned
to drop the&
. I tried to send theBox<dyn Adapter>
wrapped inArc<Mutex<Box<dyn Adapter>>>
but then inconvert.rs
of casbin-rs we can't call TryIntoAdapter for it.I am unable to figure out how can I resolve the above errors.