-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
FAQ
Rob Ede edited this page Jul 31, 2022
·
20 revisions
The examples repo (https://github.com/actix/examples) projects and links to community samples in readme.
Our MSRV policy is that we will support at least all Rust versions released in the last 6 months. I.e., the MSRV may be bumped in a minor release.
Not yet documented. See this test for how to return App
.
Async behavior in actix
handlers is less ergonomic than the standard async/await systems in Rust, but it is achiveable.
See this test file for more examples: https://github.com/actix/actix/blob/master/actix/tests/test_fut.rs
struct StreamActor;
impl Actor for StreamActor {
type Context = Context<Self>;
}
struct StreamMessage(String);
impl Message for StreamMessage {
type Result = ();
}
impl StreamHandler<StreamMessage> for StreamActor {
fn handle(&mut self, item: StreamMessage, ctx: &mut Context<Self>) {
let future = async move {
// await things in here
println!("We got message {}", item.0);
};
// Context::spawn or Context::wait
future.into_actor(self).spawn(ctx);
}
}
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
let res = awc::Client::new()
.get("https://crates.io")
.content_type("application/json")
.send()
.await
.unwrap()
.json::<HashMap<String, String>>()
.limit(65535 * 128)
.await
.unwrap();
Ok(())
}
Ask Questions in the Discord Server