Skip to content

Introduce AsyncInputStream, AsyncOutputStream, and stdio#37

Merged
pchickey merged 5 commits intomainfrom
pch/iostreams
Dec 28, 2024
Merged

Introduce AsyncInputStream, AsyncOutputStream, and stdio#37
pchickey merged 5 commits intomainfrom
pch/iostreams

Conversation

@pchickey
Copy link
Contributor

@pchickey pchickey commented Dec 28, 2024

and convert all of the crate's uses of InputStream/OutputStream/Pollable to use their Async wrappers.

  • new io::stdio mod introduces Stdin, Stdout, Stderr, which are wrappers (via DerefMut, is that poor form?) of AsyncInputStream / AsyncOutputStream. There's a test that has to be checked by hand by running in --nocapture for each of stdout and stderr, but no test for stdin yet. That will have to be written in the style of the tcp echo server test, in a future PR.
  • http::Request uses an AsyncOutputStream for writing body
  • http::IncomingBody uses an AsyncInputStream for reading body
  • net::TcpListener uses an AsyncPollable to await readiness with a single Pollable lasting the lifetime of the listener
  • net::TcpStream uses AsyncInputStream and AsyncOutputStream for read/write

Closes #23

* eliminate its internal OutputStream wrapper.
* fix io::copy to bubble up body copy error rather than panic.
* add http error variant for io errors on body.
this eliminates the buffering behavior that IncomingBody previously had. Will
have to define a BufReader for AsyncRead at some point so users can opt back
into that if they want it.
@pchickey pchickey merged commit 922dfcf into main Dec 28, 2024
4 checks passed
@pchickey pchickey deleted the pch/iostreams branch December 28, 2024 20:55
This was referenced Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Factor out a BufferedInputStream and impl AsyncRead for it

1 participant