#![allow(private_bounds)]
use {
crate::{
bound_util::{RefTokioAsyncRead, RefTokioAsyncWrite},
local_socket::{traits::StreamCommon, ConnectOptions, Name},
Sealed,
},
std::{future::Future, io},
tokio::io::{AsyncRead, AsyncWrite},
};
pub trait Stream:
AsyncRead + RefTokioAsyncRead + AsyncWrite + RefTokioAsyncWrite + StreamCommon
{
#[allow(deprecated)]
type RecvHalf: RecvHalf<Stream = Self>;
#[allow(deprecated)]
type SendHalf: SendHalf<Stream = Self>;
fn connect(name: Name<'_>) -> impl Future<Output = io::Result<Self>> + Send + Sync {
async { ConnectOptions::new().name(name).connect_tokio_as::<Self>().await }
}
#[deprecated(
since = "2.4.7",
note = "\
placing a stream in an `Rc` or `Arc` achieves the same thing as splitting, since `&Stream` \
implements `AsyncRead` and `AsyncWrite`; also, dropping a half does not shut it down like it \
does with sockets, which may be counterintuitive"
)]
fn split(self) -> (Self::RecvHalf, Self::SendHalf);
#[deprecated(
since = "2.4.7",
note = "\
placing a stream in an `Rc` or `Arc` achieves the same thing as splitting, since `&Stream` \
implements `AsyncRead` and `AsyncWrite`; also, dropping a half does not shut it down like it \
does with sockets, which may be counterintuitive"
)]
#[allow(deprecated)]
fn reunite(rh: Self::RecvHalf, sh: Self::SendHalf) -> ReuniteResult<Self>;
fn from_options(
options: &ConnectOptions<'_>,
) -> impl Future<Output = io::Result<Self>> + Send + Sync;
}
#[deprecated(
since = "2.4.7",
note = "\
placing a stream in an `Rc` or `Arc` achieves the same thing as splitting, since `&Stream` \
implements `AsyncRead` and `AsyncWrite`; also, dropping a half does not shut it down like it \
does with sockets, which may be counterintuitive"
)]
pub trait RecvHalf:
AsyncRead + RefTokioAsyncRead + Send + Sync + Sized + Sealed + 'static
{
type Stream: Stream;
}
#[deprecated(
since = "2.4.7",
note = "\
placing a stream in an `Rc` or `Arc` achieves the same thing as splitting, since `&Stream` \
implements `AsyncRead` and `AsyncWrite`; also, dropping a half does not shut it down like it \
does with sockets, which may be counterintuitive"
)]
pub trait SendHalf:
AsyncWrite + RefTokioAsyncWrite + Send + Sync + Sized + Sealed + 'static
{
type Stream: Stream;
}
#[deprecated(
since = "2.4.7",
note = "\
placing a stream in an `Rc` or `Arc` achieves the same thing as splitting, since `&Stream` \
implements `AsyncRead` and `AsyncWrite`; also, dropping a half does not shut it down like it \
does with sockets, which may be counterintuitive"
)]
#[allow(deprecated)]
pub type ReuniteResult<S> =
crate::error::ReuniteResult<S, <S as Stream>::RecvHalf, <S as Stream>::SendHalf>;