Linked Questions

0 votes
1 answer
3k views

I tried to complied the following reqwest example: let client = reqwest::Client::new(); let res = client.post("http://httpbin.org/post") .body("the exact body that is sent") ...
dev's user avatar
  • 155
2 votes
1 answer
4k views

Rust newbie here (<7 days into learning), the second hurdle I am trying to overcome after ownership rule is async/await. I am writing a test that calls an async function and I need to get the ...
undefined's user avatar
  • 3,009
2 votes
1 answer
2k views

I have a program that does various simple things based on user selection. fn main() { let mut user_input = String::new(); // Initialize variable to store user input println!("Select an ...
hokkaidomelk's user avatar
1 vote
0 answers
1k views

I have been scouring the docs to find a way to call an asynchronous function synchronously. Specifically, I am trying to call tokio::sync::mutex::lock from a Display implementation to provide useful ...
Eadword's user avatar
  • 160
0 votes
1 answer
834 views

I am learning Tokio/futures and can't find a way to return the error up to the caller in the main function; is this possible? My use case is for AWS Lambda with the runtime being synchronous and ...
James's user avatar
  • 763
-1 votes
1 answer
371 views

I would like to call two functions that perform an HTTP call with reqwest on two different branches of a match: async fn list_projects() -> Result<(), reqwest::Error> { let body = ...
C Taque's user avatar
  • 1,097
95 votes
3 answers
132k views

This should be a trivial task in any language. This isn't working in Rust. use std::collections::HashMap; fn do_it(map: &mut HashMap<String, String>) { for (key, value) in map { ...
adapt-dev's user avatar
  • 1,788
69 votes
2 answers
43k views

The async example is useful, but being new to Rust and Tokio, I am struggling to work out how to do N requests at once, using URLs from a vector, and creating an iterator of the response HTML for each ...
user964375's user avatar
  • 2,471
39 votes
5 answers
26k views

I'm making a small ncurses application in Rust that needs to communicate with a child process. I already have a prototype written in Common Lisp. I'm trying to rewrite it because CL uses a huge amount ...
jkiiski's user avatar
  • 8,491
23 votes
2 answers
28k views

use std::thread; use tokio::task; // 0.3.4 #[tokio::main] async fn main() { thread::spawn(|| { task::spawn(async { println!("123"); }); }) .join(); } ...
ibse's user avatar
  • 625
19 votes
1 answer
16k views

I want to await an async function inside a closure used in an iterator. The function requiring the closure is called inside a struct implementation. I can't figure out how to do this. This code ...
Simon S.'s user avatar
  • 1,087
11 votes
1 answer
16k views

I want to poll an async function: #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { some_function().await; } I am currently activating all features: tokio =...
Gatonito's user avatar
  • 2,014
17 votes
1 answer
19k views

I have a Tokio client that talks to a remote server and is supposed to keep the connection alive permanently. I've implemented the initial authentication handshake and found that when my test ...
ruipacheco's user avatar
  • 16.7k
5 votes
2 answers
7k views

I need to explore a directory and all its sub-directories. I can explore the directory easily with recursion in a synchronous way: use failure::Error; use std::fs; use std::path::Path; fn main() -&...
Nick's user avatar
  • 10.6k
12 votes
2 answers
9k views

I have an async fn that returns a type, and want to implement Drop on that type that calls another async function. It's not clear how to do this, and I can't find anything in the docs. The most ...
Matt Joiner's user avatar

15 30 50 per page