Compiling dynamic-preauth v0.1.0 (/home/xevion/projects/dynamic-preauth)
error[E0505]: cannot move out of `req` because it is borrowed
--> src/main.rs:56:28
|
54 | async fn connect(req: &mut Request, res: &mut Response, depot: &Depot) -> Result<(), StatusError> {
| --- binding `req` declared here
55 | WebSocketUpgrade::new()
56 | .upgrade(req, res, |ws| async move {
| ------- --- ^^^^ move out of `req` occurs here
| | |
| | borrow of `*req` occurs here
| borrow later used by call
57 | let session_id = get_session_id(req, depot).unwrap();
| --- move occurs due to use in closure
error[E0373]: closure may outlive the current function, but it borrows `depot`, which is owned by the current function
--> src/main.rs:56:28
|
56 | .upgrade(req, res, |ws| async move {
| ^^^^ may outlive borrowed value `depot`
57 | let session_id = get_session_id(req, depot).unwrap();
| ----- `depot` is borrowed here
|
note: function requires argument type to outlive `'static`
--> src/main.rs:55:5
|
55 | / WebSocketUpgrade::new()
56 | | .upgrade(req, res, |ws| async move {
57 | | let session_id = get_session_id(req, depot).unwrap();
58 | | handle_socket(session_id, ws).await;
59 | | })
| |__________^
help: to force the closure to take ownership of `depot` (and any other referenced variables), use the `move` keyword
|
56 | .upgrade(req, res, move |ws| async move {
| ++++
error[E0521]: borrowed data escapes outside of associated function
--> src/main.rs:55:5
|
54 | async fn connect(req: &mut Request, res: &mut Response, depot: &Depot) -> Result<(), StatusError> {
| --- - let's call the lifetime of this reference `'1`
| |
| `req` is a reference that is only valid in the associated function body
55 | / WebSocketUpgrade::new()
56 | | .upgrade(req, res, |ws| async move {
57 | | let session_id = get_session_id(req, depot).unwrap();
58 | | handle_socket(session_id, ws).await;
59 | | })
| | ^
| | |
| |__________`req` escapes the associated function body here
| argument requires that `'1` must outlive `'static`
error[E0521]: borrowed data escapes outside of associated function
--> src/main.rs:55:5
|
54 | async fn connect(req: &mut Request, res: &mut Response, depot: &Depot) -> Result<(), StatusError> {
| ----- - let's call the lifetime of this reference `'2`
| |
| `depot` is a reference that is only valid in the associated function body
55 | / WebSocketUpgrade::new()
56 | | .upgrade(req, res, |ws| async move {
57 | | let session_id = get_session_id(req, depot).unwrap();
58 | | handle_socket(session_id, ws).await;
59 | | })
| | ^
| | |
| |__________`depot` escapes the associated function body here
| argument requires that `'2` must outlive `'static`
Some errors have detailed explanations: E0373, E0505, E0521.
For more information about an error, try `rustc --explain E0373`.
error: could not compile `dynamic-preauth` (bin "dynamic-preauth") due to 4 previous errors