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

Allen George commented on THRIFT-2945:
--------------------------------------

I'm sorry - I don't have any idea about XCode :( I use both CLion and Visual 
Studio Code for C++ work.

I'm unsatisfied with the entire {{Rc<RefCell<Box<...>>>}} business as well; it 
was easily the most frustrating thing in working with Rust: how semantics that 
are easy to express in many other languages become extremely convoluted in 
Rust. I posted many questions on the various Rust forums about better solutions 
given the problem constraints, but didn't receive any better options.

Here are the problem constraints:

# You must be able to choose any combination of io-channel, transport, protocol 
at runtime. See the 
[cross-test|https://github.com/apache/thrift/blob/master/test/rs/src/bin/test_client.rs#L71]
 for a concrete example.
# A single *IO channel* (i.e. tcp socket, unix socket, memory) may be _shared 
by both_ the input transport and the output transport. Alternatively, each 
transport may have its own IO channel.
# A single *transport* may be _shared by both_ the input protocol and the 
output protocol. Alternatively, each protocol may have its own transport.
# I want to write test code that _preserves the type_ of the wrapped IO-channel 
or transport.

* The most maintainable way to achieve *1* is write code like:
{noformat}
let channel = create_io_channel(&channel_type, ...);
let transport = create_transport(&transport_type, &mut channel);
let input_protocol = create_input_protocol(&input_protocol_type, 
transport.clone());
let output_protocol = create_output_protocol(&output_protocol_type, 
transport.clone());
{noformat}
Unfortunately this means that channel and transport have to be trait-boxed 
because you don't know the exact type coming out of the {{create_io_channel}} 
and {{create_transport}} constructor functions.
* The sharing requirements of *2* and *3* require that types are wrapped in a 
{{Rc<RefCell<...>>}}.
* Boxing the types returned by the {{create_io_channel}} and 
{{create_transport}} constructor functions mean that you lose type information 
and can't downcast to the concrete type because boxed pointers are different 
from struct pointers. This requires the annoying {{TPassThruTransport}} that 
takes the underlying type using generics and can be boxed and shared etc. etc.

If you can propose a cleaner solution that meets all the criteria that'd be 
great!

> Implement support for Rust language
> -----------------------------------
>
>                 Key: THRIFT-2945
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2945
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Rust - Compiler, Rust - Library
>            Reporter: Maksim Golov
>            Assignee: Allen George
>             Fix For: 0.11.0
>
>
> Work on implementing support for Rust is in progress: 
> https://github.com/maximg/thrift by Simon Génier and myself.
> It will probably take quite some time to complete. Please keep us updated if 
> there are changes related to our work.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to