postgrest-rs icon indicating copy to clipboard operation
postgrest-rs copied to clipboard

Add reqwest's blocking Client feature

Open StepanTheGreat opened this issue 1 year ago • 0 comments
trafficstars

Feature request

Is your feature request related to a problem? Please describe.

Currently Postgrest is only usable inside tokio's runtime. That's sufficient for most applications, but there are some environments that either have a different future crate, or just can't afford to use tokio (heavy binary footprint).

In my case, I'm using bevy that support only futures_lite futures. There is a way to use tokio, but it's painful and it just loses the point of using tokio in the first place (you have to manually poll it. An overkill just to use postgrest).

Describe the solution you'd like

My solution would be to create a crate feature blocking (like in reqwest), which contains the blocking module, where Postgrest uses the blocking reqwest client instead. The logic should be absolutely the same:

use postgrest::blocking::Postgrest;

let pg = Postgrest::new(url);

Describe alternatives you've considered

Currently none. Just use the postgrest syntax directly with blocking reqwest or ureq.

Additional context

The feature can also be very useful not only in game development, but for simple apps in general that can afford to block the current thread.

StepanTheGreat avatar Apr 10 '24 15:04 StepanTheGreat