Skip to content

Instantly share code, notes, and snippets.

@angelsl
Forked from donjar/a.rs
Last active February 11, 2020 07:16
Show Gist options
  • Save angelsl/2669b66c7001892972e34ecc1d09eb66 to your computer and use it in GitHub Desktop.
Save angelsl/2669b66c7001892972e34ecc1d09eb66 to your computer and use it in GitHub Desktop.
use actix::prelude::*;
pub struct Msg {
}
impl Message for Msg {
type Result = Result<i32, ()>;
}
pub struct AsyncActorThatOnlySpewsState {
pub internal_state: i32,
}
impl Actor for AsyncActorThatOnlySpewsState {
type Context = Context<Self>;
}
impl Handler<Msg> for AsyncActorThatOnlySpewsState {
type Result = ResponseFuture<Result<i32, ()>>;
fn handle(&mut self, msg: Msg, _ctx: &mut Context<Self>) -> Self::Result {
let state = self.internal_state;
Box::pin(async move {
Ok(state)
})
}
}
fn main() {
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment