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
I'm trying to implement the same in rust like this -
asyncfnnew_enforcer(&self,i:Request<casbin_proto::NewEnforcerRequest>,) -> Result<Response<casbin_proto::NewEnforcerReply>,Status>{let a:Option<Box<dynAdapter>>;let e:Enforcer;if i.get_mut().adapter_handle != -1{
a = matchself.get_adapter(i.into_inner().adapter_handle){Ok(v) => Some(Box::new(v)),Err(er) => returnOk(Response::new(casbin_proto::NewEnforcerReply{handler:0})),};}if i.get_mut().model_text == String::from(""){let cfg = adapter::load_configuration("config/connection_config.json").await?;let data = match std::fs::read_to_string(cfg.enforcer.as_str()){Ok(v) => v,Err(er) => returnOk(Response::new(casbin_proto::NewEnforcerReply{handler:0})),};}match a {None => {let m = DefaultModel::from_str(i.get_mut().model_text.as_str()).await.unwrap();let e = casbin::Enforcer::new(m,()).await.unwrap();}Some(v) => {let m = DefaultModel::from_str(i.get_mut().model_text.as_str()).await.unwrap();let e = casbin::Enforcer::new(m, v).await.unwrap();}}let h = self.add_enforcer(e);Ok(Response::new(casbin_proto::NewEnforcerReply{handler: h }))}
And these are the errors I get -
error[E0277]: the trait bound `&Box<dyn Adapter>: Adapter` is not satisfied
--> src/server/rpc_calls.rs:318:31
|
318 | Ok(v) => Some(Box::new(v)),
| ^^^^^^^^^^^ the trait `Adapter` is not implemented for `&Box<dyn Adapter>`
|
= note: required for the cast to the object type `dyn Adapter`
error[E0277]: the trait bound `Box<dyn Adapter>: Adapter` is not satisfied
--> src/server/rpc_calls.rs:340:50
|
340 | let e = casbin::Enforcer::new(m, v).await.unwrap();
| ^ the trait `Adapter` is not implemented for `Box<dyn Adapter>`
|
::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.9/src/core_api.rs:29:35
|
29 | async fn new<M: TryIntoModel, A: TryIntoAdapter>(
| - required by this bound in `new`
|
= note: required because of the requirements on the impl of `TryIntoAdapter` for `Box<dyn Adapter>`
I'm trying to handle the
Adapter
trait from the main repo.This is a sample function in the golang version of casbin-server (grpc) -
I'm trying to implement the same in rust like this -
And these are the errors I get -
Any ideas on how to go around managing these errors?
@hackerchai @hsluoyz @xcaptain @PsiACE
The text was updated successfully, but these errors were encountered: