-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
There are two big issues I'm running into with handle_request().
- I want to, as a result of handling either an HTTP or WS request,
.ws_push_all_channels(). However, I can't since I'm in a closure inside of aHttpServermethod call that is borrowing it as mutable. - I have some state I want to be able to use as a mutable reference in both the HTTP and the WS closure. But Rust complains:
error[E0524]: two closures require unique access to `*message_archive` at the same time --> foo/src/lib.rs:145:9 | 74 | server.handle_request( | -------------- first borrow later used by call 75 | request, 76 | |request| { | --------- first closure is constructed here ... 124 | message_archive, | --------------- first borrow occurs due to use of `*message_archive` in closure ... 145 | |_channel, _message_type, blob| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second closure is constructed here ... 151 | message_archive, | --------------- second borrow occurs due to use of `*message_archive` in closure
Describe the solution you'd like
- One possible way around this would be to expose the
ws_channelsHashMap and add a function (not a method)ws_push_all_channels()that operated on the given HashMap. - idk
Describe alternatives you've considered
What I'm probably going to have to do is go back to the old pattern of matching.
Notes
It seems like we probably didn't hit the second of these problems before because we used WS only one way (i.e. Kinode -> FE or FE -> Kinode, not both), and hence, the state need not be passed into two closures, only one.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request