Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5339

Add `TObject` trait to cover sync read & write methods of Struct/Union/Enum

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 0.13.0
    • None
    • Rust - Compiler
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jasonshui Jason Shui
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m