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

rs compact protocol collection elem type to ttype mapping wrong

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 0.13.0
    • None
    • Rust - Library
    • None

    Description

      collection_u8_to_type only overrides bool, but in spec, other types are different too. 

      In field:

      • BOOLEAN_TRUE, encoded as 1
      • BOOLEAN_FALSE, encoded as 2
      • BYTE, encoded as 3
      • I16, encoded as 4
      • I32, encoded as 5
      • I64, encoded as 6
      • DOUBLE, encoded as 7
      • BINARY, used for binary and string fields, encoded as 8
      • LIST, encoded as 9
      • SET, encoded as 10
      • MAP, encoded as 11
      • STRUCT, used for both structs and union fields, encoded as 12

      In colleciton:

      • BOOL, encoded as 2
      • BYTE, encoded as 3
      • DOUBLE, encoded as 4
      • I16, encoded as 6
      • I32, encoded as 8
      • I64, encoded as 10
      • STRING, used for binary and string fields, encoded as 11
      • STRUCT, used for structs and union fields, encoded as 12
      • MAP, encoded as 13
      • SET, encoded as 14
      • LIST, encoded as 15
      // code placeholder
      fn collection_u8_to_type(b: u8) -> crate::Result<TType> {    
        match b {     
         0x01 => Ok(TType::Bool), 
         o => u8_to_type(o),  
        }
      }
      
      fn u8_to_type(b: u8) -> crate::Result<TType> {    
        match b {        
              0x00 => Ok(TType::Stop),
              0x03 => Ok(TType::I08), // equivalent to TType::Byte
              0x04 => Ok(TType::I16),
              0x05 => Ok(TType::I32),
              0x06 => Ok(TType::I64),
              0x07 => Ok(TType::Double),
              0x08 => Ok(TType::String),
              0x09 => Ok(TType::List),
              0x0A => Ok(TType::Set),
              0x0B => Ok(TType::Map),
              0x0C => Ok(TType::Struct),
              unkn => Err(crate::Error::Protocol(crate::ProtocolError {            kind: crate::ProtocolErrorKind::InvalidData,            message: format!("cannot convert {} into TType", unkn), 
             })),    
      }}
      

       

      Attachments

        1. Screen Shot 2020-11-02 at 16.31.09.png
          188 kB
          Allen George
        2. Screen Shot 2020-11-02 at 16.31.31.png
          177 kB
          Allen George

        Activity

          People

            allengeorge Allen George
            shuoli84 shuo li
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: