You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2021/08/22 17:03:00 UTC
[jira] [Updated] (THRIFT-5339) Add `TObject` trait to cover sync
read & write methods of Struct/Union/Enum
[ https://issues.apache.org/jira/browse/THRIFT-5339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jens Geyer updated THRIFT-5339:
-------------------------------
Summary: Add `TObject` trait to cover sync read & write methods of Struct/Union/Enum (was: [Rust] Add `TObject` trait to cover sync read & write methods of Struct/Union/Enum)
> Add `TObject` trait to cover sync read & write methods of Struct/Union/Enum
> ---------------------------------------------------------------------------
>
> Key: THRIFT-5339
> URL: https://issues.apache.org/jira/browse/THRIFT-5339
> Project: Thrift
> Issue Type: New Feature
> Components: Rust - Compiler
> Affects Versions: 0.13.0
> Reporter: Jason Shui
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Each Struct/Union/Enum generated by thrift-compiler will get two methods: `read_from_in_protocol` and `write_to_out_protocol`.
> Firstly, I think these two methods are representing a certain ability of serialization, so they should be put in a trait;
> Moreover, if this trait is provided, we can use trait bounding in our user codes, such as
> ```rust
> // pseudo code
> fn serialize_struct<T>(s: T) -> Vec<u8> where T: TObject
> { s.write_to_out_protocol(protocol); // do other things.. }
> ```
> It could also be a pretty useful marker trait as you can see.
> The name of `TObject` is only a superficial opinion, but I believe that there are enough reasons to make the trait.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)