mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-01 22:16:40 +00:00
21 lines
558 B
Rust
21 lines
558 B
Rust
use std::pin::Pin;
|
|
use std::future::Future;
|
|
|
|
use crate::io::{self, Write};
|
|
use crate::task::{Context, Poll};
|
|
|
|
#[doc(hidden)]
|
|
#[allow(missing_debug_implementations)]
|
|
pub struct WriteFuture<'a, T: Unpin + ?Sized> {
|
|
pub(crate) writer: &'a mut T,
|
|
pub(crate) buf: &'a [u8],
|
|
}
|
|
|
|
impl<T: Write + Unpin + ?Sized> Future for WriteFuture<'_, T> {
|
|
type Output = io::Result<usize>;
|
|
|
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
let buf = self.buf;
|
|
Pin::new(&mut *self.writer).poll_write(cx, buf)
|
|
}
|
|
}
|