Questions tagged [rust-actix]

Actix is a rust library built on the Actor Model which allows applications to be written as a group of independently executing but cooperating "Actors" which communicate via messages.

Actix (source code) is a Rust actors framework.

233 questions
4
votes
1 answer

Save File with original filename when using the actix-web-Framework to upload a File on a webserver in Rust

I'm creating a webserver in Rust using the actix-web Framework. Currently I'm working on the Fileupload and for this im using actix-multipart. In the official Actix-Documentation there is an example for it: use std::cell::Cell; use std::fs; use…
Samuel Dressel
  • 1,181
  • 2
  • 13
  • 27
4
votes
1 answer

Rust Actix: Get SystemRunner for System::current()

Is there a way to get a SystemRunner object from the current System (which I am getting from System::current()). I can't find a way to do it through the documentation, but I feel like it should exist. I have an endpoint where a user might call a…
MarcioPorto
  • 555
  • 7
  • 22
4
votes
1 answer

How could I store closures and use them with Actix actors?

I'm trying to use Actix to communicate capture events through WebSockets and process them using something like https://github.com/foochi/how-store-closures-with-actix. The idea is providing a library that can be used to store closures (events), and…
Deveres
  • 97
  • 7
4
votes
2 answers

How do I get the parameters from a POST request from a HTML form in Actix-web?

I am building a little webapp in Actix-web, but I can't find any example of getting parameters out of a POST request in Actix-web anywhere. Searching their excellent examples repo only gives a couple of (to me) meaningful examples, but they both…
user1816631
4
votes
1 answer

Application state access from an Actix web application middleware

I have a simple middleware intended to access the application's global state to perform validation of the authentication token: use actix_web; use actix_web::HttpMessage; pub struct Authenticator; impl actix_web::middleware::Middleware for…
hedgar2017
  • 1,425
  • 3
  • 21
  • 40
3
votes
0 answers

Integrate actix websocket with rabbitmq (lapin) in Rust

I've written a websocket server in Rust using actix. If anyone wants to check the full repo here https://github.com/fabracht/actix-websocket. Now, I want to integrate rabbitmq into the project. For that, I found the lapin crate…
Fabrex
  • 162
  • 9
3
votes
1 answer

Variable that chooses between two async functions in rust - incompatible arm types

I have a variable that will control which function is the default behavior of my web app, but both functions are async and it wont let me because they're different closures. Something like this reproduces the same…
3
votes
2 answers

How can I launch a daemon in a websocket handler with actix-web?

Given a basic setup of a WebSocket server with Actix, how can I launch a daemon inside my message handler? I've extended the example starter code linked above to call daemon(false, true) using the fork crate. use actix::{Actor, StreamHandler}; use…
lovelikelando
  • 7,593
  • 6
  • 32
  • 50
3
votes
1 answer

Actix System, multiple arbiters = how many threads

Question - if you have a single system but have multiple arbiters in it running, is it STILL a single threaded event loop? Reading through the Actix book - https://actix.rs/book/actix/sec-6-sync-arbiter.html When you normally run Actors, there are…
alwinc
  • 1,317
  • 3
  • 14
  • 21
3
votes
1 answer

POST request using curl to Actix Server failing with "400 Bad Request"

I'm trying to build an actix server using actix-web = "3.3.2" to send a POST request to AWS SES which will send an email to the address provided in the body to the route. I've created a route, called signup which returns a 400 response with the…
AMP_035
  • 167
  • 1
  • 2
  • 13
3
votes
2 answers

How to fix "the trait Factory<_, _, _> is not implemented for {function}" error in actix_web?

I have this simple code: use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; use serde::{Deserialize, Serialize}; use serde_json::{json}; use validator::{Validate, ValidationError}; #[derive(Deserialize, Serialize,…
3
votes
1 answer

Run long running async function in background after returning response

In one of my actix-web handlers I want to call a function that run in the background and immediately return a response to the user: async fn heavy_computation() -> { // do some long running computation } async fn index(req: HttpRequest) -> impl…
Oskar Persson
  • 6,605
  • 15
  • 63
  • 124
3
votes
1 answer

Using redis-rs with actix-web

I am trying to add redis as a web::Data context to my actix-web rust application: extern crate redis; // std imports use std::net::SocketAddr; // external imports use actix_web::{App, HttpServer}; use redis::Client #[actix_rt::main] async fn…
Philipp Molitor
  • 387
  • 4
  • 14
3
votes
1 answer

Send messages to clients with multiple references to websockets

My question here is in the context of using actix-web with Rust. Unfortunately I can't explain this without a somewhat hefty code example, so let me start with that. struct MyWs { game: Arc>, } impl Actor for MyWs { type…
Daniel Porteous
  • 5,536
  • 3
  • 25
  • 44
3
votes
1 answer

Serde deserialization of partial structs with actix_web

I have an API endpoint that utilizes actix_web to deserialize an incoming JSON payload (actix_web ultimately uses serde for JSON deserialization). As an example, I have something that looks like this: pub struct IncomingPayload { pub field1:…
Sam Gomena
  • 1,450
  • 11
  • 21
1 2
3
15 16