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
The design of the context traits in src/traits.rs seems to mimic a C++-style inheritance based design by providing default implementations of trait functions, but this prevents certain code patterns from working because of the borrow checker, e.g. iterating mutably over a struct field while calling self.dispatch_http_call and storing the returned token in the field. Because dispatch_http_call takes my context struct as a &self parameter, I can not call it while having a field of my struct mutably borrowed, as is the case when iterating mutably.
Note that none of these default implementations actually access the self parameter, they all just call something from the hostcalls module. It also seems like it doesn't make much sense to override most of them, except the ones that the host calls for us.
The proxy-sdk crate seems to have found a design that meshes better with the way things work in Rust. (I am not affiliated with them and haven't tried it out yet.)
The text was updated successfully, but these errors were encountered:
miwig
added a commit
to antonengelhardt/wasm-oidc-plugin
that referenced
this issue
Feb 12, 2025
Simplify discovery.rs a bit by removing some mutexes that are not strictly necessary.
We do however need to work around proxy-wasm/proxy-wasm-rust-sdk#303
by using the hostcalls module (around which the HttpContext trait is just a trivial wrapper) directly
The design of the context traits in src/traits.rs seems to mimic a C++-style inheritance based design by providing default implementations of trait functions, but this prevents certain code patterns from working because of the borrow checker, e.g. iterating mutably over a struct field while calling
self.dispatch_http_call
and storing the returned token in the field. Becausedispatch_http_call
takes my context struct as a&self
parameter, I can not call it while having a field of my struct mutably borrowed, as is the case when iterating mutably.Note that none of these default implementations actually access the
self
parameter, they all just call something from thehostcalls
module. It also seems like it doesn't make much sense to override most of them, except the ones that the host calls for us.The
proxy-sdk
crate seems to have found a design that meshes better with the way things work in Rust. (I am not affiliated with them and haven't tried it out yet.)The text was updated successfully, but these errors were encountered: