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
1
vote
1 answer

Unit testing actix actors, sending messages to different types of actor

I'm trying to use the Rust Actix actor framework where I have a thread polling some hardware, forming simple event messages and sending them to an Actor via its Addr. There's an enum KeyingEvent that forms the Message. In my tests, I have an Actor…
Matt Gumbley
  • 307
  • 2
  • 8
1
vote
0 answers

Cannot move out of an `Arc`

I have a struct called routing with the following methods. #[derive(Clone)] pub struct Routing { get_routes: Node, post_routes: Node, put_routes: Node, delete_routes: Node, …
Sanskar Jethi
  • 544
  • 5
  • 17
1
vote
1 answer

CORS POST XHR or Fetch request don't work with Actix Rust HTTP server

Could you please help me fix this issue with XHR/Fetch queries in the browser that are not working with my Actix back-end server? I tested it with Postman, it is working okay but I still get the CORS error though I added the…
Mathe Eliel
  • 658
  • 2
  • 6
  • 16
1
vote
1 answer

Rust actix-web capturing HTTP error 413 (HTTP/1.1 413 Payload Too Large)

I am using actix-web. I would like to restrict the size of post request and have the web application capture this error log it and send back an informative error message to the user. My code is given below. It seems the middleware gets run whether…
Allan K
  • 379
  • 2
  • 13
1
vote
1 answer

Handling duplicate inserts into database in async rust

Beginner in both rust and async programming here. I have a function that downloads and stores a bunch of tweets in the database: pub async fn process_user_timeline(config: &Settings, pool: &PgPool, user_object: &Value) { // get timeline if…
ilmoi
  • 1,994
  • 2
  • 21
  • 45
1
vote
2 answers

Unable to use asynchronous actors

I'm trying to use the actors as documented in the actix documentation. But even the doc example is not working for me. I tried the following code which compiles but does not print the message "Received fibo message" use actix::prelude::*; //…
b.moyet
  • 101
  • 1
  • 9
1
vote
1 answer

How do I define URL parameters in actix-web?

In NodeJS, a route can be defined like: app.get('/:x', (req, res) => { console.log(req.params.x) res.sendStatus(200) }); Is there an actix-web equivalent or a better recommended approach? I want to upload a file with an id identifier, such that…
Jonathan Woollett-light
  • 2,813
  • 5
  • 30
  • 58
1
vote
1 answer

Send file thought Actix websocket

I'm having a hard time finding documentation or tutorial in order to send a file throught a websocket. Here is my JS: ['dragleave', 'drop'].forEach(event_name => document.addEventListener(event_name, function(e) { e.preventDefault(); let files =…
Athanor
  • 855
  • 1
  • 16
  • 34
1
vote
1 answer

Run async function in run_interval and return result

I need to run an async function in actix::prelude::AsyncContext::run_interval, but I need to also pass in a struct member and return the result (not the future). This is a somewhat more complex version of this question here. As can be seen in the…
1
vote
1 answer

Return Either HTML or JSON From Actix Web Handler

I would like all of my routes to return Json instead of HTML when requested. For example, when /index.json is requested, it should return the object that the /index html response would be built with. I'm currently handling this with a "tail match"…
C-RAD
  • 1,052
  • 9
  • 18
1
vote
0 answers

How to return multiple types from a function?

I'm using actix_web for my handlers and I've stumbled across a problem. I'd like to return a web::Json with 1 out of 2 types depending on the parameters. I have something like this which doesn't compile because impl can only be one…
Patryk
  • 22,602
  • 44
  • 128
  • 244
1
vote
1 answer

How to send a message to another actor from actix SyncContext?

I would like to implement a long running background task that can report progress to other Actors. I already accomplished that. But I would also like to be able to cancel the long running background task again. What I got so far is this: use…
Jonas Wolf
  • 1,154
  • 1
  • 12
  • 20
1
vote
1 answer

How to fetch response body in Decode failed error in reqwest?

Currently I can only get the error message which is error decoding response body: expected value at line 1 column 1. Apparently the reason of error is httpbin.org was returning HTML. I'm wondering how can I return that HTML to the client. use…
Joshua Jiang
  • 91
  • 1
  • 3
1
vote
2 answers

How to send an array with HttpResponse?

Is there a way to send a vector (array) through a HttpResponse with actix_web? I can send strings in the body completely fine and was hoping to send an array for the client to receive and store. This is my currently used code snippet which responds…
Yun Jae Jung
  • 139
  • 1
  • 8
1
vote
1 answer

How to execute async lua code with rlua-async?

I'm trying to run/script my existing rust async code with rlua-async. Sadly it is not well documented and has no examples but I have prevailed in getting my async functions defined but I have trouble getting my lua code executed in an async way. I…
arturh
  • 6,056
  • 4
  • 39
  • 48