mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
io: add SyncIOBridge::into_inner (#5971)
This commit is contained in:
@@ -140,4 +140,9 @@ impl<T: Unpin> SyncIoBridge<T> {
|
||||
pub fn new_with_handle(src: T, rt: tokio::runtime::Handle) -> Self {
|
||||
Self { src, rt }
|
||||
}
|
||||
|
||||
/// Consume this bridge, returning the underlying stream.
|
||||
pub fn into_inner(self) -> T {
|
||||
self.src
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,18 @@ async fn test_async_write_to_sync() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_into_inner() -> Result<(), Box<dyn Error>> {
|
||||
let mut buf = Vec::new();
|
||||
SyncIoBridge::new(tokio::io::empty())
|
||||
.into_inner()
|
||||
.read_to_end(&mut buf)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(buf.len(), 0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_shutdown() -> Result<(), Box<dyn Error>> {
|
||||
let (s1, mut s2) = tokio::io::duplex(1024);
|
||||
|
||||
Reference in New Issue
Block a user