actix-web: The trait bound `Ws: actix::actor::Actor` is not satisfied
Problem:
The trait bound `Ws: actix::actor::Actor` is not satisfied
compile error.
Your Environment:
$ uname -a
Linux dev 5.4.0-70-generic #78~18.04.1-Ubuntu SMP Sat Mar 20 14:10:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linu
Rust Version (I.e, output of rustc -V
):
$ rustc -V
rustc 1.51.0 (2fd73fabe 2021-03-23)
Actix Web Version:
[dependencies]
actix = "0.11.0"
actix-web = "3"
actix-web-actors = "3.0.0"
Test Code:
use actix::prelude::*;
use actix_web_actors::*;
struct Ws;
impl Actor for Ws {
type Context = ws::WebsocketContext<Self>;
}
impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for Ws {
fn handle(&mut self, msg: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
match msg.unwrap() {
ws::Message::Ping(msg) => ctx.pong(&msg),
ws::Message::Text(text) => ctx.text(text),
ws::Message::Binary(bin) => ctx.binary(bin),
ws::Message::Close(reason) => ctx.close(reason),
_ => {}
}
}
}
fn main() {
println!("Hello, world!");
}
Error:
error[E0277]: the trait bound `Ws: actix::actor::Actor` is not satisfied
--> src/main.rs:7:5
|
7 | type Context = ws::WebsocketContext<Self>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `actix::actor::Actor` is not implemented for `Ws`
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 15 (6 by maintainers)
Will actix-web-actors ever support newer actix? It’s still broken as of 0.12.0.
@fakeshadow Thank you! It compiles now.
actix-web-actors
3.0 does not supportactix
0.11. Use 0.10 insteadyes, the current master branch here is using 0.12
I think the version range in
actix-web-actors
doesn’t work how I expected. I expanded theactix
dependency range to include both 0.12 and 0.13 but it seems like cargo doesn’t select the right version all the time. I’ll have a look into it and may need to yank it.I was having build issues in my CI giving this error:
Without having changed any relevant code, so it had to be something that was updated upstream. Using
--locked
worked, so I was pretty sure it’s a version.Anyways, setting
actix-web-actors = "=4.0.0"
fixed this for me.I think it’s a
actix-web-actors
4.1.0 issue.it works fine for me
4.0.0-rc.2 doesn’t solve this problem. So, need to downgrade to actix 0.10 as I told previously. Sorry.
Same issue, are there any plans to support actors in 0.12.0 or future actix versions?