rust-tokio Questions

3

Solved

I am trying to make a get request to a url with rust and everytime I run this project I get this error, my other rust project work fine. here's my cargo.toml file. [package] name = "api_req&qu...
Juju asked 25/5, 2022 at 16:39

1

I ran into the kind of a problem described in this question: How can I create a Tokio runtime inside another Tokio runtime without getting the error "Cannot start a runtime from within a runti...
Photodrama asked 27/10, 2021 at 9:23

2

Solved

I'm attempting to copy a file downloaded with reqwest in to a tokio file. This file is too large to store in memory so it needs to be through the bytes_stream() rather than bytes() I had attempted ...
Chivalric asked 2/11, 2022 at 0:22

4

Solved

I want to write a server using the current master branch of Hyper that saves a message that is delivered by a POST request and sends this message to every incoming GET request. I have this, mostly...
Tuft asked 14/4, 2017 at 22:21

5

Solved

I'm following the mdns Rust documentation and pasted the example code but it throws the following error: thread 'main' panicked at 'there is no reactor running, must be called from the context of T...
Toboggan asked 11/11, 2020 at 3:8

4

Solved

I have a trait that I'm using to abstract away tokio::net::TcpStream and tokio::net::UnixStream: /// Interface for TcpStream and UnixStream. trait TryRead { // overlapping the name makes it hard t...
Ashwin asked 27/1, 2021 at 14:51

1

Solved

everybody. let rt = tokio::runtime::Runtime::new().unwrap(); This code doesn't work when I try to build wasm. let rt = tokio::runtime::Runtime::new().unwrap(); | ^^^^^^^ could not find `Runtime` ...
Kondon asked 1/11, 2023 at 10:45

2

Solved

Background: I have a process using tokio::process to spawn child processes with handles in the tokio runtime. It is also responsible for freeing the resources after killing a child and, according ...
Clevelandclevenger asked 5/4, 2020 at 11:29

3

Solved

I have an async method that should execute some futures in parallel, and only return after all futures finished. However, it is passed some data by reference that does not live as long as 'static (...
Heathenry asked 12/12, 2020 at 20:56

1

Solved

I am trying to make a multithreaded tcp communication program in rust the idea is that there exists a listening socket on the main thread, and as connections come in the work is handled by worker t...
Mockup asked 24/3, 2023 at 16:16

2

Solved

Async runtimes for Rust like tokio provide "asyncified" copies of many standard functions, including some file IO ones, which work by basically just summoning the corresponding blocking t...
Slavery asked 5/1, 2022 at 20:39

2

Solved

I'm facing a scenario where I need to run async code from the drop handler of an object. The whole application runs in a tokio async context, so I know that the drop handler is called with an activ...
Hildy asked 19/3, 2022 at 20:23

2

The rng crate is neither Sync nor Send, so the rng::thread_rng can not cross the .await point. What is the simplest and beautiful way to generate random numbers in async rust? Generating A lot of n...
Order asked 8/5, 2021 at 3:34

2

Solved

I am used to Scala's Future type where you wrap whatever object you're returning in Future[..] to designate it as such. My Rust function hello returns Query and I don't seem able to pass that resul...
Acme asked 31/8, 2021 at 18:28

2

Solved

In Node.js I can set the interval that a certain event should be triggered, function intervalFunc() { console.log('whelp, triggered again!'); } setInterval(intervalFunc, 1500); However the inter...
Agape asked 30/3, 2021 at 0:40

1

Solved

I want to run two Future in parallel, and if possible in different threads : try_join!( tokio::spawn(fut1), // fut1 is not 'static tokio::spawn(fut2) )?; If my understanding is correct, tokio::s...
Coleen asked 20/12, 2022 at 15:38

2

Solved

I know tokio allows to write concurrent code. But I'm not sure if it runs in parallel. My computer has eight cores. So ideally I would run no more than eight threads. If I needed more concurrency I...
Cris asked 30/1, 2021 at 18:31

1

Solved

In the task documentation, there's a section that talks about calling blocking code in async, and how that should be avoided as to not block the async thread too much (https://docs.rs/tokio/1.21.2/...
Microbiology asked 23/11, 2022 at 13:26

2

When I cargo run, I get met with error: failed to run custom build command for `ring v0.16.20` --- stderr running "gcc.exe" "-O0" "-ffunction-sections" "-fdata...
Xerophilous asked 27/6, 2021 at 9:58

4

I have a Rust async server based on the Tokio runtime. It has to process a mix of latency-sensitive I/O-bound requests, and heavy CPU-bound requests. I don't want to let the CPU-bound tasks monopo...
Panter asked 12/5, 2020 at 13:25

2

Solved

I implemented TCP client using tokio. However, my code not compile because I got an error: error: future cannot be sent between threads safely --> src/main.rs:81:9 | 81 | tokio::spawn(async mo...
Rafa asked 14/6, 2022 at 15:27

1

Solved

What is an "async" mutex as opposed to a "normal" mutex? I believe this is the difference between tokio's Mutex and the normal std lib Mutex. But I don't get, conceptually, how ...
Tome asked 24/9, 2022 at 20:54

2

Solved

I am trying to use the read and write of a tcp stream in different threads. This is what I currently have: use tokio::prelude::*; use tokio::net::TcpStream; #[tokio::main] async fn main() -> R...
Acaroid asked 5/6, 2020 at 16:32

1

Solved

I'm attempting to build a multithreaded application using MPSC and I'm running into the error in the title. I'm not sure what the proper pattern for this use case is - I'm looking for a pattern tha...
Analogous asked 16/8, 2022 at 4:12

3

Solved

Imagine that some futures are stored in a Vec whose length are runtime-determined, you are supposed to join these futures concurrently, what should you do? Obviously, by the example in the document...
Sousa asked 26/8, 2020 at 2:34

© 2022 - 2024 — McMap. All rights reserved.