You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2018/11/12 12:58:59 UTC
[thrift] branch master updated: THRIFT-4664: Cannot create
ReadHalf/WriteHalf
This is an automated email from the ASF dual-hosted git repository.
jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 24918ab THRIFT-4664: Cannot create ReadHalf/WriteHalf
24918ab is described below
commit 24918abba929282d6e405fedbc2ef68c3e894136
Author: Jake W <ja...@playruyi.com>
AuthorDate: Mon Nov 12 12:43:04 2018 +0800
THRIFT-4664: Cannot create ReadHalf/WriteHalf
Client: rs
---
lib/rs/src/transport/mod.rs | 20 ++++++++++++++++++++
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 9392786..6e84bfa 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 a6f780a..954e2f5 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(