Asyncronously flush the output stream. Initiates a flush, and then awaits until the flush is complete and the output stream is ready for writing again. This method is the same as [`AsyncWrite::flush`], but doesn't require a `&mut self`. Fails with a `std::io::Error` indicating either an error returned by the stream flush, using the debug string provided by the WASI error, or else that the stream
(&self)
| 305 | /// or else that the stream is closed, indicated by |
| 306 | /// `std::io::ErrorKind::ConnectionReset`. |
| 307 | pub async fn flush(&self) -> std::io::Result<()> { |
| 308 | match self.stream.flush() { |
| 309 | Ok(()) => { |
| 310 | self.ready().await; |
| 311 | Ok(()) |
| 312 | } |
| 313 | Err(StreamError::Closed) => { |
| 314 | Err(std::io::Error::from(std::io::ErrorKind::ConnectionReset)) |
| 315 | } |
| 316 | Err(StreamError::LastOperationFailed(err)) => { |
| 317 | Err(std::io::Error::other(err.to_debug_string())) |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | impl AsyncWrite for AsyncOutputStream { |