Closed Token-Thinker closed 10 months ago
Hey its me again haha.
No worries, ask away :) !
Unfortunately, due to the lack of type erasing (such as Box<dyn MyTrait>
) in bare metal, the routes in a Router are heavily baked into the generated type, and thus Router::new().route("/", get(get_site))
and Router::new().route("/ws", get(|upgrade: WebSocketUpgrade| { upgrade.on_upgrade(crate::network::websockets::WebsocketHandler {}) }))
are different types.
This might be able to be resolved if we get dyn safe async traits, but not in the current version of Rust.
As for the resource error, one possible solution would be to shrink the TCP buffers. This would potentially slow the connection down, as more packets would be dropped before being transferred into the HTTP buffer, but it shouldn't be too bad.
okay, that makes sense. Thank you!
Hey its me again haha.
I'm trying to create a function for setting up multiple ports with various routes using a single function to conserve memory on my device, however i'm running into a
type
error when setting up theRouter
(which is understandable) betweenIntoResponse
andWebSocketUpgrade
and a little lost on what to do. Any advice?Also note - I did split it into two separate (http and ws) however i still can't get two ws ports to spawn for some reason (i believe resource issue) just kind of at my wits end.