diff --git a/src/local_socket.rs b/src/local_socket.rs index 6040715..a6adc2e 100644 --- a/src/local_socket.rs +++ b/src/local_socket.rs @@ -129,19 +129,3 @@ pub mod tokio { mod concurrency_detector; pub(crate) use concurrency_detector::*; - -use std::io; - -#[cold] -pub(crate) fn flush_unsupported() -> io::Result<()> { - Err(io::Error::new( - io::ErrorKind::Unsupported, - "local sockets cannot be flushed", - )) -} - -#[cfg(feature = "tokio")] -#[cold] -pub(crate) fn async_flush_unsupported() -> std::task::Poll> { - flush_unsupported().into() -} diff --git a/src/local_socket/stream/enum.rs b/src/local_socket/stream/enum.rs index 5144c5b..142a780 100644 --- a/src/local_socket/stream/enum.rs +++ b/src/local_socket/stream/enum.rs @@ -3,10 +3,7 @@ use super::r#trait; use crate::os::unix::uds_local_socket as uds_impl; #[cfg(windows)] use crate::os::windows::named_pipe::local_socket as np_impl; -use crate::{ - local_socket::{flush_unsupported, Name}, - TryClone, -}; +use crate::{local_socket::Name, TryClone}; use std::io::{self, prelude::*, IoSlice, IoSliceMut}; impmod! {local_socket::dispatch_sync} @@ -39,7 +36,7 @@ macro_rules! dispatch_write { } #[inline] fn flush(&mut self) -> io::Result<()> { - flush_unsupported() + Ok(()) } #[inline] fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result { @@ -47,11 +44,11 @@ macro_rules! dispatch_write { } }; ($ty:ident) => { - /// Flushing fails with [`Unsupported`](io::ErrorKind::Unsupported). + /// Flushing is an always successful no-op. impl Write for &$ty { dispatch_write!(@iw $ty); } - /// Flushing fails with [`Unsupported`](io::ErrorKind::Unsupported). + /// Flushing is an always successful no-op. impl Write for $ty { dispatch_write!(@iw $ty); } diff --git a/src/local_socket/tokio/stream/enum.rs b/src/local_socket/tokio/stream/enum.rs index 1e54090..4f8139f 100644 --- a/src/local_socket/tokio/stream/enum.rs +++ b/src/local_socket/tokio/stream/enum.rs @@ -1,5 +1,5 @@ use super::r#trait; -use crate::local_socket::{async_flush_unsupported, Name}; +use crate::local_socket::Name; #[cfg(unix)] use crate::os::unix::uds_local_socket::tokio as uds_impl; #[cfg(windows)] @@ -37,7 +37,7 @@ macro_rules! dispatch_write { } #[inline] fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { - async_flush_unsupported() + Poll::Ready(Ok(())) } #[inline] fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { @@ -45,9 +45,11 @@ macro_rules! dispatch_write { } }; ($ty:ident) => { + /// Flushing is an always successful no-op. impl AsyncWrite for &$ty { dispatch_write!(@iw $ty); } + /// Flushing is an always successful no-op. impl AsyncWrite for $ty { dispatch_write!(@iw $ty); } diff --git a/src/os/unix/uds_local_socket/stream.rs b/src/os/unix/uds_local_socket/stream.rs index 97e6dfb..5c09ad7 100644 --- a/src/os/unix/uds_local_socket/stream.rs +++ b/src/os/unix/uds_local_socket/stream.rs @@ -2,7 +2,6 @@ use super::name_to_addr; use crate::{ error::ReuniteError, local_socket::{ - flush_unsupported, traits::{self, ReuniteResult}, ConcurrencyDetector, LocalSocketSite, Name, }, @@ -69,7 +68,7 @@ impl Write for &Stream { } #[inline] fn flush(&mut self) -> io::Result<()> { - flush_unsupported() + Ok(()) } // FUTURE is_write_vectored } diff --git a/src/os/unix/uds_local_socket/tokio/stream.rs b/src/os/unix/uds_local_socket/tokio/stream.rs index e5da5f9..39b715b 100644 --- a/src/os/unix/uds_local_socket/tokio/stream.rs +++ b/src/os/unix/uds_local_socket/tokio/stream.rs @@ -1,7 +1,7 @@ use super::super::name_to_addr; use crate::{ error::ReuniteError, - local_socket::{async_flush_unsupported, traits::tokio as traits, Name}, + local_socket::{traits::tokio as traits, Name}, os::unix::c_wrappers, Sealed, }; @@ -132,7 +132,7 @@ impl AsyncWrite for &Stream { } #[inline] fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { - async_flush_unsupported() + Ok(()) } #[inline] fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { @@ -229,7 +229,7 @@ impl AsyncWrite for &SendHalf { } #[inline] fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { - async_flush_unsupported() + Ok(()) } #[inline] fn poll_shutdown(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { diff --git a/src/os/windows/named_pipe/local_socket/stream.rs b/src/os/windows/named_pipe/local_socket/stream.rs index 7165521..92e311a 100644 --- a/src/os/windows/named_pipe/local_socket/stream.rs +++ b/src/os/windows/named_pipe/local_socket/stream.rs @@ -1,7 +1,6 @@ use crate::{ error::{FromHandleError, ReuniteError}, local_socket::{ - flush_unsupported, traits::{self, ReuniteResult}, Name, }, @@ -68,7 +67,7 @@ impl Write for &Stream { #[inline] fn flush(&mut self) -> io::Result<()> { - flush_unsupported() + Ok(()) } // FUTURE is_write_vectored } @@ -145,7 +144,7 @@ impl Write for &SendHalf { #[inline] fn flush(&mut self) -> io::Result<()> { - flush_unsupported() + Ok(()) } // FUTURE is_write_vectored } diff --git a/src/os/windows/named_pipe/local_socket/tokio/stream.rs b/src/os/windows/named_pipe/local_socket/tokio/stream.rs index 9c2fdd3..d5b8ea1 100644 --- a/src/os/windows/named_pipe/local_socket/tokio/stream.rs +++ b/src/os/windows/named_pipe/local_socket/tokio/stream.rs @@ -1,7 +1,6 @@ use crate::{ error::{FromHandleError, ReuniteError}, local_socket::{ - async_flush_unsupported, traits::tokio::{self as traits, ReuniteResult}, Name, }, @@ -65,7 +64,7 @@ impl AsyncWrite for &Stream { } #[inline] fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { - async_flush_unsupported() + Poll::Ready(Ok(())) } #[inline] fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { @@ -132,7 +131,7 @@ impl AsyncWrite for &SendHalf { } #[inline] fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { - async_flush_unsupported() + Poll::Ready(Ok(())) } #[inline] fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {