From e82099bdc42267cac793452a46edf22065d30bd5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 4 Oct 2021 14:15:21 -0400 Subject: [PATCH] forward more read methods --- tokio-util/src/io/sync_bridge.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tokio-util/src/io/sync_bridge.rs b/tokio-util/src/io/sync_bridge.rs index 998c13dd563..f61a75a7a13 100644 --- a/tokio-util/src/io/sync_bridge.rs +++ b/tokio-util/src/io/sync_bridge.rs @@ -14,6 +14,23 @@ impl Read for SyncIoBridge { let src = &mut self.src; self.rt.block_on(src.read(buf)) } + + fn read_to_end(&mut self, buf: &mut Vec) -> std::io::Result { + 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 { + 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 Write for SyncIoBridge {