Skip to content

Commit 59a0311

Browse files
committed
impl poll_flush and poll_shutdown
1 parent 09b79fd commit 59a0311

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/ucp/endpoint/util.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,23 @@ impl<'a> AsyncWrite for WriteStream<'a> {
8787
}
8888

8989
fn poll_flush(
90-
self: Pin<&mut Self>,
91-
_cx: &mut std::task::Context<'_>,
90+
mut self: Pin<&mut Self>,
91+
cx: &mut std::task::Context<'_>,
9292
) -> Poll<Result<(), std::io::Error>> {
93-
todo!()
93+
if let Some(mut req) = self.as_mut().project().request.as_pin_mut() {
94+
let r = ready!(req.poll_unpin(cx));
95+
self.request = None;
96+
Poll::Ready(r.map_err(|e| e.into()))
97+
} else {
98+
Poll::Ready(Ok(()))
99+
}
94100
}
95101

96102
fn poll_shutdown(
97103
self: Pin<&mut Self>,
98104
_cx: &mut std::task::Context<'_>,
99105
) -> Poll<Result<(), std::io::Error>> {
100-
todo!()
106+
Poll::Ready(Ok(()))
101107
}
102108
}
103109

@@ -191,17 +197,23 @@ impl<'a> AsyncWrite for TagWriteStream<'a> {
191197
}
192198

193199
fn poll_flush(
194-
self: Pin<&mut Self>,
195-
_cx: &mut std::task::Context<'_>,
200+
mut self: Pin<&mut Self>,
201+
cx: &mut std::task::Context<'_>,
196202
) -> Poll<Result<(), std::io::Error>> {
197-
todo!()
203+
if let Some(mut req) = self.as_mut().project().request.as_pin_mut() {
204+
let r = ready!(req.poll_unpin(cx));
205+
self.request = None;
206+
Poll::Ready(r.map_err(|e| e.into()))
207+
} else {
208+
Poll::Ready(Ok(()))
209+
}
198210
}
199211

200212
fn poll_shutdown(
201213
self: Pin<&mut Self>,
202214
_cx: &mut std::task::Context<'_>,
203215
) -> Poll<Result<(), std::io::Error>> {
204-
todo!()
216+
Poll::Ready(Ok(()))
205217
}
206218
}
207219

0 commit comments

Comments
 (0)