runix icon indicating copy to clipboard operation
runix copied to clipboard

Tokio-less APIs?

Open RaitoBezarius opened this issue 2 years ago • 3 comments

Hi there, thank you for the amazing package :)

I am trying to use it in a project where I would like to have a std::process::Command-like API without any tokio/async/await stuff, do you think it is possible? I can also send a PR if you tell me what would you accept as a change regarding this.

Thank you!

RaitoBezarius avatar Mar 09 '23 12:03 RaitoBezarius

Thank you!

Our usecase is very much async focused so all the command stuff is very async centric and non async ways are currently not easily exposed. Though Async stops after the Run trait and its impls.

It should be possible to define a RunSync trait and corresponding impl of a sync CommandLine backend, i.e. a sync version of https://github.com/flox/runix/blob/3112401dc888111b7a074cbf4a52ebb2cd51e45b/crates/runix/src/command_line/mod.rs#L216-L255

If we go down that path both async and sync impls should share as much code as possible, so they do not become a maintenance burden

ysndr avatar Mar 09 '23 16:03 ysndr

Would you think it would make sense to gate sync APIs behind a feature and make it non default to reduce more the maintenance burden?

Le jeu. 9 mars 2023 à 17:57, Yannik Sander @.***> a écrit :

Thank you!

Our usecase is very much async focused so all the command stuff is very async centric and non async ways are currently not easily exposed. Though Async stops after the Run trait and its impls.

It should be possible to define a RunSync trait and corresponding impl of a sync CommandLine backend, i.e. a sync version of https://github.com/flox/runix/blob/3112401dc888111b7a074cbf4a52ebb2cd51e45b/crates/runix/src/command_line/mod.rs#L216-L255

If we go down that path both async and sync impls should share as much code as possible, so they do not become a maintenance burden

— Reply to this email directly, view it on GitHub https://github.com/flox/runix/issues/6#issuecomment-1462416669, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACMZRE7DBANJEIGZTWVTBDW3IDXRANCNFSM6AAAAAAVVBFHIM . You are receiving this because you authored the thread.Message ID: @.***>

RaitoBezarius avatar Mar 09 '23 17:03 RaitoBezarius

Putting it behind feature flags in either direction would make sense. Either way, we should look to share everything but the lines that are related to async commands. https://github.com/flox/runix/blob/3112401dc888111b7a074cbf4a52ebb2cd51e45b/crates/runix/src/command_line/mod.rs#L245-L254

n.b. its able to "downgrade" a tokio command to an std command, perhaps its possible to go the other way around as well. than it should be a fairly minimal difference.

ysndr avatar Mar 09 '23 17:03 ysndr