Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on programming.dev

Replacing `async_std` by `smol`: What about stdin?

For my library, I want to replace async_std by smol, since the former has been deprecated in favor of the latter. This is mostly just a simple translation (different module structure, names etc.), but what I don't know is how to replace async-std's stdin. Anybody got a hint on that?

View original on programming.dev
13

4 replies

programming.dev

The readme for smol has an example for stdout. I assume stdin is the same:

        let mut stdout = Unblock::new(std::io::stdout());
        io::copy(stream, &mut stdout).await?;

And there is more information about how to use it for reading/writing on the Unblock docs.

9
lemmy.world

I've not looked too much into it, but it seems AsyncRead/AsyncBufRead (through IoSafe) is implemented for stdin. So i think you should be able to use it like that.

0

You reached the end

Replacing `async_std` by `smol`: What about stdin? | Spyke