Actix websockets with an AppState
up vote
-2
down vote
favorite
I am trying to combine the Actix examples for Diesel and WebSockets. After adding the WebSockets one, it does not have the AppState
in place.
I cannot get this to work, even after looking and comparing to other code (there have been version differences, but after fixing them the result was the same error).
Here is my last (failing) commit, describing everything I got. The repo can be checked out and run.
$ rustup default nightly
$ cargo check
Checking rust-diesel v0.1.0 (~/pansen/rust_diesel)
error[E0271]: type mismatch resolving `<handlers::ws::MyWebSocket as actix::Actor>::Context == actix_web::ws::WebsocketContext<handlers::ws::MyWebSocket, AppState>`
--> src/main.rs:63:51
|
63 | r.method(http::Method::GET).f(|r| ws::start(r, handlers::ws::MyWebSocket::new())),
| ^^^^^^^^^ expected (), found struct `AppState`
|
= note: expected type `actix_web::ws::WebsocketContext<_, ()>`
found type `actix_web::ws::WebsocketContext<_, AppState>`
= note: required by `actix_web::ws::start`
websocket rust rust-actix
add a comment |
up vote
-2
down vote
favorite
I am trying to combine the Actix examples for Diesel and WebSockets. After adding the WebSockets one, it does not have the AppState
in place.
I cannot get this to work, even after looking and comparing to other code (there have been version differences, but after fixing them the result was the same error).
Here is my last (failing) commit, describing everything I got. The repo can be checked out and run.
$ rustup default nightly
$ cargo check
Checking rust-diesel v0.1.0 (~/pansen/rust_diesel)
error[E0271]: type mismatch resolving `<handlers::ws::MyWebSocket as actix::Actor>::Context == actix_web::ws::WebsocketContext<handlers::ws::MyWebSocket, AppState>`
--> src/main.rs:63:51
|
63 | r.method(http::Method::GET).f(|r| ws::start(r, handlers::ws::MyWebSocket::new())),
| ^^^^^^^^^ expected (), found struct `AppState`
|
= note: expected type `actix_web::ws::WebsocketContext<_, ()>`
found type `actix_web::ws::WebsocketContext<_, AppState>`
= note: required by `actix_web::ws::start`
websocket rust rust-actix
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am trying to combine the Actix examples for Diesel and WebSockets. After adding the WebSockets one, it does not have the AppState
in place.
I cannot get this to work, even after looking and comparing to other code (there have been version differences, but after fixing them the result was the same error).
Here is my last (failing) commit, describing everything I got. The repo can be checked out and run.
$ rustup default nightly
$ cargo check
Checking rust-diesel v0.1.0 (~/pansen/rust_diesel)
error[E0271]: type mismatch resolving `<handlers::ws::MyWebSocket as actix::Actor>::Context == actix_web::ws::WebsocketContext<handlers::ws::MyWebSocket, AppState>`
--> src/main.rs:63:51
|
63 | r.method(http::Method::GET).f(|r| ws::start(r, handlers::ws::MyWebSocket::new())),
| ^^^^^^^^^ expected (), found struct `AppState`
|
= note: expected type `actix_web::ws::WebsocketContext<_, ()>`
found type `actix_web::ws::WebsocketContext<_, AppState>`
= note: required by `actix_web::ws::start`
websocket rust rust-actix
I am trying to combine the Actix examples for Diesel and WebSockets. After adding the WebSockets one, it does not have the AppState
in place.
I cannot get this to work, even after looking and comparing to other code (there have been version differences, but after fixing them the result was the same error).
Here is my last (failing) commit, describing everything I got. The repo can be checked out and run.
$ rustup default nightly
$ cargo check
Checking rust-diesel v0.1.0 (~/pansen/rust_diesel)
error[E0271]: type mismatch resolving `<handlers::ws::MyWebSocket as actix::Actor>::Context == actix_web::ws::WebsocketContext<handlers::ws::MyWebSocket, AppState>`
--> src/main.rs:63:51
|
63 | r.method(http::Method::GET).f(|r| ws::start(r, handlers::ws::MyWebSocket::new())),
| ^^^^^^^^^ expected (), found struct `AppState`
|
= note: expected type `actix_web::ws::WebsocketContext<_, ()>`
found type `actix_web::ws::WebsocketContext<_, AppState>`
= note: required by `actix_web::ws::start`
websocket rust rust-actix
websocket rust rust-actix
edited Nov 11 at 14:12
Shepmaster
145k11276409
145k11276409
asked Nov 11 at 11:44
pansen
495
495
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13
add a comment |
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13
1
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You need the State
extractor. Then store State<AppState>
in your WebSocket actor.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You need the State
extractor. Then store State<AppState>
in your WebSocket actor.
add a comment |
up vote
0
down vote
You need the State
extractor. Then store State<AppState>
in your WebSocket actor.
add a comment |
up vote
0
down vote
up vote
0
down vote
You need the State
extractor. Then store State<AppState>
in your WebSocket actor.
You need the State
extractor. Then store State<AppState>
in your WebSocket actor.
edited Nov 11 at 15:11
Shepmaster
145k11276409
145k11276409
answered Nov 11 at 14:49
Nikolay Kim
1091
1091
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248403%2factix-websockets-with-an-appstate%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
– Shepmaster
Nov 11 at 14:13