interprocess_docfix/local_socket/tokio/stream/
write_half.rs1use {
2 futures_io::AsyncWrite,
3 std::{
4 fmt::{self, Debug, Formatter},
5 io::{self, IoSlice},
6 pin::Pin,
7 task::{Context, Poll},
8 },
9};
10
11#[cfg(feature = "tokio_support")]
12impmod! {local_socket::tokio,
13 OwnedWriteHalf as OwnedWriteHalfImpl
14}
15#[cfg(not(feature = "tokio_support"))]
16struct OwnedWriteHalfImpl;
17
18pub struct OwnedWriteHalf {
25 pub(super) inner: OwnedWriteHalfImpl,
26}
27impl OwnedWriteHalf {
28 pub fn peer_pid(&self) -> io::Result<u32> {
34 self.inner.peer_pid()
35 }
36 fn pinproj(&mut self) -> Pin<&mut OwnedWriteHalfImpl> {
37 Pin::new(&mut self.inner)
38 }
39}
40
41impl AsyncWrite for OwnedWriteHalf {
42 fn poll_write(
43 mut self: Pin<&mut Self>,
44 cx: &mut Context<'_>,
45 buf: &[u8],
46 ) -> Poll<io::Result<usize>> {
47 self.pinproj().poll_write(cx, buf)
48 }
49 fn poll_write_vectored(
50 mut self: Pin<&mut Self>,
51 cx: &mut Context<'_>,
52 bufs: &[IoSlice<'_>],
53 ) -> Poll<io::Result<usize>> {
54 self.pinproj().poll_write_vectored(cx, bufs)
55 }
56 fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
58 self.pinproj().poll_flush(cx)
59 }
60 fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
61 self.pinproj().poll_close(cx)
62 }
63}
64
65impl Debug for OwnedWriteHalf {
66 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
67 Debug::fmt(&self.inner, f)
68 }
69}
70
71