aboutsummaryrefslogtreecommitdiff
path: root/src/io/split.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/io/split.rs')
-rw-r--r--src/io/split.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/io/split.rs b/src/io/split.rs
index 3f1b9af..81d1e6d 100644
--- a/src/io/split.rs
+++ b/src/io/split.rs
@@ -31,6 +31,13 @@ pub(super) fn split<T: AsyncRead + AsyncWrite>(t: T) -> (ReadHalf<T>, WriteHalf<
(ReadHalf { handle: a }, WriteHalf { handle: b })
}
+impl<T> ReadHalf<T> {
+ /// Checks if this `ReadHalf` and some `WriteHalf` were split from the same stream.
+ pub fn is_pair_of(&self, other: &WriteHalf<T>) -> bool {
+ self.handle.is_pair_of(&other.handle)
+ }
+}
+
impl<T: Unpin> ReadHalf<T> {
/// Attempts to put the two "halves" of a split `AsyncRead + AsyncWrite` back
/// together. Succeeds only if the `ReadHalf<T>` and `WriteHalf<T>` are
@@ -42,6 +49,13 @@ impl<T: Unpin> ReadHalf<T> {
}
}
+impl<T> WriteHalf<T> {
+ /// Checks if this `WriteHalf` and some `ReadHalf` were split from the same stream.
+ pub fn is_pair_of(&self, other: &ReadHalf<T>) -> bool {
+ self.handle.is_pair_of(&other.handle)
+ }
+}
+
impl<T: Unpin> WriteHalf<T> {
/// Attempts to put the two "halves" of a split `AsyncRead + AsyncWrite` back
/// together. Succeeds only if the `ReadHalf<T>` and `WriteHalf<T>` are