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