51 questions
1
vote
1
answer
63
views
Can a rust function work with an async callback as well as with a blocking one?
I have a rust struct that owns a cache of fetched robots.txt instances and a function to check whether my bot is allowed to crawl an url:
pub fn check(&mut self, url: &Url, fetcher: &...
-1
votes
1
answer
98
views
Ntex server unreachable to cUrl from test session, but reachable from other shell...at the same time
I am trying to test a simple ntex server.
This is the whole code inside the test:
use ntex::{web, web::test};
use shopp::config;
#[ntex::test]
async fn health_check_works() {
let app = test::...
1
vote
1
answer
450
views
future created by async block is not `Send` in Rust API
I have the following error in my Rust API.
error: future cannot be sent between threads safely
--> src/bin/server/server.rs:115:5
|
115 | / {
116 | | info!("...
0
votes
0
answers
42
views
Async Rust task is only polled once [duplicate]
I’ve been trying to develop a program using async Rust and async-std crate. Because of the environment in which the code will run, I’m using 2 threads: the main thread and a secondary IO thread, both ...
1
vote
1
answer
763
views
Suppressing external library logs in a tokio tracing subscriber
Note - This is not duplicate of How to turn off tracing events emitted by other crates?. The suggested question answers filtering all the logs emitted by other crates, however this question is to ...
0
votes
1
answer
316
views
async-std::net:TcpStream read function does not return although data is available
Hi I have a strange bug that I am debugging for a few days now.
I am using async-std::net::TcpStream as part of a larger program like this:
// init socket and connection
let socket = std::net::...
2
votes
0
answers
460
views
Rust - async-std's "tokio1" feature, how it works?
There is a feature flag on async-std: tokio1
async-std = { version = "1", features = ["tokio1", "attributes"] }
Then I can use async_std::main on tokio stuff:
#[...
1
vote
2
answers
2k
views
Is there any performance advantage to use async/await amid synchronous code?
Im trying to understand when to use async and when it can improve performance.
I know it’s most-powerful in replacing otherwise-blocking IO operations like file IO, http calls, database operations, ...
1
vote
1
answer
113
views
Rust compiler does not unify types that both `impl Future<Output=()>` in branches of `if let` expression
While trying to create a Future conditionally, for later use with select_biased!:
let mut heartbeat_timer = if let ServerState::Leader(_, _, _) = server_state {
// if we're ...
0
votes
0
answers
410
views
Async middleware, get async result before calling next middleware
I'm trying to create a middleware with redis and actix-web.
This is what I want for my middleware:
-> Concat the request path and query_string, to create a redis key.
-> Get the value stored ...
1
vote
1
answer
570
views
AsyncRead for UdpSocket
I'm trying to implement AsyncRead for a UdpSocket that have an async recv function and I have some difficulties calling poll on my future:
use async_std::{
io::Read as AsyncRead,
net::...
3
votes
0
answers
1k
views
Single threaded asynchronous event loop with `winit`
I'm trying to build an NES emulator using winit, which entails building a game loop which should run exactly 60 times per second.
At first, I used std::thread to create a separate thread where the ...
1
vote
1
answer
1k
views
How to await `JoinHandle`s and update `JoinHandle`s at the same time?
Is it possible to both read a stream of Futures from a set of JoinHandle<()> tasks and update that set of tasks with new tasks at the same time?
I currently have a Service that runs some long ...
1
vote
0
answers
54
views
Why do I get "error[E0308]: mismatched types" when the function pointer types match exactly [duplicate]
I've got a scenario where I want to pass a function pointer (or closure) that takes a mutable reference to a struct, as a way of letting the caller initialize that struct for me.
The (very simplified) ...
1
vote
1
answer
147
views
Rust Generic Function Attempt for Async Reads
My goal is to reduce the following read_stream_***() functions into a generic fuction that can be passed different streams.
use async_std::net::TcpStream;
use async_std::{ task };
use async_std::io::{ ...