Skip to content

Commit

Permalink
forward more read methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Oct 4, 2021
1 parent 33a3a21 commit e82099b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tokio-util/src/io/sync_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ impl<T: AsyncRead + Unpin> Read for SyncIoBridge<T> {
let src = &mut self.src;
self.rt.block_on(src.read(buf))
}

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> std::io::Result<usize> {
let src = &mut self.src;
self.rt.block_on(src.read_to_end(buf))
}

fn read_to_string(&mut self, buf: &mut String) -> std::io::Result<usize> {
let src = &mut self.src;
self.rt.block_on(src.read_to_string(buf))
}

fn read_exact(&mut self, buf: &mut [u8]) -> std::io::Result<()> {
let src = &mut self.src;
// The AsyncRead trait returns the count, synchronous doesn't.
let _n = self.rt.block_on(src.read_exact(buf))?;
Ok(())
}
}

impl<T: AsyncWrite + Unpin> Write for SyncIoBridge<T> {
Expand Down

0 comments on commit e82099b

Please sign in to comment.