thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4664) Rust cannot create ReadHalf/WriteHalf to implement custom tranports
Date Mon, 12 Nov 2018 12:59:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683769#comment-16683769
] 

ASF GitHub Bot commented on THRIFT-4664:
----------------------------------------

jeking3 closed pull request #1627: THRIFT-4664: Rust cannot create ReadHalf/WriteHalf
URL: https://github.com/apache/thrift/pull/1627
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lib/rs/src/transport/mod.rs b/lib/rs/src/transport/mod.rs
index 939278643b..6e84bfa492 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 a6f780ac8c..954e2f5866 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(


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Rust cannot create ReadHalf/WriteHalf to implement custom tranports
> -------------------------------------------------------------------
>
>                 Key: THRIFT-4664
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4664
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Rust - Library
>    Affects Versions: 0.11.0
>         Environment: C:\Users\jake>rustup show
> Default host: x86_64-pc-windows-msvc
> stable-x86_64-pc-windows-msvc (default)
> rustc 1.30.0 (da5f414c2 2018-10-24)
>            Reporter: J W
>            Assignee: Allen George
>            Priority: Minor
>
> To implement custom transports ("channels") looks like the intention is:
>  # Optionally, `impl TIoChannel for XXX` providing a split()
>  # Create `ReadHalf` and `WriteHalf` as passed to various `XXXProtocol::new()` associated
functions
> Problems is:
> {code:java}
> use thrift::transport::{
>   TIoChannel,
>   ReadHalf,
>   WriteHalf,
> };
> impl TIoChannel for TNngChannel {
> fn split(self) -> thrift::Result<(ReadHalf<Self>, WriteHalf<Self>)>
where Self: Sized,
> {
>     //SNIP
>     Ok((
>     ReadHalf { handle: self },
>     WriteHalf { handle: clone }
>     ))
> }
> {code}
> Results in:
>  error[E0451]: field `handle` of struct `thrift::transport::ReadHalf` is private
>  --> runng-thrift\src\nng_channel.rs:57:24
> 57 | ReadHalf \{ handle: self },
>  
> ^^^^^^^^^^^^ field `handle` is private
>  
> To enable creation of custom tranports/channels need to be able to create `ReadHalf`
and `WriteHalf` from outside the crate.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message