slack-rs / slack-rs-api

Rust interface for the Slack Web API
Apache License 2.0
109 stars 66 forks source link

Any way to use v0.22.0 without async/tokio? #91

Closed sts10 closed 4 years ago

sts10 commented 4 years ago

Help a casual programmer who can't quite wrap his head around async Rust just yet out: Is there a way to use version 0.22 of this crate without all the async goodness you all worked hard to implement? Could you maybe provide some examples in that directory?

I'm sorry I can't be more specific in my request... I'm feeling a bit lost with these cryptic error messages.

The reason I want to upgrade to 0.22 is for all the other features and debugging you've implemented.

dten commented 4 years ago

Hey. 0.22 isn't async (the tagged release commit), but master in the repo is and we haven't released a 0.23 yet. If you're targeting the repo directly you can specify the revision before the async merge instead of master branch in your cargo toml (rev = "305a920086af5733606b96d86a310cfab0a7b018”) I wasn't sure if anyone would ask but since you've pretty quickly asked about it then I should look at making it have sync feature. You can also create a tokio runtime and use the block_on functions to run a future without using await. I did that in an app that was using iron still but needed some library that was only async

dten commented 4 years ago

https://docs.rs/tokio/0.2.20/tokio/runtime/struct.Runtime.html#method.block_on

Shows roughly how to evaluate a future with blocking

sts10 commented 4 years ago

Thanks so much for your quick response to my frantic and a little impolite note!

I'm going to wrestle with this a bit more -- hopefully not creating more issues in desperation/panic as I go -- over the next few days and weeks. I did end up managing to get an async version of my tool -- with the latest version of slack-rs-api directly from GitHub -- compiling and hopefully working, mostly by dropping in a lot .awaits and asyncs based on the error message the compiler threw at me. I don't feel great about it, but hopefully I can learn what I did in retrospect and be able to maintain and add to it.

That said, it would be nice if there was a simpler, "sync" option available and kept up-to-date with the API? Either way, thanks again for working on this crate and responding to my terrible issue so quickly.

dten commented 4 years ago

That's good to hear! Async will only increase when it comes to networking crates but thankfully the compiler is here to help. There's loads of great resources that info async about, but even then it can be a little mysterious. I suggest the async book

https://rust-lang.github.io/async-book/01_getting_started/04_async_await_primer.html