Created
September 6, 2020 16:14
-
-
Save rhzs/177283724116667445052fa23ecd41e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
xxxx | |
[dependencies] | |
actix = "0.10.0-alpha.3" | |
actix-cors = "0.3.0-alpha.1" | |
actix-http = "2.0.0-beta.3" | |
actix-rt = "1" | |
actix-service = "1.0.6" | |
actix-web = { version = "3.0.0-beta.3", features = ["rustls"] } | |
log = "0.4" | |
actix_derive = "0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cargo check Error | |
error: Expect a attribute `rtype` | |
--> chat-worker/src/worker.rs:7:10 | |
| | |
7 | #[derive(Message)] | |
| ^^^^^^^ | |
| | |
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) | |
error[E0277]: the trait bound `worker::BackgroundTask: actix::Message` is not satisfied | |
--> chat-worker/src/worker.rs:21:6 | |
| | |
21 | impl Handler<BackgroundTask> for BackgroundTaskActor { | |
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `actix::Message` is not implemented for `worker::BackgroundTask` | |
| | |
::: /Users/angel/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.10.0-alpha.3/src/handler.rs:23:8 | |
| | |
23 | M: Message, | |
| ------- required by this bound in `actix::Handler` | |
error: aborting due to 2 previous errors | |
For more information about this error, try `rustc --explain E0277`. | |
error: could not compile `chat-worker`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate log; | |
extern crate actix; | |
pub mod worker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use actix::prelude::*; | |
use actix::Actor; | |
use std::{thread, time}; | |
#[derive(Message)] // COMPILE ERROR: Here.. | |
pub struct BackgroundTask; | |
#[derive(Default)] | |
pub struct BackgroundTaskActor; | |
impl Actor for BackgroundTaskActor { | |
type Context = SyncContext<Self>; | |
fn started(&mut self, _: &mut SyncContext<Self>) { | |
info!("Background task actor started up") | |
} | |
} | |
impl Handler<BackgroundTask> for BackgroundTaskActor { // COMPILE ERROR: Here.. | |
type Result = (); | |
fn handle(&mut self, _: BackgroundTask, _: &mut SyncContext<Self>) { | |
info!("Starting background task"); | |
thread::sleep(time::Duration::new(4, 0)); | |
info!("Finished background task"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment