diff options
author | Jake W <jake@playruyi.com> | 2018-11-12 12:43:04 +0800 |
---|---|---|
committer | James E. King III <jking@apache.org> | 2018-11-12 07:58:54 -0500 |
commit | 24918abba929282d6e405fedbc2ef68c3e894136 (patch) | |
tree | e61742925fb0622dcaa99cde768e080417da6fcf | |
parent | b57d126157938e5bba4fc55125d73e7ac5bf11a2 (diff) | |
download | thrift-24918abba929282d6e405fedbc2ef68c3e894136.tar.gz |
THRIFT-4664: Cannot create ReadHalf/WriteHalf
Client: rs
-rw-r--r-- | lib/rs/src/transport/mod.rs | 20 | ||||
-rw-r--r-- | lib/rs/src/transport/socket.rs | 5 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/rs/src/transport/mod.rs b/lib/rs/src/transport/mod.rs index 939278643..6e84bfa49 100644 --- a/lib/rs/src/transport/mod.rs +++ b/lib/rs/src/transport/mod.rs @@ -143,6 +143,26 @@ where handle: C, } +impl<C> ReadHalf<C> +where + C: Read, +{ + /// Create a `ReadHalf` associated with readable `handle` + pub fn new(handle: C) -> ReadHalf<C> { + ReadHalf { handle } + } +} + +impl<C> WriteHalf<C> +where + C: Write, +{ + /// Create a `WriteHalf` associated with writable `handle` + pub fn new(handle: C) -> WriteHalf<C> { + WriteHalf { handle } + } +} + impl<C> Read for ReadHalf<C> where C: Read, diff --git a/lib/rs/src/transport/socket.rs b/lib/rs/src/transport/socket.rs index a6f780ac8..954e2f586 100644 --- a/lib/rs/src/transport/socket.rs +++ b/lib/rs/src/transport/socket.rs @@ -133,8 +133,9 @@ impl TIoChannel for TTcpChannel { .and_then(|s| s.try_clone().ok()) .map( |cloned| { - (ReadHalf { handle: TTcpChannel { stream: s.stream.take() } }, - WriteHalf { handle: TTcpChannel { stream: Some(cloned) } }) + let read_half = ReadHalf::new( TTcpChannel { stream: s.stream.take() } ); + let write_half = WriteHalf::new( TTcpChannel { stream: Some(cloned) } ); + (read_half, write_half) }, ) .ok_or_else( |