How do i stop my API request from freezing my application?

I assume your talking about the send_message fn. The client::requestbuilder::send fn returns a future. By calling await in your send messege fn you are telling your send messege function to wait for the future to respond before it returns, so that function does nothing in terms of async for the main thread that called it.

You typically want an async workflow to be something like such to actually be helpful:

  1. Create a future (send request)
  2. Do other stuff maybe send other api requests or send some output to client
  3. Consume future and get the output (ur essentially checking if the api has returned at a later point in time, if it hasn't you will still freeze the thread until await is finished waiting)

If this can not apply to your use case then you will need to use Multithreading to solve this issue from the best of my knowledge. Not an expert on rust though so someone else here might know of another way.

/r/learnrust Thread Parent