diff --git a/pilota-build/src/codegen/workspace.rs b/pilota-build/src/codegen/workspace.rs index 72f929a9..2cff6189 100644 --- a/pilota-build/src/codegen/workspace.rs +++ b/pilota-build/src/codegen/workspace.rs @@ -184,6 +184,8 @@ where Command::new("cargo") .arg("init") .arg("--lib") + .arg("--vcs") + .arg("none") .current_dir(base_dir.as_ref()) .arg(&*info.name), )?; @@ -246,7 +248,7 @@ where def_id, kind: super::CodegenKind::RePub, })), - base_dir.as_ref(), + base_dir.as_ref().join(&*info.name).join("src").as_path(), ); if let Some(main_mod_path) = info.main_mod_path { gen_rs_stream.push_str(&format!( diff --git a/pilota-build/src/test/mod.rs b/pilota-build/src/test/mod.rs index ff8bf1dd..b594b8a7 100644 --- a/pilota-build/src/test/mod.rs +++ b/pilota-build/src/test/mod.rs @@ -1,7 +1,7 @@ #![cfg(test)] use std::{fs, path::Path}; - +use std::fs::File; use tempfile::tempdir; use crate::{plugin::SerdePlugin, IdlService}; @@ -45,7 +45,14 @@ fn diff_dir(old: impl AsRef, new: impl AsRef) { if !corresponding_new_file.exists() { panic!("File {:?} does not exist in the new directory", file_name); } - diff_file(old_file, corresponding_new_file); + + if old_file.is_file() && corresponding_new_file.is_file() { + diff_file(old_file, corresponding_new_file); + } else if !old_file.is_file() && !corresponding_new_file.is_file() { + diff_dir(old_file, corresponding_new_file) + } else { + panic!("{} and {} are not both files or directories", old_file.to_str().unwrap(), corresponding_new_file.to_str().unwrap()); + } } } @@ -85,6 +92,41 @@ fn test_with_builder( } } +fn test_with_builder_workspace( + source: impl AsRef, + target: impl AsRef, + f: F, +) { + if std::env::var("UPDATE_TEST_DATA").as_deref() == Ok("1") { + fs::remove_dir(&target); + fs::create_dir_all(&target).unwrap(); + let cargo_toml_path = target.as_ref().join("Cargo.toml"); + File::create(cargo_toml_path).unwrap(); + + f(source.as_ref(), target.as_ref()); + } else { + let dir = tempdir().unwrap(); + let path = dir.path().join( + target + .as_ref() + .file_name() + .and_then(|s| s.to_str()) + .unwrap(), + ); + let mut base_dir_tmp = path.clone(); + base_dir_tmp.pop(); + base_dir_tmp.push(path.file_stem().unwrap()); + println!("{path:?}"); + + fs::create_dir_all(&path).unwrap(); + let cargo_toml_path = path.join("Cargo.toml"); + File::create(cargo_toml_path).unwrap(); + + f(source.as_ref(), &path); + diff_dir(target, base_dir_tmp); + } +} + fn test_with_split_builder( source: impl AsRef, target: impl AsRef, @@ -125,6 +167,29 @@ fn test_thrift(source: impl AsRef, target: impl AsRef) { }); } +fn test_thrift_workspace(source: impl AsRef, target: impl AsRef) { + test_with_builder_workspace(source, target, |source, target| { + crate::Builder::thrift() + .ignore_unused(false) + .compile_with_config( + vec![IdlService::from_path(source.to_owned())], + crate::Output::Workspace(target.into()), + ) + }); +} + +fn test_thrift_workspace_with_split(source: impl AsRef, target: impl AsRef) { + test_with_builder_workspace(source, target, |source, target| { + crate::Builder::thrift() + .ignore_unused(false) + .split_generated_files(true) + .compile_with_config( + vec![IdlService::from_path(source.to_owned())], + crate::Output::Workspace(target.into()), + ) + }); +} + fn test_thrift_with_split( source: impl AsRef, target: impl AsRef, @@ -186,6 +251,56 @@ fn test_thrift_gen() { }); } +#[test] +fn test_thrift_workspace_gen() { + let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("test_data") + .join("thrift_workspace"); + + test_data_dir.read_dir().unwrap().for_each(|f| { + let f = f.unwrap(); + + let path = f.path(); + + if let Some(ext) = path.extension() { + if ext == "thrift" { + let mut dir_path = path.clone(); + let buf = dir_path.clone(); + let dir_name = buf.file_stem().unwrap(); + dir_path.pop(); + dir_path.push(dir_name); + + test_thrift_workspace(path, dir_path); + } + } + }); +} + +#[test] +fn test_thrift_workspace_with_split_gen() { + let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("test_data") + .join("thrift_workspace_with_split"); + + test_data_dir.read_dir().unwrap().for_each(|f| { + let f = f.unwrap(); + + let path = f.path(); + + if let Some(ext) = path.extension() { + if ext == "thrift" { + let mut dir_path = path.clone(); + let buf = dir_path.clone(); + let dir_name = buf.file_stem().unwrap(); + dir_path.pop(); + dir_path.push(dir_name); + + test_thrift_workspace_with_split(path, dir_path); + } + } + }); +} + #[test] fn test_thrift_gen_with_split() { let test_data_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) diff --git a/pilota-build/test_data/thrift_workspace/apache.thrift b/pilota-build/test_data/thrift_workspace/apache.thrift new file mode 100644 index 00000000..8de93e4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache.thrift @@ -0,0 +1,426 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * Contains some contributions under the Thrift Software License. + * Please see doc/old-thrift-license.txt in the Thrift distribution for + * details. + */ + +namespace c_glib TTest +namespace cpp thrift.test +namespace delphi Thrift.Test +namespace go thrifttest +namespace java thrift.test +namespace js ThriftTest +namespace lua ThriftTest +namespace netstd ThriftTest +namespace perl ThriftTest +namespace php ThriftTest +namespace py ThriftTest +namespace py.twisted ThriftTest +namespace rb Thrift.Test +namespace st ThriftTest +namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest') + +// Presence of namespaces and sub-namespaces for which there is +// no generator should compile with warnings only +// namespace noexist ThriftTest +// namespace cpp.noexist ThriftTest + +namespace * thrift.test + +/** + * Docstring! + */ +enum Numberz +{ + ONE = 1, + TWO, + THREE, + FIVE = 5, + SIX, + EIGHT = 8 +} + +const Numberz myNumberz = Numberz.ONE; +// the following is expected to fail: +// const Numberz urNumberz = ONE; + +typedef i64 UserId + +struct Bonk +{ + 1: string message, + 2: i32 type +} + +typedef map MapType + +struct Bools { + 1: bool im_true, + 2: bool im_false, +} + +struct Xtruct +{ + 1: string string_thing, + 4: i8 byte_thing, + 9: i32 i32_thing, + 11: i64 i64_thing +} + +struct Xtruct2 +{ + 1: i8 byte_thing, // used to be byte, hence the name + 2: Xtruct struct_thing, + 3: i32 i32_thing +} + +struct Xtruct3 +{ + 1: string string_thing, + 4: i32 changed, + 9: i32 i32_thing, + 11: i64 i64_thing +} + + +struct Insanity +{ + 1: map userMap, + 2: list xtructs +} (python.immutable= "") + +struct CrazyNesting { + 1: string string_field, + 2: optional set set_field, + // Do not insert line break as test/go/Makefile.am is removing this line with pattern match + 3: required list (python.immutable = ""), map(python.immutable = "")> (python.immutable = "")>>>> list_field, + 4: binary binary_field + 5: uuid uuid_field +} + +union SomeUnion { + 1: map map_thing, + 2: string string_thing, + 3: i32 i32_thing, + 4: Xtruct3 xtruct_thing, + 5: Insanity insanity_thing +} + +exception Xception { + 1: i32 errorCode, + 2: string message +} + +exception Xception2 { + 1: i32 errorCode, + 2: Xtruct struct_thing +} + +struct EmptyStruct {} + +struct OneField { + 1: EmptyStruct field +} + +service ThriftTest +{ + /** + * Prints "testVoid()" and returns nothing. + */ + void testVoid(), + + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string testString(1: string thing), + + /** + * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false' + * @param bool thing - the bool data to print + * @return bool - returns the bool 'thing' + */ + bool testBool(1: bool thing), + + /** + * Prints 'testByte("%d")' with thing as '%d' + * The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility. + * @param byte thing - the i8/byte to print + * @return i8 - returns the i8/byte 'thing' + */ + i8 testByte(1: i8 thing), + + /** + * Prints 'testI32("%d")' with thing as '%d' + * @param i32 thing - the i32 to print + * @return i32 - returns the i32 'thing' + */ + i32 testI32(1: i32 thing), + + /** + * Prints 'testI64("%d")' with thing as '%d' + * @param i64 thing - the i64 to print + * @return i64 - returns the i64 'thing' + */ + i64 testI64(1: i64 thing), + + /** + * Prints 'testDouble("%f")' with thing as '%f' + * @param double thing - the double to print + * @return double - returns the double 'thing' + */ + double testDouble(1: double thing), + + /** + * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data + * @param binary thing - the binary data to print + * @return binary - returns the binary 'thing' + */ + binary testBinary(1: binary thing), + + /** + * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct. + * @param uuid thing - the uuid to print + * @return uuid - returns the uuid 'thing' + */ + uuid testUuid(1: uuid thing), + + /** + * Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values + * @param Xtruct thing - the Xtruct to print + * @return Xtruct - returns the Xtruct 'thing' + */ + Xtruct testStruct(1: Xtruct thing), + + /** + * Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct + * @param Xtruct2 thing - the Xtruct2 to print + * @return Xtruct2 - returns the Xtruct2 'thing' + */ + Xtruct2 testNest(1: Xtruct2 thing), + + /** + * Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testMap(1: map thing), + + /** + * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testStringMap(1: map thing), + + /** + * Prints 'testSet("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param set thing - the set to print + * @return set - returns the set 'thing' + */ + set testSet(1: set thing), + + /** + * Prints 'testList("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param list thing - the list to print + * @return list - returns the list 'thing' + */ + list testList(1: list thing), + + /** + * Prints 'testEnum("%d")' where thing has been formatted into its numeric value + * @param Numberz thing - the Numberz to print + * @return Numberz - returns the Numberz 'thing' + */ + Numberz testEnum(1: Numberz thing), + + /** + * Prints 'testTypedef("%d")' with thing as '%d' + * @param UserId thing - the UserId to print + * @return UserId - returns the UserId 'thing' + */ + UserId testTypedef(1: UserId thing), + + /** + * Prints 'testMapMap("%d")' with hello as '%d' + * @param i32 hello - the i32 to print + * @return map> - returns a dictionary with these values: + * {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } + */ + map> testMapMap(1: i32 hello), + + /** + * So you think you've got this all worked out, eh? + * + * Creates a map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => , }, + * } + * @return map> - a map with the above values + */ + map> testInsanity(1: Insanity argument), + + /** + * Prints 'testMulti()' + * @param i8 arg0 - + * @param i32 arg1 - + * @param i64 arg2 - + * @param map arg3 - + * @param Numberz arg4 - + * @param UserId arg5 - + * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 + * and i64_thing = arg2 + */ + Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map arg3, 5: Numberz arg4, 6: UserId arg5), + + /** + * Print 'testException(%s)' with arg as '%s' + * @param string arg - a string indication what type of exception to throw + * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg + * else if arg == "TException" throw TException + * else do not throw anything + */ + void testException(1: string arg) throws(1: Xception err1), + + /** + * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' + * @param string arg - a string indicating what type of exception to throw + * if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" + * else if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2" + * else do not throw anything + * @return Xtruct - an Xtruct with string_thing = arg1 + */ + Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2) + + /** + * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' + * sleep 'secondsToSleep' + * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' + * @param i32 secondsToSleep - the number of seconds to sleep + */ + oneway void testOneway(1:i32 secondsToSleep) +} + +service SecondService +{ + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string secondtestString(1: string thing) +} + +struct VersioningTestV1 { + 1: i32 begin_in_both, + 3: string old_string, + 12: i32 end_in_both +} + +struct VersioningTestV2 { + 1: i32 begin_in_both, + + 2: i32 newint, + 3: i8 newbyte, + 4: i16 newshort, + 5: i64 newlong, + 6: double newdouble + 7: Bonk newstruct, + 8: list newlist, + 9: set newset, + 10: map newmap, + 11: string newstring, + 12: i32 end_in_both +} + +struct ListTypeVersioningV1 { + 1: list myints; + 2: string hello; +} + +struct ListTypeVersioningV2 { + 1: list strings; + 2: string hello; +} + +struct GuessProtocolStruct { + 7: map map_field, +} + +struct LargeDeltas { + 1: Bools b1, + 10: Bools b10, + 100: Bools b100, + 500: bool check_true, + 1000: Bools b1000, + 1500: bool check_false, + 2000: VersioningTestV2 vertwo2000, + 2500: set a_set2500, + 3000: VersioningTestV2 vertwo3000, + 4000: list big_numbers +} + +struct NestedListsI32x2 { + 1: list> integerlist +} +struct NestedListsI32x3 { + 1: list>> integerlist +} +struct NestedMixedx2 { + 1: list> int_set_list + 2: map> map_int_strset + 3: list>> map_int_strset_list +} +struct ListBonks { + 1: list bonk +} +struct NestedListsBonk { + 1: list>> bonk +} + +struct BoolTest { + 1: optional bool b = true; + 2: optional string s = "true"; +} + +struct StructA { + 1: required string s; +} + +struct StructB { + 1: optional StructA aa; + 2: required StructA ab; +} + +struct OptionalSetDefaultTest { + 1: optional set with_default = [ "test" ] +} + +struct OptionalBinary { +//1: optional set bin_set = [] + 2: optional map bin_map = {} +} diff --git a/pilota-build/test_data/thrift_workspace/apache/Cargo.toml b/pilota-build/test_data/thrift_workspace/apache/Cargo.toml new file mode 100644 index 00000000..5e265b7d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["apache", "common"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/apache/apache/Cargo.toml b/pilota-build/test_data/thrift_workspace/apache/apache/Cargo.toml new file mode 100644 index 00000000..f9e139ef --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/apache/Cargo.toml @@ -0,0 +1,19 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.common] +path = "../common" + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "apache" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/apache/apache/src/gen.rs b/pilota-build/test_data/thrift_workspace/apache/apache/src/gen.rs new file mode 100644 index 00000000..dc8bd543 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/apache/src/gen.rs @@ -0,0 +1,21922 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod apache { + #[derive(Debug, Default, Clone, PartialEq)] + pub struct LargeDeltas { + pub b1: ::std::option::Option, + + pub b10: ::std::option::Option, + + pub b100: ::std::option::Option, + + pub check_true: ::std::option::Option, + + pub b1000: ::std::option::Option, + + pub check_false: ::std::option::Option, + + pub vertwo2000: ::std::option::Option, + + pub a_set2500: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, + + pub vertwo3000: ::std::option::Option, + + pub big_numbers: ::std::option::Option<::std::vec::Vec>, + } + impl ::pilota::thrift::Message for LargeDeltas { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "LargeDeltas", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b1.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.b10.as_ref() { + __protocol.write_struct_field(10, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.b100.as_ref() { + __protocol.write_struct_field(100, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.check_true.as_ref() { + __protocol.write_bool_field(500, *value)?; + } + if let Some(value) = self.b1000.as_ref() { + __protocol.write_struct_field(1000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.check_false.as_ref() { + __protocol.write_bool_field(1500, *value)?; + } + if let Some(value) = self.vertwo2000.as_ref() { + __protocol.write_struct_field(2000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.a_set2500.as_ref() { + __protocol.write_set_field( + 2500, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.vertwo3000.as_ref() { + __protocol.write_struct_field(3000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.big_numbers.as_ref() { + __protocol.write_list_field( + 4000, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_10 = None; + let mut var_100 = None; + let mut var_500 = None; + let mut var_1000 = None; + let mut var_1500 = None; + let mut var_2000 = None; + let mut var_2500 = None; + let mut var_3000 = None; + let mut var_4000 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(10) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_10 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(100) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_100 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(500) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_500 = Some(__protocol.read_bool()?); + } + Some(1000) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(1500) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_1500 = Some(__protocol.read_bool()?); + } + Some(2000) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2500) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_2500 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + Some(3000) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_3000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(4000) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_4000 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `LargeDeltas` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + b1: var_1, + b10: var_10, + b100: var_100, + check_true: var_500, + b1000: var_1000, + check_false: var_1500, + vertwo2000: var_2000, + a_set2500: var_2500, + vertwo3000: var_3000, + big_numbers: var_4000, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_10 = None; + let mut var_100 = None; + let mut var_500 = None; + let mut var_1000 = None; + let mut var_1500 = None; + let mut var_2000 = None; + let mut var_2500 = None; + let mut var_3000 = None; + let mut var_4000 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::decode_async(__protocol).await?); + + },Some(10) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_10 = Some(::decode_async(__protocol).await?); + + },Some(100) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_100 = Some(::decode_async(__protocol).await?); + + },Some(500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_500 = Some(__protocol.read_bool().await?); + + },Some(1000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1000 = Some(::decode_async(__protocol).await?); + + },Some(1500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1500 = Some(__protocol.read_bool().await?); + + },Some(2000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2000 = Some(::decode_async(__protocol).await?); + + },Some(2500) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2500 = Some({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + }; + __protocol.read_set_end().await?; + val}); + + },Some(3000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_3000 = Some(::decode_async(__protocol).await?); + + },Some(4000) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_4000 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `LargeDeltas` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + b1: var_1, + b10: var_10, + b100: var_100, + check_true: var_500, + b1000: var_1000, + check_false: var_1500, + vertwo2000: var_2000, + a_set2500: var_2500, + vertwo3000: var_3000, + big_numbers: var_4000, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "LargeDeltas", + }) + self + .b1 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .b10 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(10), value)) + + self + .b100 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(100), value)) + + self + .check_true + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(500), *value)) + + self + .b1000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1000), value)) + + self + .check_false + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1500), *value)) + + self + .vertwo2000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2000), value)) + + self.a_set2500.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(2500), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + + self + .vertwo3000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(3000), value)) + + self.big_numbers.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(4000), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestEnumArgsRecv { + pub thing: ::common::apache::Numberz, + } + impl ::pilota::thrift::Message for ThriftTestTestEnumArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.thing).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsRecv", + }) + __protocol.i32_field_len(Some(1), (&self.thing).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestI32ArgsSend { + pub thing: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestI32ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI32ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI32ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum SecondServiceSecondtestStringResultRecv { + #[derivative(Default)] + Ok(::pilota::FastStr), + } + + impl ::pilota::thrift::Message for SecondServiceSecondtestStringResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultRecv", + })?; + match self { + SecondServiceSecondtestStringResultRecv::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = + Some(SecondServiceSecondtestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SecondServiceSecondtestStringResultRecv::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultRecv", + }) + match self { + SecondServiceSecondtestStringResultRecv::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestSetArgsRecv { + pub thing: ::pilota::AHashSet, + } + impl ::pilota::thrift::Message for ThriftTestTestSetArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestSetArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestSetArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsRecv", + }) + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestBoolArgsSend { + pub thing: bool, + } + impl ::pilota::thrift::Message for ThriftTestTestBoolArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bool_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBoolArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_1 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBoolArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsSend", + }) + __protocol.bool_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMultiExceptionException { + #[derivative(Default)] + Err1(Xception), + + Err2(Xception2), + } + + impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionException", + })?; + match self { + ThriftTestTestMultiExceptionException::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionException::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionException::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionException::Err1( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionException::Err2( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionException", + }) + match self { + ThriftTestTestMultiExceptionException::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionException::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMapArgsRecv { + pub thing: ::pilota::AHashMap, + } + impl ::pilota::thrift::Message for ThriftTestTestMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsRecv", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestVoidArgsSend {} + impl ::pilota::thrift::Message for ThriftTestTestVoidArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestVoidArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestVoidArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestExceptionException { + #[derivative(Default)] + Err1(Xception), + } + + impl ::pilota::thrift::Message for ThriftTestTestExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionException", + })?; + match self { + ThriftTestTestExceptionException::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionException", + }) + match self { + ThriftTestTestExceptionException::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStructArgsRecv { + pub thing: ::common::apache::Xtruct, + } + impl ::pilota::thrift::Message for ThriftTestTestStructArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMultiResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + } + + impl ::pilota::thrift::Message for ThriftTestTestMultiResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultRecv", + })?; + match self { + ThriftTestTestMultiResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultRecv", + }) + match self { + ThriftTestTestMultiResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestBinaryArgsRecv { + pub thing: ::pilota::Bytes, + } + impl ::pilota::thrift::Message for ThriftTestTestBinaryArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsRecv", + }) + __protocol.bytes_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub const MY_NUMBERZ: ::common::apache::Numberz = ::common::apache::Numberz::ONE; + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct StructA { + pub s: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for StructA { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "StructA" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.s).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructA` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field s is required".to_string(), + )); + }; + + let data = Self { s: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructA` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field s is required".to_string(), + ), + ); + }; + + let data = Self { s: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "StructA" }) + + __protocol.faststr_field_len(Some(1), &self.s) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMapMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap>), + } + + impl ::pilota::thrift::Message for ThriftTestTestMapMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultRecv", + })?; + match self { + ThriftTestTestMapMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32()?, + __protocol.read_i32()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ); + ret = Some(ThriftTestTestMapMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity( + map_ident.size, + ); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultRecv", + }) + match self { + ThriftTestTestMapMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestI64ArgsRecv { + pub thing: i64, + } + impl ::pilota::thrift::Message for ThriftTestTestI64ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i64_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI64ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I64 => + { + var_1 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI64ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsRecv", + }) + __protocol.i64_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct VersioningTestV1 { + pub begin_in_both: ::std::option::Option, + + pub old_string: ::std::option::Option<::pilota::FastStr>, + + pub end_in_both: ::std::option::Option, + } + impl ::pilota::thrift::Message for VersioningTestV1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "VersioningTestV1", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.begin_in_both.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.old_string.as_ref() { + __protocol.write_faststr_field(3, (value).clone())?; + } + if let Some(value) = self.end_in_both.as_ref() { + __protocol.write_i32_field(12, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_3 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr()?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + begin_in_both: var_1, + old_string: var_3, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_3 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + Some(3) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr().await?); + } + Some(12) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_12 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + begin_in_both: var_1, + old_string: var_3, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "VersioningTestV1", + }) + self + .begin_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .old_string + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(3), value)) + + self + .end_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(12), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestEnumResultRecv { + #[derivative(Default)] + Ok(::common::apache::Numberz), + } + + impl ::pilota::thrift::Message for ThriftTestTestEnumResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultRecv", + })?; + match self { + ThriftTestTestEnumResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultRecv", + }) + match self { + ThriftTestTestEnumResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestByteArgsRecv { + pub thing: i8, + } + impl ::pilota::thrift::Message for ThriftTestTestByteArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestByteArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_1 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestByteArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsRecv", + }) + __protocol.i8_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestOnewayResultSend { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for ThriftTestTestOnewayResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultSend", + })?; + match self { + ThriftTestTestOnewayResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultSend", + }) + match self { + ThriftTestTestOnewayResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestSetResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashSet), + } + + impl ::pilota::thrift::Message for ThriftTestTestSetResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultRecv", + })?; + match self { + ThriftTestTestSetResultRecv::Ok(ref value) => { + __protocol.write_set_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }; + __protocol.set_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestSetResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }; + + ret = Some(ThriftTestTestSetResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultRecv", + }) + match self { + ThriftTestTestSetResultRecv::Ok(ref value) => __protocol.set_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStringArgsRecv { + pub thing: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestStringArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap), + } + + impl ::pilota::thrift::Message for ThriftTestTestMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultRecv", + })?; + match self { + ThriftTestTestMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ); + ret = Some(ThriftTestTestMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultRecv", + }) + match self { + ThriftTestTestMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct OneField { + pub field: ::std::option::Option, + } + impl ::pilota::thrift::Message for OneField { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "OneField" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.field.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OneField` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { field: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OneField` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { field: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "OneField" }) + + self + .field + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStructResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + } + + impl ::pilota::thrift::Message for ThriftTestTestStructResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultRecv", + })?; + match self { + ThriftTestTestStructResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestStructResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestStructResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultRecv", + }) + match self { + ThriftTestTestStructResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Xtruct3 { + pub string_thing: ::std::option::Option<::pilota::FastStr>, + + pub changed: ::std::option::Option, + + pub i32_thing: ::std::option::Option, + + pub i64_thing: ::std::option::Option, + } + impl ::pilota::thrift::Message for Xtruct3 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct3" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_thing.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.changed.as_ref() { + __protocol.write_i32_field(4, *value)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(9, *value)?; + } + if let Some(value) = self.i64_thing.as_ref() { + __protocol.write_i64_field(11, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(__protocol.read_i32()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + string_thing: var_1, + changed: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_4 = Some(__protocol.read_i32().await?); + } + Some(9) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_9 = Some(__protocol.read_i32().await?); + } + Some(11) + if field_ident.field_type == ::pilota::thrift::TType::I64 => + { + var_11 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + string_thing: var_1, + changed: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct3" }) + + self + .string_thing + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .changed + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(4), *value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(9), *value)) + + self + .i64_thing + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(11), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestBinaryResultRecv { + #[derivative(Default)] + Ok(::pilota::Bytes), + } + + impl ::pilota::thrift::Message for ThriftTestTestBinaryResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultRecv", + })?; + match self { + ThriftTestTestBinaryResultRecv::Ok(ref value) => { + __protocol.write_bytes_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(ThriftTestTestBinaryResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(ThriftTestTestBinaryResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultRecv", + }) + match self { + ThriftTestTestBinaryResultRecv::Ok(ref value) => { + __protocol.bytes_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct NestedListsI32x3 { + pub integerlist: + ::std::option::Option<::std::vec::Vec<::std::vec::Vec<::std::vec::Vec>>>, + } + impl ::pilota::thrift::Message for NestedListsI32x3 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x3", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.integerlist.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::vec::Vec>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = + __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = + __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = + __protocol.read_list_begin().await?; + let mut val = + Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x3", + }) + self.integerlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::List, + el, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::I32, + el, + |__protocol, el| __protocol.i32_len(*el), + ) + }, + ) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestI64ResultRecv { + #[derivative(Default)] + Ok(i64), + } + + impl ::pilota::thrift::Message for ThriftTestTestI64ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultRecv", + })?; + match self { + ThriftTestTestI64ResultRecv::Ok(ref value) => { + __protocol.write_i64_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64()?; + __protocol.i64_len(*&field_ident); + ret = Some(ThriftTestTestI64ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64().await?; + + ret = Some(ThriftTestTestI64ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultRecv", + }) + match self { + ThriftTestTestI64ResultRecv::Ok(ref value) => { + __protocol.i64_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum SecondServiceSecondtestStringResultSend { + #[derivative(Default)] + Ok(::pilota::FastStr), + } + + impl ::pilota::thrift::Message for SecondServiceSecondtestStringResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultSend", + })?; + match self { + SecondServiceSecondtestStringResultSend::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = + Some(SecondServiceSecondtestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SecondServiceSecondtestStringResultSend::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultSend", + }) + match self { + SecondServiceSecondtestStringResultSend::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestByteResultRecv { + #[derivative(Default)] + Ok(i8), + } + + impl ::pilota::thrift::Message for ThriftTestTestByteResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultRecv", + })?; + match self { + ThriftTestTestByteResultRecv::Ok(ref value) => { + __protocol.write_i8_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8()?; + __protocol.i8_len(*&field_ident); + ret = Some(ThriftTestTestByteResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8().await?; + + ret = Some(ThriftTestTestByteResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultRecv", + }) + match self { + ThriftTestTestByteResultRecv::Ok(ref value) => { + __protocol.i8_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStringResultRecv { + #[derivative(Default)] + Ok(::pilota::FastStr), + } + + impl ::pilota::thrift::Message for ThriftTestTestStringResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultRecv", + })?; + match self { + ThriftTestTestStringResultRecv::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(ThriftTestTestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(ThriftTestTestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultRecv", + }) + match self { + ThriftTestTestStringResultRecv::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestExceptionArgsSend { + pub arg: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + ), + ); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.arg) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMultiResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + } + + impl ::pilota::thrift::Message for ThriftTestTestMultiResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultSend", + })?; + match self { + ThriftTestTestMultiResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultSend", + }) + match self { + ThriftTestTestMultiResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Bonk { + pub message: ::std::option::Option<::pilota::FastStr>, + + pub r#type: ::std::option::Option, + } + impl ::pilota::thrift::Message for Bonk { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Bonk" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.r#type.as_ref() { + __protocol.write_i32_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + message: var_1, + r#type: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_2 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + message: var_1, + r#type: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Bonk" }) + + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .r#type + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + impl Default for OptionalSetDefaultTest { + fn default() -> Self { + OptionalSetDefaultTest { + with_default: Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])), + } + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OptionalSetDefaultTest { + pub with_default: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for OptionalSetDefaultTest { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "OptionalSetDefaultTest", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.with_default.as_ref() { + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalSetDefaultTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_1.is_none() { + var_1 = Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])); + } + + let data = Self { + with_default: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `OptionalSetDefaultTest` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_1.is_none() { + var_1 = Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])); + } + + let data = Self { + with_default: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "OptionalSetDefaultTest", + }) + self.with_default.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMapMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap>), + } + + impl ::pilota::thrift::Message for ThriftTestTestMapMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultSend", + })?; + match self { + ThriftTestTestMapMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32()?, + __protocol.read_i32()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ); + ret = Some(ThriftTestTestMapMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity( + map_ident.size, + ); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultSend", + }) + match self { + ThriftTestTestMapMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ListTypeVersioningV1 { + pub myints: ::std::option::Option<::std::vec::Vec>, + + pub hello: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for ListTypeVersioningV1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV1", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.myints.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.hello.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + myints: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ListTypeVersioningV1` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + myints: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV1", + }) + self.myints.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + self + .hello + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestEnumResultSend { + #[derivative(Default)] + Ok(::common::apache::Numberz), + } + + impl ::pilota::thrift::Message for ThriftTestTestEnumResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultSend", + })?; + match self { + ThriftTestTestEnumResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultSend", + }) + match self { + ThriftTestTestEnumResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestOnewayArgsSend { + pub seconds_to_sleep: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestOnewayArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.seconds_to_sleep)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + ), + ); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.seconds_to_sleep) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestSetResultSend { + #[derivative(Default)] + Ok(::pilota::AHashSet), + } + + impl ::pilota::thrift::Message for ThriftTestTestSetResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultSend", + })?; + match self { + ThriftTestTestSetResultSend::Ok(ref value) => { + __protocol.write_set_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }; + __protocol.set_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestSetResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }; + + ret = Some(ThriftTestTestSetResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultSend", + }) + match self { + ThriftTestTestSetResultSend::Ok(ref value) => __protocol.set_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap), + } + + impl ::pilota::thrift::Message for ThriftTestTestMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultSend", + })?; + match self { + ThriftTestTestMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ); + ret = Some(ThriftTestTestMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultSend", + }) + match self { + ThriftTestTestMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestExceptionResultSend { + #[derivative(Default)] + Ok(()), + + Err1(Xception), + } + + impl ::pilota::thrift::Message for ThriftTestTestExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultSend", + })?; + match self { + ThriftTestTestExceptionResultSend::Ok(ref value) => {} + ThriftTestTestExceptionResultSend::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = + Some(ThriftTestTestExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultSend", + }) + match self { + ThriftTestTestExceptionResultSend::Ok(ref value) => 0, + ThriftTestTestExceptionResultSend::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStructResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + } + + impl ::pilota::thrift::Message for ThriftTestTestStructResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultSend", + })?; + match self { + ThriftTestTestStructResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestStructResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestStructResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultSend", + }) + match self { + ThriftTestTestStructResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct CrazyNesting { + pub string_field: ::std::option::Option<::pilota::FastStr>, + + pub set_field: ::std::option::Option<::pilota::AHashSet>, + + pub list_field: ::std::vec::Vec< + ::pilota::AHashMap< + ::pilota::AHashSet, + ::pilota::AHashMap< + i32, + ::pilota::AHashSet< + ::std::vec::Vec<::pilota::AHashMap>, + >, + >, + >, + >, + + pub binary_field: ::std::option::Option<::pilota::Bytes>, + + pub uuid_field: ::std::option::Option<[u8; 16]>, + } + impl ::pilota::thrift::Message for CrazyNesting { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "CrazyNesting", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_field.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.set_field.as_ref() { + __protocol.write_set_field( + 2, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Map, + &&self.list_field, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::Set, + ::pilota::thrift::TType::Map, + &val, + |__protocol, key| { + __protocol.write_set( + ::pilota::thrift::TType::I32, + &key, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Map, + &val, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Binary, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol + .write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.binary_field.as_ref() { + __protocol.write_bytes_field(4, (value).clone())?; + } + if let Some(value) = self.uuid_field.as_ref() { + __protocol.write_uuid_field(5, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?); + } + __protocol.read_set_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec< + ::pilota::AHashMap< + ::pilota::AHashSet, + ::pilota::AHashMap< + i32, + ::pilota::AHashSet< + ::std::vec::Vec< + ::pilota::AHashMap< + Insanity, + ::pilota::FastStr, + >, + >, + >, + >, + >, + > = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert({let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + }; + __protocol.read_set_end()?; + val}, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, {let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::AHashMap> = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + }; + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + }; + __protocol.read_set_end()?; + val}); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_4 = Some(__protocol.read_bytes()?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_5 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `CrazyNesting` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field list_field is required".to_string(), + )); + }; + + let data = Self { + string_field: var_1, + set_field: var_2, + list_field: var_3, + binary_field: var_4, + uuid_field: var_5, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2 = Some({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::decode_async(__protocol).await?); + }; + __protocol.read_set_end().await?; + val}); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + }; + __protocol.read_set_end().await?; + val}, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, {let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::decode_async(__protocol).await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_set_end().await?; + val}); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_4 = Some(__protocol.read_bytes().await?); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_5 = Some(__protocol.read_uuid().await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `CrazyNesting` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field list_field is required".to_string(), + ), + ); + }; + + let data = Self { + string_field: var_1, + set_field: var_2, + list_field: var_3, + binary_field: var_4, + uuid_field: var_5, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "CrazyNesting", + }) + self + .string_field + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self.set_field.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Map, + &self.list_field, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::Set, + ::pilota::thrift::TType::Map, + el, + |__protocol, key| { + __protocol.set_len( + ::pilota::thrift::TType::I32, + key, + |__protocol, el| __protocol.i32_len(*el), + ) + }, + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len( + ::pilota::thrift::TType::List, + val, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::Map, + el, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Binary, + el, + |__protocol, key| { + __protocol.struct_len(key) + }, + |__protocol, val| { + __protocol.faststr_len(val) + }, + ) + }, + ) + }, + ) + }, + ) + }, + ) + }, + ) + + self + .binary_field + .as_ref() + .map_or(0, |value| __protocol.bytes_field_len(Some(4), value)) + + self + .uuid_field + .as_ref() + .map_or(0, |value| __protocol.uuid_field_len(Some(5), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestBinaryResultSend { + #[derivative(Default)] + Ok(::pilota::Bytes), + } + + impl ::pilota::thrift::Message for ThriftTestTestBinaryResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultSend", + })?; + match self { + ThriftTestTestBinaryResultSend::Ok(ref value) => { + __protocol.write_bytes_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(ThriftTestTestBinaryResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(ThriftTestTestBinaryResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultSend", + }) + match self { + ThriftTestTestBinaryResultSend::Ok(ref value) => { + __protocol.bytes_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ListBonks { + pub bonk: ::std::option::Option<::std::vec::Vec>, + } + impl ::pilota::thrift::Message for ListBonks { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "ListBonks" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bonk.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListBonks` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push( + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListBonks` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "ListBonks" }) + + self.bonk.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestI64ResultSend { + #[derivative(Default)] + Ok(i64), + } + + impl ::pilota::thrift::Message for ThriftTestTestI64ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultSend", + })?; + match self { + ThriftTestTestI64ResultSend::Ok(ref value) => { + __protocol.write_i64_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64()?; + __protocol.i64_len(*&field_ident); + ret = Some(ThriftTestTestI64ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64().await?; + + ret = Some(ThriftTestTestI64ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultSend", + }) + match self { + ThriftTestTestI64ResultSend::Ok(ref value) => { + __protocol.i64_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct SecondServiceSecondtestStringArgsSend { + pub thing: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for SecondServiceSecondtestStringArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestByteResultSend { + #[derivative(Default)] + Ok(i8), + } + + impl ::pilota::thrift::Message for ThriftTestTestByteResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultSend", + })?; + match self { + ThriftTestTestByteResultSend::Ok(ref value) => { + __protocol.write_i8_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8()?; + __protocol.i8_len(*&field_ident); + ret = Some(ThriftTestTestByteResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8().await?; + + ret = Some(ThriftTestTestByteResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultSend", + }) + match self { + ThriftTestTestByteResultSend::Ok(ref value) => { + __protocol.i8_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMultiExceptionArgsRecv { + pub arg0: ::pilota::FastStr, + + pub arg1: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg0).clone())?; + __protocol.write_faststr_field(2, (&self.arg1).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + ), + ); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.arg0) + + __protocol.faststr_field_len(Some(2), &self.arg1) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStringResultSend { + #[derivative(Default)] + Ok(::pilota::FastStr), + } + + impl ::pilota::thrift::Message for ThriftTestTestStringResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultSend", + })?; + match self { + ThriftTestTestStringResultSend::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(ThriftTestTestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(ThriftTestTestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultSend", + }) + match self { + ThriftTestTestStringResultSend::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMultiExceptionResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + + Err1(Xception), + + Err2(Xception2), + } + + impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultRecv", + })?; + match self { + ThriftTestTestMultiExceptionResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultRecv::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultRecv::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionResultRecv::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err1( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err2( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultRecv", + }) + match self { + ThriftTestTestMultiExceptionResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ThriftTestTestMultiExceptionResultRecv::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionResultRecv::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Xception { + pub error_code: ::std::option::Option, + + pub message: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for Xception { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xception" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.error_code.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + error_code: var_1, + message: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + error_code: var_1, + message: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xception" }) + + self + .error_code + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMultiArgsSend { + pub arg0: i8, + + pub arg1: i32, + + pub arg2: i64, + + pub arg3: ::pilota::AHashMap, + + pub arg4: ::common::apache::Numberz, + + pub arg5: ::common::apache::UserId, + } + impl ::pilota::thrift::Message for ThriftTestTestMultiArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.arg0)?; + __protocol.write_i32_field(2, *&self.arg1)?; + __protocol.write_i64_field(3, *&self.arg2)?; + __protocol.write_map_field( + 4, + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &&self.arg3, + |__protocol, key| { + __protocol.write_i16(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_i32_field(5, (&self.arg4).inner())?; + __protocol.write_struct_field(6, &self.arg5, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i16()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64().await?); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16().await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + ), + ); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + ), + ); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + ), + ); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + ), + ); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + ), + ); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsSend", + }) + __protocol.i8_field_len(Some(1), *&self.arg0) + + __protocol.i32_field_len(Some(2), *&self.arg1) + + __protocol.i64_field_len(Some(3), *&self.arg2) + + __protocol.map_field_len( + Some(4), + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &self.arg3, + |__protocol, key| __protocol.i16_len(*key), + |__protocol, val| __protocol.faststr_len(val), + ) + + __protocol.i32_field_len(Some(5), (&self.arg4).inner()) + + __protocol.struct_field_len(Some(6), &self.arg5) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Bools { + pub im_true: ::std::option::Option, + + pub im_false: ::std::option::Option, + } + impl ::pilota::thrift::Message for Bools { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Bools" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.im_true.as_ref() { + __protocol.write_bool_field(1, *value)?; + } + if let Some(value) = self.im_false.as_ref() { + __protocol.write_bool_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_2 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bools` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + im_true: var_1, + im_false: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_1 = Some(__protocol.read_bool().await?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_2 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bools` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + im_true: var_1, + im_false: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Bools" }) + + self + .im_true + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1), *value)) + + self + .im_false + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMapMapArgsSend { + pub hello: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestMapMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.hello)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + ), + ); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct GuessProtocolStruct { + pub map_field: + ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for GuessProtocolStruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "GuessProtocolStruct", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.map_field.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_7 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `GuessProtocolStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { map_field: var_7 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_7 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(7) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `GuessProtocolStruct` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { map_field: var_7 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "GuessProtocolStruct", + }) + self.map_field.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestEnumArgsSend { + pub thing: ::common::apache::Numberz, + } + impl ::pilota::thrift::Message for ThriftTestTestEnumArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.thing).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsSend", + }) + __protocol.i32_field_len(Some(1), (&self.thing).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait ThriftTest {} + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestSetArgsSend { + pub thing: ::pilota::AHashSet, + } + impl ::pilota::thrift::Message for ThriftTestTestSetArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestSetArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestSetArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsSend", + }) + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMapArgsSend { + pub thing: ::pilota::AHashMap, + } + impl ::pilota::thrift::Message for ThriftTestTestMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsSend", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStructArgsSend { + pub thing: ::common::apache::Xtruct, + } + impl ::pilota::thrift::Message for ThriftTestTestStructArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestInsanityArgsRecv { + pub argument: Insanity, + } + impl ::pilota::thrift::Message for ThriftTestTestInsanityArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field( + 1, + &self.argument, + ::pilota::thrift::TType::Struct, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + ), + ); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.argument) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestBinaryArgsSend { + pub thing: ::pilota::Bytes, + } + impl ::pilota::thrift::Message for ThriftTestTestBinaryArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsSend", + }) + __protocol.bytes_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + impl Default for BoolTest { + fn default() -> Self { + BoolTest { + b: Some(true), + s: Some(::pilota::FastStr::from_static_str("true")), + } + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] + pub struct BoolTest { + pub b: ::std::option::Option, + + pub s: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for BoolTest { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "BoolTest" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b.as_ref() { + __protocol.write_bool_field(1, *value)?; + } + if let Some(value) = self.s.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(true); + let mut var_2 = Some(::pilota::FastStr::from_static_str("true")); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `BoolTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b: var_1, s: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(true); + let mut var_2 = Some(::pilota::FastStr::from_static_str("true")); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_1 = Some(__protocol.read_bool().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `BoolTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b: var_1, s: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "BoolTest" }) + + self + .b + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1), *value)) + + self + .s + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestTypedefArgsRecv { + pub thing: ::common::apache::UserId, + } + impl ::pilota::thrift::Message for ThriftTestTestTypedefArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestI64ArgsSend { + pub thing: i64, + } + impl ::pilota::thrift::Message for ThriftTestTestI64ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i64_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI64ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I64 => + { + var_1 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI64ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsSend", + }) + __protocol.i64_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait SecondService {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestListArgsRecv { + pub thing: ::std::vec::Vec, + } + impl ::pilota::thrift::Message for ThriftTestTestListArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestListArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestListArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsRecv", + }) + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestByteArgsSend { + pub thing: i8, + } + impl ::pilota::thrift::Message for ThriftTestTestByteArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestByteArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_1 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestByteArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsSend", + }) + __protocol.i8_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStringMapArgsRecv { + pub thing: ::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>, + } + impl ::pilota::thrift::Message for ThriftTestTestStringMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &&self.thing, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsRecv", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &self.thing, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStringArgsSend { + pub thing: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestStringArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestNestArgsRecv { + pub thing: Xtruct2, + } + impl ::pilota::thrift::Message for ThriftTestTestNestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestNestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestNestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct EmptyStruct {} + impl ::pilota::thrift::Message for EmptyStruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "EmptyStruct", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `EmptyStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `EmptyStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "EmptyStruct", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestExceptionResultRecv { + #[derivative(Default)] + Ok(()), + + Err1(Xception), + } + + impl ::pilota::thrift::Message for ThriftTestTestExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultRecv", + })?; + match self { + ThriftTestTestExceptionResultRecv::Ok(ref value) => {} + ThriftTestTestExceptionResultRecv::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = + Some(ThriftTestTestExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultRecv", + }) + match self { + ThriftTestTestExceptionResultRecv::Ok(ref value) => 0, + ThriftTestTestExceptionResultRecv::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestUuidArgsRecv { + pub thing: [u8; 16], + } + impl ::pilota::thrift::Message for ThriftTestTestUuidArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_uuid_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestUuidArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Uuid => + { + var_1 = Some(__protocol.read_uuid().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestUuidArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsRecv", + }) + __protocol.uuid_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Xtruct2 { + pub byte_thing: ::std::option::Option, + + pub struct_thing: ::std::option::Option<::common::apache::Xtruct>, + + pub i32_thing: ::std::option::Option, + } + impl ::pilota::thrift::Message for Xtruct2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct2" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.byte_thing.as_ref() { + __protocol.write_i8_field(1, *value)?; + } + if let Some(value) = self.struct_thing.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(3, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_3 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + byte_thing: var_1, + struct_thing: var_2, + i32_thing: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_3 = Some(__protocol.read_i32().await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Xtruct2` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + byte_thing: var_1, + struct_thing: var_2, + i32_thing: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct2" }) + + self + .byte_thing + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(1), *value)) + + self + .struct_thing + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(3), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestInsanityResultRecv { + #[derivative(Default)] + Ok( + ::pilota::AHashMap< + ::common::apache::UserId, + ::pilota::AHashMap<::common::apache::Numberz, Insanity>, + >, + ), + } + + impl ::pilota::thrift::Message for ThriftTestTestInsanityResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultRecv", + })?; + match self { + ThriftTestTestInsanityResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity( + map_ident.size, + ); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode( + __protocol, + )?, + ::pilota::thrift::Message::decode( + __protocol, + )?, + ); + } + __protocol.read_map_end()?; + val + }, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ); + ret = Some(ThriftTestTestInsanityResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, ::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestInsanityResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultRecv", + }) + match self { + ThriftTestTestInsanityResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestDoubleArgsRecv { + pub thing: f64, + } + impl ::pilota::thrift::Message for ThriftTestTestDoubleArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_double_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_1 = Some(__protocol.read_double()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_1 = Some(__protocol.read_double().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsRecv", + }) + __protocol.double_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct NestedListsI32x2 { + pub integerlist: ::std::option::Option<::std::vec::Vec<::std::vec::Vec>>, + } + impl ::pilota::thrift::Message for NestedListsI32x2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.integerlist.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = + __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x2", + }) + self.integerlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::I32, + el, + |__protocol, el| __protocol.i32_len(*el), + ) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestTypedefResultRecv { + #[derivative(Default)] + Ok(::common::apache::UserId), + } + + impl ::pilota::thrift::Message for ThriftTestTestTypedefResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultRecv", + })?; + match self { + ThriftTestTestTypedefResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::I64)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestTypedefResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestTypedefResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultRecv", + }) + match self { + ThriftTestTestTypedefResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestI32ArgsRecv { + pub thing: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestI32ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI32ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestI32ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestListResultRecv { + #[derivative(Default)] + Ok(::std::vec::Vec), + } + + impl ::pilota::thrift::Message for ThriftTestTestListResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultRecv", + })?; + match self { + ThriftTestTestListResultRecv::Ok(ref value) => { + __protocol.write_list_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }; + __protocol.list_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestListResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }; + + ret = Some(ThriftTestTestListResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultRecv", + }) + match self { + ThriftTestTestListResultRecv::Ok(ref value) => __protocol.list_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestBoolArgsRecv { + pub thing: bool, + } + impl ::pilota::thrift::Message for ThriftTestTestBoolArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bool_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBoolArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_1 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBoolArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsRecv", + }) + __protocol.bool_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStringMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), + } + + impl ::pilota::thrift::Message for ThriftTestTestStringMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultRecv", + })?; + match self { + ThriftTestTestStringMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &field_ident, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ); + ret = Some(ThriftTestTestStringMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestStringMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultRecv", + }) + match self { + ThriftTestTestStringMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestVoidArgsRecv {} + impl ::pilota::thrift::Message for ThriftTestTestVoidArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestVoidArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestVoidArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestNestResultRecv { + #[derivative(Default)] + Ok(Xtruct2), + } + + impl ::pilota::thrift::Message for ThriftTestTestNestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultRecv", + })?; + match self { + ThriftTestTestNestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestNestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestNestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultRecv", + }) + match self { + ThriftTestTestNestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestUuidResultRecv { + #[derivative(Default)] + Ok([u8; 16]), + } + + impl ::pilota::thrift::Message for ThriftTestTestUuidResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultRecv", + })?; + match self { + ThriftTestTestUuidResultRecv::Ok(ref value) => { + __protocol.write_uuid_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid()?; + __protocol.uuid_len(*&field_ident); + ret = Some(ThriftTestTestUuidResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid().await?; + + ret = Some(ThriftTestTestUuidResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultRecv", + }) + match self { + ThriftTestTestUuidResultRecv::Ok(ref value) => { + __protocol.uuid_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct StructB { + pub aa: ::std::option::Option, + + pub ab: StructA, + } + impl ::pilota::thrift::Message for StructB { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "StructB" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.aa.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_struct_field(2, &self.ab, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructB` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ab is required".to_string(), + )); + }; + + let data = Self { + aa: var_1, + ab: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructB` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ab is required".to_string(), + ), + ); + }; + + let data = Self { + aa: var_1, + ab: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "StructB" }) + + self + .aa + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.struct_field_len(Some(2), &self.ab) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestDoubleResultRecv { + #[derivative(Default)] + Ok(f64), + } + + impl ::pilota::thrift::Message for ThriftTestTestDoubleResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultRecv", + })?; + match self { + ThriftTestTestDoubleResultRecv::Ok(ref value) => { + __protocol.write_double_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double()?; + __protocol.double_len(*&field_ident); + ret = Some(ThriftTestTestDoubleResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double().await?; + + ret = Some(ThriftTestTestDoubleResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultRecv", + }) + match self { + ThriftTestTestDoubleResultRecv::Ok(ref value) => { + __protocol.double_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct VersioningTestV2 { + pub begin_in_both: ::std::option::Option, + + pub newint: ::std::option::Option, + + pub newbyte: ::std::option::Option, + + pub newshort: ::std::option::Option, + + pub newlong: ::std::option::Option, + + pub newdouble: ::std::option::Option, + + pub newstruct: ::std::option::Option, + + pub newlist: ::std::option::Option<::std::vec::Vec>, + + pub newset: ::std::option::Option<::pilota::AHashSet>, + + pub newmap: ::std::option::Option<::pilota::AHashMap>, + + pub newstring: ::std::option::Option<::pilota::FastStr>, + + pub end_in_both: ::std::option::Option, + } + impl ::pilota::thrift::Message for VersioningTestV2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "VersioningTestV2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.begin_in_both.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.newint.as_ref() { + __protocol.write_i32_field(2, *value)?; + } + if let Some(value) = self.newbyte.as_ref() { + __protocol.write_i8_field(3, *value)?; + } + if let Some(value) = self.newshort.as_ref() { + __protocol.write_i16_field(4, *value)?; + } + if let Some(value) = self.newlong.as_ref() { + __protocol.write_i64_field(5, *value)?; + } + if let Some(value) = self.newdouble.as_ref() { + __protocol.write_double_field(6, *value)?; + } + if let Some(value) = self.newstruct.as_ref() { + __protocol.write_struct_field(7, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.newlist.as_ref() { + __protocol.write_list_field( + 8, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newset.as_ref() { + __protocol.write_set_field( + 9, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newmap.as_ref() { + __protocol.write_map_field( + 10, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newstring.as_ref() { + __protocol.write_faststr_field(11, (value).clone())?; + } + if let Some(value) = self.end_in_both.as_ref() { + __protocol.write_i32_field(12, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + let mut var_7 = None; + let mut var_8 = None; + let mut var_9 = None; + let mut var_10 = None; + let mut var_11 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_3 = Some(__protocol.read_i8()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I16 => { + var_4 = Some(__protocol.read_i16()?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_5 = Some(__protocol.read_i64()?); + } + Some(6) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_6 = Some(__protocol.read_double()?); + } + Some(7) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_7 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_8 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_9 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_10 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(11) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_11 = Some(__protocol.read_faststr()?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + begin_in_both: var_1, + newint: var_2, + newbyte: var_3, + newshort: var_4, + newlong: var_5, + newdouble: var_6, + newstruct: var_7, + newlist: var_8, + newset: var_9, + newmap: var_10, + newstring: var_11, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + let mut var_7 = None; + let mut var_8 = None; + let mut var_9 = None; + let mut var_10 = None; + let mut var_11 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_2 = Some(__protocol.read_i32().await?); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_3 = Some(__protocol.read_i8().await?); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::I16 => + { + var_4 = Some(__protocol.read_i16().await?); + } + Some(5) + if field_ident.field_type == ::pilota::thrift::TType::I64 => + { + var_5 = Some(__protocol.read_i64().await?); + } + Some(6) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_6 = Some(__protocol.read_double().await?); + } + Some(7) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_7 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(8) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_8 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(9) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_9 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + Some(10) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_10 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(11) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_11 = Some(__protocol.read_faststr().await?); + } + Some(12) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_12 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + begin_in_both: var_1, + newint: var_2, + newbyte: var_3, + newshort: var_4, + newlong: var_5, + newdouble: var_6, + newstruct: var_7, + newlist: var_8, + newset: var_9, + newmap: var_10, + newstring: var_11, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "VersioningTestV2", + }) + self + .begin_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .newint + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(2), *value)) + + self + .newbyte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(3), *value)) + + self + .newshort + .as_ref() + .map_or(0, |value| __protocol.i16_field_len(Some(4), *value)) + + self + .newlong + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(5), *value)) + + self + .newdouble + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(6), *value)) + + self + .newstruct + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(7), value)) + + self.newlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(8), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + self.newset.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(9), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + self.newmap.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(10), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }) + + self + .newstring + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(11), value)) + + self + .end_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(12), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestI32ResultRecv { + #[derivative(Default)] + Ok(i32), + } + + impl ::pilota::thrift::Message for ThriftTestTestI32ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultRecv", + })?; + match self { + ThriftTestTestI32ResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(ThriftTestTestI32ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(ThriftTestTestI32ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultRecv", + }) + match self { + ThriftTestTestI32ResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestBoolResultRecv { + #[derivative(Default)] + Ok(bool), + } + + impl ::pilota::thrift::Message for ThriftTestTestBoolResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultRecv", + })?; + match self { + ThriftTestTestBoolResultRecv::Ok(ref value) => { + __protocol.write_bool_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool()?; + __protocol.bool_len(*&field_ident); + ret = Some(ThriftTestTestBoolResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool().await?; + + ret = Some(ThriftTestTestBoolResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultRecv", + }) + match self { + ThriftTestTestBoolResultRecv::Ok(ref value) => { + __protocol.bool_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestMultiExceptionResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + + Err1(Xception), + + Err2(Xception2), + } + + impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultSend", + })?; + match self { + ThriftTestTestMultiExceptionResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultSend::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultSend::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = + Some(ThriftTestTestMultiExceptionResultSend::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Err1( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Err2( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultSend", + }) + match self { + ThriftTestTestMultiExceptionResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ThriftTestTestMultiExceptionResultSend::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionResultSend::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestVoidResultRecv { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for ThriftTestTestVoidResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultRecv", + })?; + match self { + ThriftTestTestVoidResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultRecv", + }) + match self { + ThriftTestTestVoidResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct Insanity { + pub user_map: ::std::option::Option< + ::pilota::AHashMap<::common::apache::Numberz, ::common::apache::UserId>, + >, + + pub xtructs: ::std::option::Option<::std::vec::Vec<::common::apache::Xtruct>>, + } + impl ::pilota::thrift::Message for Insanity { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Insanity" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.user_map.as_ref() { + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.xtructs.as_ref() { + __protocol.write_list_field( + 2, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::common::apache::Xtruct> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Insanity` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + user_map: var_1, + xtructs: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Insanity` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + user_map: var_1, + xtructs: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Insanity" }) + + self.user_map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }) + + self.xtructs.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestInsanityResultSend { + #[derivative(Default)] + Ok( + ::pilota::AHashMap< + ::common::apache::UserId, + ::pilota::AHashMap<::common::apache::Numberz, Insanity>, + >, + ), + } + + impl ::pilota::thrift::Message for ThriftTestTestInsanityResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultSend", + })?; + match self { + ThriftTestTestInsanityResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity( + map_ident.size, + ); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode( + __protocol, + )?, + ::pilota::thrift::Message::decode( + __protocol, + )?, + ); + } + __protocol.read_map_end()?; + val + }, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ); + ret = Some(ThriftTestTestInsanityResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, ::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestInsanityResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultSend", + }) + match self { + ThriftTestTestInsanityResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct NestedMixedx2 { + pub int_set_list: ::std::option::Option<::std::vec::Vec<::pilota::AHashSet>>, + + pub map_int_strset: ::std::option::Option< + ::pilota::AHashMap>, + >, + + pub map_int_strset_list: ::std::option::Option< + ::std::vec::Vec<::pilota::AHashMap>>, + >, + } + impl ::pilota::thrift::Message for NestedMixedx2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedMixedx2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.int_set_list.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Set, + &value, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.map_int_strset.as_ref() { + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::Binary, + &val, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.map_int_strset_list.as_ref() { + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Map, + &value, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::Binary, + &val, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::AHashSet> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec< + ::pilota::AHashMap< + i32, + ::pilota::AHashSet<::pilota::FastStr>, + >, + > = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity( + list_ident.size, + ); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedMixedx2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + int_set_list: var_1, + map_int_strset: var_2, + map_int_strset_list: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = + __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity( + list_ident.size, + ); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = + __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity( + list_ident.size, + ); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity( + map_ident.size, + ); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = + __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity( + list_ident.size, + ); + for _ in 0..list_ident.size { + val.insert( + __protocol.read_faststr().await?, + ); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedMixedx2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + int_set_list: var_1, + map_int_strset: var_2, + map_int_strset_list: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedMixedx2", + }) + self.int_set_list.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Set, + value, + |__protocol, el| { + __protocol.set_len( + ::pilota::thrift::TType::I32, + el, + |__protocol, el| __protocol.i32_len(*el), + ) + }, + ) + }) + self.map_int_strset.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len( + ::pilota::thrift::TType::Binary, + val, + |__protocol, el| __protocol.faststr_len(el), + ) + }, + ) + }) + self.map_int_strset_list.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Map, + value, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + el, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len( + ::pilota::thrift::TType::Binary, + val, + |__protocol, el| __protocol.faststr_len(el), + ) + }, + ) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestTypedefResultSend { + #[derivative(Default)] + Ok(::common::apache::UserId), + } + + impl ::pilota::thrift::Message for ThriftTestTestTypedefResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultSend", + })?; + match self { + ThriftTestTestTypedefResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::I64)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestTypedefResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestTypedefResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultSend", + }) + match self { + ThriftTestTestTypedefResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestListResultSend { + #[derivative(Default)] + Ok(::std::vec::Vec), + } + + impl ::pilota::thrift::Message for ThriftTestTestListResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultSend", + })?; + match self { + ThriftTestTestListResultSend::Ok(ref value) => { + __protocol.write_list_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }; + __protocol.list_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestListResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }; + + ret = Some(ThriftTestTestListResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultSend", + }) + match self { + ThriftTestTestListResultSend::Ok(ref value) => __protocol.list_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMultiExceptionArgsSend { + pub arg0: ::pilota::FastStr, + + pub arg1: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg0).clone())?; + __protocol.write_faststr_field(2, (&self.arg1).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + ), + ); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.arg0) + + __protocol.faststr_field_len(Some(2), &self.arg1) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestStringMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), + } + + impl ::pilota::thrift::Message for ThriftTestTestStringMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultSend", + })?; + match self { + ThriftTestTestStringMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &field_ident, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ); + ret = Some(ThriftTestTestStringMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestStringMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultSend", + }) + match self { + ThriftTestTestStringMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestExceptionArgsRecv { + pub arg: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for ThriftTestTestExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + ), + ); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.arg) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestNestResultSend { + #[derivative(Default)] + Ok(Xtruct2), + } + + impl ::pilota::thrift::Message for ThriftTestTestNestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultSend", + })?; + match self { + ThriftTestTestNestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestNestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ThriftTestTestNestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultSend", + }) + match self { + ThriftTestTestNestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestUuidResultSend { + #[derivative(Default)] + Ok([u8; 16]), + } + + impl ::pilota::thrift::Message for ThriftTestTestUuidResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultSend", + })?; + match self { + ThriftTestTestUuidResultSend::Ok(ref value) => { + __protocol.write_uuid_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid()?; + __protocol.uuid_len(*&field_ident); + ret = Some(ThriftTestTestUuidResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid().await?; + + ret = Some(ThriftTestTestUuidResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultSend", + }) + match self { + ThriftTestTestUuidResultSend::Ok(ref value) => { + __protocol.uuid_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct MapType(pub ::pilota::AHashMap<::pilota::FastStr, Bonk>); + + impl ::std::ops::Deref for MapType { + type Target = ::pilota::AHashMap<::pilota::FastStr, Bonk>; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl From<::pilota::AHashMap<::pilota::FastStr, Bonk>> for MapType { + fn from(v: ::pilota::AHashMap<::pilota::FastStr, Bonk>) -> Self { + Self(v) + } + } + + impl ::pilota::thrift::Message for MapType { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_map( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Struct, + &(&**self), + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(MapType({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + })) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(MapType({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + ::decode_async(__protocol) + .await?, + ); + } + __protocol.read_map_end().await?; + val + })) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Struct, + &**self, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + } + } + impl Default for OptionalBinary { + fn default() -> Self { + OptionalBinary { + bin_map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }), + } + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OptionalBinary { + pub bin_map: ::std::option::Option<::pilota::AHashMap<::pilota::Bytes, i32>>, + } + impl ::pilota::thrift::Message for OptionalBinary { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "OptionalBinary", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bin_map.as_ref() { + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_bytes(key.clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_bytes()?, + __protocol.read_i32()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalBinary` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_2.is_none() { + var_2 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }); + } + + let data = Self { bin_map: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_bytes().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalBinary` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_2.is_none() { + var_2 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }); + } + + let data = Self { bin_map: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "OptionalBinary", + }) + self.bin_map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.bytes_len(key), + |__protocol, val| __protocol.i32_len(*val), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestDoubleResultSend { + #[derivative(Default)] + Ok(f64), + } + + impl ::pilota::thrift::Message for ThriftTestTestDoubleResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultSend", + })?; + match self { + ThriftTestTestDoubleResultSend::Ok(ref value) => { + __protocol.write_double_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double()?; + __protocol.double_len(*&field_ident); + ret = Some(ThriftTestTestDoubleResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double().await?; + + ret = Some(ThriftTestTestDoubleResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultSend", + }) + match self { + ThriftTestTestDoubleResultSend::Ok(ref value) => { + __protocol.double_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ListTypeVersioningV2 { + pub strings: ::std::option::Option<::std::vec::Vec<::pilota::FastStr>>, + + pub hello: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for ListTypeVersioningV2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.strings.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.hello.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::FastStr> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_faststr()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + strings: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_faststr().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ListTypeVersioningV2` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + strings: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV2", + }) + self.strings.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + self + .hello + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestI32ResultSend { + #[derivative(Default)] + Ok(i32), + } + + impl ::pilota::thrift::Message for ThriftTestTestI32ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultSend", + })?; + match self { + ThriftTestTestI32ResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(ThriftTestTestI32ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(ThriftTestTestI32ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultSend", + }) + match self { + ThriftTestTestI32ResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestOnewayArgsRecv { + pub seconds_to_sleep: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestOnewayArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.seconds_to_sleep)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + ), + ); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.seconds_to_sleep) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestBoolResultSend { + #[derivative(Default)] + Ok(bool), + } + + impl ::pilota::thrift::Message for ThriftTestTestBoolResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultSend", + })?; + match self { + ThriftTestTestBoolResultSend::Ok(ref value) => { + __protocol.write_bool_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool()?; + __protocol.bool_len(*&field_ident); + ret = Some(ThriftTestTestBoolResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool().await?; + + ret = Some(ThriftTestTestBoolResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultSend", + }) + match self { + ThriftTestTestBoolResultSend::Ok(ref value) => { + __protocol.bool_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestVoidResultSend { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for ThriftTestTestVoidResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultSend", + })?; + match self { + ThriftTestTestVoidResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultSend", + }) + match self { + ThriftTestTestVoidResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum SomeUnion { + #[derivative(Default)] + MapThing(::pilota::AHashMap<::common::apache::Numberz, ::common::apache::UserId>), + + StringThing(::pilota::FastStr), + + I32Thing(i32), + + XtructThing(Xtruct3), + + InsanityThing(Insanity), + } + + impl ::pilota::thrift::Message for SomeUnion { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "SomeUnion", + })?; + match self { + SomeUnion::MapThing(ref value) => { + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + SomeUnion::StringThing(ref value) => { + __protocol.write_faststr_field(2, (value).clone())?; + } + SomeUnion::I32Thing(ref value) => { + __protocol.write_i32_field(3, *value)?; + } + SomeUnion::XtructThing(ref value) => { + __protocol.write_struct_field(4, value, ::pilota::thrift::TType::Struct)?; + } + SomeUnion::InsanityThing(ref value) => { + __protocol.write_struct_field(5, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ); + ret = Some(SomeUnion::MapThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(SomeUnion::StringThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(3) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(SomeUnion::I32Thing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(4) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(SomeUnion::XtructThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(5) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(SomeUnion::InsanityThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(SomeUnion::MapThing(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SomeUnion::StringThing(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(3) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(SomeUnion::I32Thing(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(4) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(SomeUnion::XtructThing(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(5) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(SomeUnion::InsanityThing(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "SomeUnion" }) + + match self { + SomeUnion::MapThing(ref value) => __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ), + SomeUnion::StringThing(ref value) => { + __protocol.faststr_field_len(Some(2), value) + } + SomeUnion::I32Thing(ref value) => __protocol.i32_field_len(Some(3), *value), + SomeUnion::XtructThing(ref value) => { + __protocol.struct_field_len(Some(4), value) + } + SomeUnion::InsanityThing(ref value) => { + __protocol.struct_field_len(Some(5), value) + } + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestInsanityArgsSend { + pub argument: Insanity, + } + impl ::pilota::thrift::Message for ThriftTestTestInsanityArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field( + 1, + &self.argument, + ::pilota::thrift::TType::Struct, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + ), + ); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.argument) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct NestedListsBonk { + pub bonk: + ::std::option::Option<::std::vec::Vec<::std::vec::Vec<::std::vec::Vec>>>, + } + impl ::pilota::thrift::Message for NestedListsBonk { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsBonk", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bonk.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::vec::Vec>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = + __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::pilota::thrift::Message::decode( + __protocol, + )?, + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsBonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `NestedListsBonk` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsBonk", + }) + self.bonk.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::List, + el, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::Struct, + el, + |__protocol, el| __protocol.struct_len(el), + ) + }, + ) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestTypedefArgsSend { + pub thing: ::common::apache::UserId, + } + impl ::pilota::thrift::Message for ThriftTestTestTypedefArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct SecondServiceSecondtestStringArgsRecv { + pub thing: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for SecondServiceSecondtestStringArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestListArgsSend { + pub thing: ::std::vec::Vec, + } + impl ::pilota::thrift::Message for ThriftTestTestListArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestListArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::List => + { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestListArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsSend", + }) + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ThriftTestTestOnewayResultRecv { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for ThriftTestTestOnewayResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultRecv", + })?; + match self { + ThriftTestTestOnewayResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultRecv", + }) + match self { + ThriftTestTestOnewayResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestStringMapArgsSend { + pub thing: ::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>, + } + impl ::pilota::thrift::Message for ThriftTestTestStringMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &&self.thing, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsSend", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &self.thing, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestNestArgsSend { + pub thing: Xtruct2, + } + impl ::pilota::thrift::Message for ThriftTestTestNestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestNestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestNestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Xception2 { + pub error_code: ::std::option::Option, + + pub struct_thing: ::std::option::Option<::common::apache::Xtruct>, + } + impl ::pilota::thrift::Message for Xception2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xception2" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.error_code.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.struct_thing.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + error_code: var_1, + struct_thing: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Xception2` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + error_code: var_1, + struct_thing: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xception2" }) + + self + .error_code + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .struct_thing + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMultiArgsRecv { + pub arg0: i8, + + pub arg1: i32, + + pub arg2: i64, + + pub arg3: ::pilota::AHashMap, + + pub arg4: ::common::apache::Numberz, + + pub arg5: ::common::apache::UserId, + } + impl ::pilota::thrift::Message for ThriftTestTestMultiArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.arg0)?; + __protocol.write_i32_field(2, *&self.arg1)?; + __protocol.write_i64_field(3, *&self.arg2)?; + __protocol.write_map_field( + 4, + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &&self.arg3, + |__protocol, key| { + __protocol.write_i16(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_i32_field(5, (&self.arg4).inner())?; + __protocol.write_struct_field(6, &self.arg5, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i16()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64().await?); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16().await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + ), + ); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + ), + ); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + ), + ); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + ), + ); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + ), + ); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsRecv", + }) + __protocol.i8_field_len(Some(1), *&self.arg0) + + __protocol.i32_field_len(Some(2), *&self.arg1) + + __protocol.i64_field_len(Some(3), *&self.arg2) + + __protocol.map_field_len( + Some(4), + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &self.arg3, + |__protocol, key| __protocol.i16_len(*key), + |__protocol, val| __protocol.faststr_len(val), + ) + + __protocol.i32_field_len(Some(5), (&self.arg4).inner()) + + __protocol.struct_field_len(Some(6), &self.arg5) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestUuidArgsSend { + pub thing: [u8; 16], + } + impl ::pilota::thrift::Message for ThriftTestTestUuidArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_uuid_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestUuidArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Uuid => + { + var_1 = Some(__protocol.read_uuid().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestUuidArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsSend", + }) + __protocol.uuid_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestMapMapArgsRecv { + pub hello: i32, + } + impl ::pilota::thrift::Message for ThriftTestTestMapMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.hello)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + ), + ); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Debug, Default, Clone, PartialEq)] + pub struct ThriftTestTestDoubleArgsSend { + pub thing: f64, + } + impl ::pilota::thrift::Message for ThriftTestTestDoubleArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_double_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_1 = Some(__protocol.read_double()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_1 = Some(__protocol.read_double().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + ), + ); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsSend", + }) + __protocol.double_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub use ::common::apache::Numberz; + pub use ::common::apache::UserId; + pub use ::common::apache::Xtruct; + } + pub use apache::*; +} diff --git a/pilota-build/test_data/thrift_workspace/apache/apache/src/lib.rs b/pilota-build/test_data/thrift_workspace/apache/apache/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/apache/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/apache/common/Cargo.toml b/pilota-build/test_data/thrift_workspace/apache/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/apache/common/src/gen.rs b/pilota-build/test_data/thrift_workspace/apache/common/src/gen.rs new file mode 100644 index 00000000..ef42bb7a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/common/src/gen.rs @@ -0,0 +1,371 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod apache { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Numberz(i32); + + impl Numberz { + pub const ONE: Self = Self(1); + pub const TWO: Self = Self(2); + pub const THREE: Self = Self(3); + pub const FIVE: Self = Self(5); + pub const SIX: Self = Self(6); + pub const EIGHT: Self = Self(8); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("ONE"), + Self(2) => ::std::string::String::from("TWO"), + Self(3) => ::std::string::String::from("THREE"), + Self(5) => ::std::string::String::from("FIVE"), + Self(6) => ::std::string::String::from("SIX"), + Self(8) => ::std::string::String::from("EIGHT"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Numberz { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Numberz) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Numberz { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Numberz, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Numberz, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct UserId(pub i64); + + impl ::std::ops::Deref for UserId { + type Target = i64; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl From for UserId { + fn from(v: i64) -> Self { + Self(v) + } + } + + impl ::pilota::thrift::Message for UserId { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i64(*(&**self))?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(UserId(__protocol.read_i64()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(UserId(__protocol.read_i64().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i64_len(*&**self) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Xtruct { + pub string_thing: ::std::option::Option<::pilota::FastStr>, + + pub byte_thing: ::std::option::Option, + + pub i32_thing: ::std::option::Option, + + pub i64_thing: ::std::option::Option, + } + impl ::pilota::thrift::Message for Xtruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_thing.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.byte_thing.as_ref() { + __protocol.write_i8_field(4, *value)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(9, *value)?; + } + if let Some(value) = self.i64_thing.as_ref() { + __protocol.write_i64_field(11, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_4 = Some(__protocol.read_i8()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + string_thing: var_1, + byte_thing: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_4 = Some(__protocol.read_i8().await?); + } + Some(9) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_9 = Some(__protocol.read_i32().await?); + } + Some(11) + if field_ident.field_type == ::pilota::thrift::TType::I64 => + { + var_11 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + string_thing: var_1, + byte_thing: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct" }) + + self + .string_thing + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .byte_thing + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(4), *value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(9), *value)) + + self + .i64_thing + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(11), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } +} diff --git a/pilota-build/test_data/thrift_workspace/apache/common/src/lib.rs b/pilota-build/test_data/thrift_workspace/apache/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/apache/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/auto_name.thrift b/pilota-build/test_data/thrift_workspace/auto_name.thrift new file mode 100644 index 00000000..badc2e0c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name.thrift @@ -0,0 +1,33 @@ + +struct TEST { + 1: required string Id, +} + +const string ip = "ip"; +const string IP = "IP"; + +struct Test { + 1: required string ID, + 2: required string Id, +} + +enum Index { + A, + a, +} + +struct TestException { + +} + +service Service { + Test test(1: TEST req, 2: TEST Req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST type); +} + +service service { + Test test(1: TEST req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST self); +} diff --git a/pilota-build/test_data/thrift_workspace/auto_name/Cargo.toml b/pilota-build/test_data/thrift_workspace/auto_name/Cargo.toml new file mode 100644 index 00000000..1b42860e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["auto_name"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/auto_name/auto_name/Cargo.toml b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/Cargo.toml new file mode 100644 index 00000000..b005b796 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "auto_name" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/gen.rs b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/gen.rs new file mode 100644 index 00000000..bb2e599b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/gen.rs @@ -0,0 +1,5123 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod auto_name { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TEST { + pub id: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for TEST { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "TEST" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TEST` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + + let data = Self { id: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TEST` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + ), + ); + }; + + let data = Self { id: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "TEST" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait service {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum serviceTest2ResultRecv { + #[derivative(Default)] + Ok(Test), + } + + impl ::pilota::thrift::Message for serviceTest2ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ResultRecv", + })?; + match self { + serviceTest2ResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ResultRecv", + }) + match self { + serviceTest2ResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct servicetestArgsSend { + pub req: TEST, + } + impl ::pilota::thrift::Message for servicetestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "servicetestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `servicetestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `servicetestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "servicetestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait Service {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServiceTest2ResultRecv { + #[derivative(Default)] + Ok(Test), + } + + impl ::pilota::thrift::Message for ServiceTest2ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultRecv", + })?; + match self { + ServiceTest2ResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultRecv", + }) + match self { + ServiceTest2ResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServicetestArgsSend { + pub req: TEST, + + pub Req: TEST, + } + impl ::pilota::thrift::Message for ServicetestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServicetestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_struct_field(2, &self.Req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServicetestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Req is required".to_string(), + )); + }; + + let data = Self { + req: var_1, + Req: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServicetestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Req is required".to_string(), + ), + ); + }; + + let data = Self { + req: var_1, + Req: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServicetestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.struct_field_len(Some(2), &self.Req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestException {} + impl ::pilota::thrift::Message for TestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestException", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestException", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Index(i32); + + impl Index { + pub const A: Self = Self(0); + pub const a: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("a"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + pub const ip: &'static str = "ip"; + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct serviceTest2ArgsSend { + pub self_: TEST, + } + impl ::pilota::thrift::Message for serviceTest2ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "serviceTest2ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.self_, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `serviceTest2ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + )); + }; + + let data = Self { self_: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `serviceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + ), + ); + }; + + let data = Self { self_: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.self_) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct serviceTestArgsSend { + pub req: TEST, + } + impl ::pilota::thrift::Message for serviceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "serviceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `serviceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `serviceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct servicetestArgsRecv { + pub req: TEST, + } + impl ::pilota::thrift::Message for servicetestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "servicetestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `servicetestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `servicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "servicetestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum servicetestException { + #[derivative(Default)] + E(TestException), + } + + impl ::pilota::thrift::Message for servicetestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "servicetestException", + })?; + match self { + servicetestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(servicetestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(servicetestException::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "servicetestException", + }) + match self { + servicetestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum servicetestResultSend { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for servicetestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "servicetestResultSend", + })?; + match self { + servicetestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + servicetestResultSend::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(servicetestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(servicetestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(servicetestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(servicetestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "servicetestResultSend", + }) + match self { + servicetestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + servicetestResultSend::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum servicetestResultRecv { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for servicetestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "servicetestResultRecv", + })?; + match self { + servicetestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + servicetestResultRecv::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(servicetestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(servicetestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(servicetestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(servicetestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "servicetestResultRecv", + }) + match self { + servicetestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + servicetestResultRecv::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTest2ArgsSend { + pub r#type: TEST, + } + impl ::pilota::thrift::Message for ServiceTest2ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServiceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + ), + ); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.r#type) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTestArgsSend { + pub req: TEST, + } + impl ::pilota::thrift::Message for ServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServiceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServicetestArgsRecv { + pub req: TEST, + + pub Req: TEST, + } + impl ::pilota::thrift::Message for ServicetestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServicetestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_struct_field(2, &self.Req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServicetestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Req is required".to_string(), + )); + }; + + let data = Self { + req: var_1, + Req: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Req is required".to_string(), + ), + ); + }; + + let data = Self { + req: var_1, + Req: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServicetestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.struct_field_len(Some(2), &self.Req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServicetestException { + #[derivative(Default)] + E(TestException), + } + + impl ::pilota::thrift::Message for ServicetestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServicetestException", + })?; + match self { + ServicetestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServicetestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServicetestException::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServicetestException", + }) + match self { + ServicetestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServicetestResultSend { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for ServicetestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServicetestResultSend", + })?; + match self { + ServicetestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServicetestResultSend::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServicetestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServicetestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServicetestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServicetestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServicetestResultSend", + }) + match self { + ServicetestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ServicetestResultSend::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServicetestResultRecv { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for ServicetestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServicetestResultRecv", + })?; + match self { + ServicetestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServicetestResultRecv::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServicetestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServicetestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServicetestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServicetestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServicetestResultRecv", + }) + match self { + ServicetestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ServicetestResultRecv::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub const IP: &'static str = "IP"; + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct serviceTest2ArgsRecv { + pub self_: TEST, + } + impl ::pilota::thrift::Message for serviceTest2ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "serviceTest2ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.self_, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `serviceTest2ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + )); + }; + + let data = Self { self_: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `serviceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + ), + ); + }; + + let data = Self { self_: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.self_) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum serviceTest2ResultSend { + #[derivative(Default)] + Ok(Test), + } + + impl ::pilota::thrift::Message for serviceTest2ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ResultSend", + })?; + match self { + serviceTest2ResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTest2ResultSend", + }) + match self { + serviceTest2ResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct serviceTestArgsRecv { + pub req: TEST, + } + impl ::pilota::thrift::Message for serviceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "serviceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `serviceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `serviceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum serviceTestException { + #[derivative(Default)] + E(TestException), + } + + impl ::pilota::thrift::Message for serviceTestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "serviceTestException", + })?; + match self { + serviceTestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTestException", + }) + match self { + serviceTestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum serviceTestResultSend { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for serviceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "serviceTestResultSend", + })?; + match self { + serviceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + serviceTestResultSend::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTestResultSend", + }) + match self { + serviceTestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + serviceTestResultSend::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum serviceTestResultRecv { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for serviceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "serviceTestResultRecv", + })?; + match self { + serviceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + serviceTestResultRecv::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(serviceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(serviceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "serviceTestResultRecv", + }) + match self { + serviceTestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + serviceTestResultRecv::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTest2ArgsRecv { + pub r#type: TEST, + } + impl ::pilota::thrift::Message for ServiceTest2ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServiceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + ), + ); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.r#type) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServiceTest2ResultSend { + #[derivative(Default)] + Ok(Test), + } + + impl ::pilota::thrift::Message for ServiceTest2ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultSend", + })?; + match self { + ServiceTest2ResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultSend", + }) + match self { + ServiceTest2ResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTestArgsRecv { + pub req: TEST, + } + impl ::pilota::thrift::Message for ServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServiceTestException { + #[derivative(Default)] + E(TestException), + } + + impl ::pilota::thrift::Message for ServiceTestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestException", + })?; + match self { + ServiceTestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestException", + }) + match self { + ServiceTestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServiceTestResultSend { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for ServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultSend", + })?; + match self { + ServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServiceTestResultSend::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultSend", + }) + match self { + ServiceTestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ServiceTestResultSend::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum ServiceTestResultRecv { + #[derivative(Default)] + Ok(Test), + + E(TestException), + } + + impl ::pilota::thrift::Message for ServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultRecv", + })?; + match self { + ServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServiceTestResultRecv::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultRecv", + }) + match self { + ServiceTestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ServiceTestResultRecv::E(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Test { + pub ID: ::pilota::FastStr, + + pub Id: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for Test { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.ID).clone())?; + __protocol.write_faststr_field(2, (&self.Id).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ID is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Id is required".to_string(), + )); + }; + + let data = Self { + ID: var_1, + Id: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ID is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Id is required".to_string(), + ), + ); + }; + + let data = Self { + ID: var_1, + Id: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + + __protocol.faststr_field_len(Some(1), &self.ID) + + __protocol.faststr_field_len(Some(2), &self.Id) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use auto_name::*; +} diff --git a/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/lib.rs b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/auto_name/auto_name/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes.thrift b/pilota-build/test_data/thrift_workspace/binary_bytes.thrift new file mode 100644 index 00000000..48422250 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes/Cargo.toml b/pilota-build/test_data/thrift_workspace/binary_bytes/Cargo.toml new file mode 100644 index 00000000..f1fc84a1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["binary_bytes"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/Cargo.toml b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/Cargo.toml new file mode 100644 index 00000000..6c087b8d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "binary_bytes" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/gen.rs b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/gen.rs new file mode 100644 index 00000000..aeca20e6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/gen.rs @@ -0,0 +1,197 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod binary_bytes { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub bytes: ::pilota::Bytes, + + pub vec: ::std::vec::Vec, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.bytes).clone())?; + __protocol.write_bytes_vec_field(2, &self.vec)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_bytes_vec()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_bytes_vec().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + ), + ); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.bytes_field_len(Some(1), &self.bytes) + + __protocol.bytes_vec_field_len(Some(2), &self.vec) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use binary_bytes::*; +} diff --git a/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/lib.rs b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/binary_bytes/binary_bytes/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/const_val.thrift b/pilota-build/test_data/thrift_workspace/const_val.thrift new file mode 100644 index 00000000..ff758be7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0, + B = 1, +} + +const map TEST_MAP = { + Index.A: "hello", + Index.B: "world", +}; + + +const list TEST_LIST = [ + "hello", + "world", +]; + + +const map> TEST_MAP_LIST = { + 1: ["hello"] +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/const_val/Cargo.toml b/pilota-build/test_data/thrift_workspace/const_val/Cargo.toml new file mode 100644 index 00000000..6771b1c3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["const_val"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/const_val/const_val/Cargo.toml b/pilota-build/test_data/thrift_workspace/const_val/const_val/Cargo.toml new file mode 100644 index 00000000..d76cc391 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val/const_val/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "const_val" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/const_val/const_val/src/gen.rs b/pilota-build/test_data/thrift_workspace/const_val/const_val/src/gen.rs new file mode 100644 index 00000000..a42d4717 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val/const_val/src/gen.rs @@ -0,0 +1,113 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod const_val { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Index(i32); + + impl Index { + pub const A: Self = Self(0); + pub const B: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + ::pilota::lazy_static::lazy_static! { + pub static ref TEST_MAP_LIST: ::pilota::AHashMap> = { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(1i32, ::std::vec!["hello"]); + map + }; + } + pub const TEST_LIST: [&'static str; 2] = ["hello", "world"]; + ::pilota::lazy_static::lazy_static! { + pub static ref TEST_MAP: ::pilota::AHashMap = { + let mut map = ::pilota::AHashMap::with_capacity(2); + map.insert(Index::A, "hello");map.insert(Index::B, "world"); + map + }; + } + } + pub use const_val::*; +} diff --git a/pilota-build/test_data/thrift_workspace/const_val/const_val/src/lib.rs b/pilota-build/test_data/thrift_workspace/const_val/const_val/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/const_val/const_val/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/decode_error.thrift b/pilota-build/test_data/thrift_workspace/decode_error.thrift new file mode 100644 index 00000000..003193aa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error.thrift @@ -0,0 +1,14 @@ + + + +struct A { + 1: required B b, +} + +struct B { + 2: required C c, +} + +struct C { + 3: required string a, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/decode_error/Cargo.toml b/pilota-build/test_data/thrift_workspace/decode_error/Cargo.toml new file mode 100644 index 00000000..ccb7d65b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["decode_error"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/decode_error/decode_error/Cargo.toml b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/Cargo.toml new file mode 100644 index 00000000..afcb6003 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "decode_error" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/gen.rs b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/gen.rs new file mode 100644 index 00000000..5df854d3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/gen.rs @@ -0,0 +1,472 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod decode_error { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub b: B, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.b, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field b is required".to_string(), + )); + }; + + let data = Self { b: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field b is required".to_string(), + ), + ); + }; + + let data = Self { b: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.struct_field_len(Some(1), &self.b) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct B { + pub c: C, + } + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(2, &self.c, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field c is required".to_string(), + )); + }; + + let data = Self { c: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field c is required".to_string(), + ), + ); + }; + + let data = Self { c: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + __protocol.struct_field_len(Some(2), &self.c) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct C { + pub a: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(3, (&self.a).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field a is required".to_string(), + )); + }; + + let data = Self { a: var_3 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(3) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field a is required".to_string(), + ), + ); + }; + + let data = Self { a: var_3 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + __protocol.faststr_field_len(Some(3), &self.a) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use decode_error::*; +} diff --git a/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/lib.rs b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/decode_error/decode_error/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/default_value.thrift b/pilota-build/test_data/thrift_workspace/default_value.thrift new file mode 100644 index 00000000..9db807a4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value.thrift @@ -0,0 +1,29 @@ +enum B { + Read = 1; + Write = 2; +} + +const string A_S = "string"; + +struct A { + 1: required string faststr = "hello world", + 2: required string string = "test"(pilota.rust_type = "string"), + 3: optional bool a = false, + 4: optional B test_b = B.Read, + 5: optional B test_b2 = 2, + 6: optional i8 test_b3 = B.Read, + 7: optional map map = {"hello": "world"}, + 8: optional double test_double = 1, + 9: optional double test_double2 = 1.2, + 10: optional string alias_str = A_S, + 11: required binary empty = "", + 12: required map test_map = {1.0: 2.0}, + 13: required set test_set = [1.0], + 14: bool a2 = 3, + 15: map map2 = [], + } + +struct C { + 1: string off = "off", + 2: optional byte test_byte = 0, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/default_value/Cargo.toml b/pilota-build/test_data/thrift_workspace/default_value/Cargo.toml new file mode 100644 index 00000000..983f2173 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["default_value"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/default_value/default_value/Cargo.toml b/pilota-build/test_data/thrift_workspace/default_value/default_value/Cargo.toml new file mode 100644 index 00000000..dbe4eae4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value/default_value/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "default_value" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/default_value/default_value/src/gen.rs b/pilota-build/test_data/thrift_workspace/default_value/default_value/src/gen.rs new file mode 100644 index 00000000..afc8ed6a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value/default_value/src/gen.rs @@ -0,0 +1,951 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct B(i32); + + impl B { + pub const READ: Self = Self(1); + pub const WRITE: Self = Self(2); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("READ"), + Self(2) => ::std::string::String::from("WRITE"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for B { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: B) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + impl Default for C { + fn default() -> Self { + C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Some(0i8), + } + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] + pub struct C { + pub off: ::std::option::Option<::pilota::FastStr>, + + pub test_byte: ::std::option::Option, + } + impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.off.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.test_byte.as_ref() { + __protocol.write_i8_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_2 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self + .off + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .test_byte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + impl Default for A { + fn default() -> Self { + A { + faststr: ::pilota::FastStr::from_static_str("hello world"), + string: "test".to_string(), + a: Some(false), + test_b: Some(B::READ), + test_b2: Some(B::WRITE), + test_b3: Some((B::READ.inner() as i8)), + map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }), + test_double: Some(1f64), + test_double2: Some(1.2f64), + alias_str: Some(::pilota::FastStr::from_static_str(A_S)), + empty: ::pilota::Bytes::from_static("".as_bytes()), + test_map: { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }, + test_set: ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]), + a2: Some(true), + map2: Some(::pilota::AHashMap::new()), + } + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, + + pub a: ::std::option::Option, + + pub test_b: ::std::option::Option, + + pub test_b2: ::std::option::Option, + + pub test_b3: ::std::option::Option, + + pub map: + ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + + pub test_double: ::std::option::Option, + + pub test_double2: ::std::option::Option, + + pub alias_str: ::std::option::Option<::pilota::FastStr>, + + pub empty: ::pilota::Bytes, + + pub test_map: ::pilota::AHashMap<::pilota::OrderedFloat, f64>, + + pub test_set: ::pilota::AHashSet<::pilota::OrderedFloat>, + + pub a2: ::std::option::Option, + + pub map2: + ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_bool_field(3, *value)?; + } + if let Some(value) = self.test_b.as_ref() { + __protocol.write_i32_field(4, (value).inner())?; + } + if let Some(value) = self.test_b2.as_ref() { + __protocol.write_i32_field(5, (value).inner())?; + } + if let Some(value) = self.test_b3.as_ref() { + __protocol.write_i8_field(6, *value)?; + } + if let Some(value) = self.map.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.test_double.as_ref() { + __protocol.write_double_field(8, *value)?; + } + if let Some(value) = self.test_double2.as_ref() { + __protocol.write_double_field(9, *value)?; + } + if let Some(value) = self.alias_str.as_ref() { + __protocol.write_faststr_field(10, (value).clone())?; + } + __protocol.write_bytes_field(11, (&self.empty).clone())?; + __protocol.write_map_field( + 12, + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &&self.test_map, + |__protocol, key| { + __protocol.write_double(key.0)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_double(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_set_field( + 13, + ::pilota::thrift::TType::Double, + &&self.test_set, + |__protocol, val| { + __protocol.write_double(val.0)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.a2.as_ref() { + __protocol.write_bool_field(14, *value)?; + } + if let Some(value) = self.map2.as_ref() { + __protocol.write_map_field( + 15, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = __protocol.read_faststr()?; + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8()?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(8) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_8 = Some(__protocol.read_double()?); + } + Some(9) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_9 = Some(__protocol.read_double()?); + } + Some(10) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_10 = Some(__protocol.read_faststr()?); + } + Some(11) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_11 = __protocol.read_bytes()?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double()?), + __protocol.read_double()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double()?, + )); + } + __protocol.read_set_end()?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool()?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = var_13 + .unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = __protocol.read_faststr().await?; + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string().await?); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_3 = Some(__protocol.read_bool().await?); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_4 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(5) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_5 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(6) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_6 = Some(__protocol.read_i8().await?); + } + Some(7) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(8) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_8 = Some(__protocol.read_double().await?); + } + Some(9) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_9 = Some(__protocol.read_double().await?); + } + Some(10) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_10 = Some(__protocol.read_faststr().await?); + } + Some(11) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_11 = __protocol.read_bytes().await?; + } + Some(12) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_12 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat( + __protocol.read_double().await?, + ), + __protocol.read_double().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(13) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_13 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double().await?, + )); + } + __protocol.read_set_end().await?; + val + }); + } + Some(14) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_14 = Some(__protocol.read_bool().await?); + } + Some(15) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_15 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = var_13.unwrap_or_else(|| { + ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]) + }); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(3), *value)) + + self.test_b.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(4), (value).inner()) + }) + + self.test_b2.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(5), (value).inner()) + }) + + self + .test_b3 + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(6), *value)) + + self.map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + self + .test_double + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(8), *value)) + + self + .test_double2 + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(9), *value)) + + self + .alias_str + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(10), value)) + + __protocol.bytes_field_len(Some(11), &self.empty) + + __protocol.map_field_len( + Some(12), + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &self.test_map, + |__protocol, key| __protocol.double_len(key.0), + |__protocol, val| __protocol.double_len(*val), + ) + + __protocol.set_field_len( + Some(13), + ::pilota::thrift::TType::Double, + &self.test_set, + |__protocol, el| __protocol.double_len(el.0), + ) + + self + .a2 + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(14), *value)) + + self.map2.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(15), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub const A_S: &'static str = "string"; + } + pub use default_value::*; +} diff --git a/pilota-build/test_data/thrift_workspace/default_value/default_value/src/lib.rs b/pilota-build/test_data/thrift_workspace/default_value/default_value/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/default_value/default_value/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/enum_map.thrift b/pilota-build/test_data/thrift_workspace/enum_map.thrift new file mode 100644 index 00000000..16675284 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map.thrift @@ -0,0 +1,14 @@ +typedef i32 TypeB + +const TypeB TypeB1 = 1 +const TypeB TypeB2 = 2 + +typedef string TypeA + +const TypeA TypeA1 = "a1" +const TypeA TypeA2 = "a2" + +const map TypeAMap = { + TypeB1: TypeA1, + TypeB2: TypeA2, +} diff --git a/pilota-build/test_data/thrift_workspace/enum_map/Cargo.toml b/pilota-build/test_data/thrift_workspace/enum_map/Cargo.toml new file mode 100644 index 00000000..81b15212 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["enum_map"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/enum_map/enum_map/Cargo.toml b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/Cargo.toml new file mode 100644 index 00000000..b323b400 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "enum_map" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/gen.rs b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/gen.rs new file mode 100644 index 00000000..a729d943 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/gen.rs @@ -0,0 +1,132 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod enum_map { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TypeB(pub i32); + + impl ::std::ops::Deref for TypeB { + type Target = i32; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl From for TypeB { + fn from(v: i32) -> Self { + Self(v) + } + } + + impl ::pilota::thrift::Message for TypeB { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(*(&**self))?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(TypeB(__protocol.read_i32()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(TypeB(__protocol.read_i32().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(*&**self) + } + } + pub const TYPE_A2: TypeA = TypeA(::pilota::FastStr::from_static_str("a2")); + pub const TYPE_B2: TypeB = TypeB(2i32); + pub const TYPE_A1: TypeA = TypeA(::pilota::FastStr::from_static_str("a1")); + pub const TYPE_B1: TypeB = TypeB(1i32); + ::pilota::lazy_static::lazy_static! { + pub static ref TYPE_A_MAP: ::pilota::AHashMap = { + let mut map = ::pilota::AHashMap::with_capacity(2); + map.insert(TYPE_B1, TYPE_A1);map.insert(TYPE_B2, TYPE_A2); + map + }; + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TypeA(pub ::pilota::FastStr); + + impl ::std::ops::Deref for TypeA { + type Target = ::pilota::FastStr; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl From<::pilota::FastStr> for TypeA { + fn from(v: ::pilota::FastStr) -> Self { + Self(v) + } + } + + impl ::pilota::thrift::Message for TypeA { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_faststr((&**self).clone())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(TypeA(__protocol.read_faststr()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(TypeA(__protocol.read_faststr().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.faststr_len(&**self) + } + } + } + pub use enum_map::*; +} diff --git a/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/lib.rs b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_map/enum_map/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/enum_test.thrift b/pilota-build/test_data/thrift_workspace/enum_test.thrift new file mode 100644 index 00000000..d0cbb42e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0x01, + B = 0x10, +} + +enum Err { + +} + +enum Ok { +} + +struct Request { + 1: required Index Index, + 2: Index index, +} +service Test { + Err test_enum(1: Ok req); + Err test_enum_var_type_name_conflict (1: Request req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/enum_test/Cargo.toml b/pilota-build/test_data/thrift_workspace/enum_test/Cargo.toml new file mode 100644 index 00000000..2a0d1a05 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["enum_test"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/enum_test/enum_test/Cargo.toml b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/Cargo.toml new file mode 100644 index 00000000..3cd297ac --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "enum_test" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/gen.rs b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/gen.rs new file mode 100644 index 00000000..bee5c05d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/gen.rs @@ -0,0 +1,1644 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod enum_test { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTestEnumVarTypeNameConflictArgsSend { + pub req: Request, + } + impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Index(i32); + + impl Index { + pub const A: Self = Self(1); + pub const B: Self = Self(16); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("A"), + Self(16) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTestEnumArgsSend { + pub req: Ok, + } + impl ::pilota::thrift::Message for TestTestEnumArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.req).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsSend", + }) + __protocol.i32_field_len(Some(1), (&self.req).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Ok(i32); + + impl Ok { + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Ok { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Ok) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Ok { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Ok, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Ok, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTestEnumVarTypeNameConflictArgsRecv { + pub req: Request, + } + impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestEnumVarTypeNameConflictResultSend { + #[derivative(Default)] + Ok(Err), + } + + impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultSend", + })?; + match self { + TestTestEnumVarTypeNameConflictResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumVarTypeNameConflictResultSend::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestEnumVarTypeNameConflictResultSend::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultSend", + }) + match self { + TestTestEnumVarTypeNameConflictResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTestEnumArgsRecv { + pub req: Ok, + } + impl ::pilota::thrift::Message for TestTestEnumArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.req).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsRecv", + }) + __protocol.i32_field_len(Some(1), (&self.req).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestEnumResultSend { + #[derivative(Default)] + Ok(Err), + } + + impl ::pilota::thrift::Message for TestTestEnumResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultSend", + })?; + match self { + TestTestEnumResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultSend", + }) + match self { + TestTestEnumResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Request { + pub Index: Index, + + pub index: ::std::option::Option, + } + impl ::pilota::thrift::Message for Request { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Request" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.Index).inner())?; + if let Some(value) = self.index.as_ref() { + __protocol.write_i32_field(2, (value).inner())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Request` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Index is required".to_string(), + )); + }; + + let data = Self { + Index: var_1, + index: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_2 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Request` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Index is required".to_string(), + ), + ); + }; + + let data = Self { + Index: var_1, + index: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Request" }) + + __protocol.i32_field_len(Some(1), (&self.Index).inner()) + + self.index.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(2), (value).inner()) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait Test {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestEnumVarTypeNameConflictResultRecv { + #[derivative(Default)] + Ok(Err), + } + + impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultRecv", + })?; + match self { + TestTestEnumVarTypeNameConflictResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumVarTypeNameConflictResultRecv::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestEnumVarTypeNameConflictResultRecv::Ok( + field_ident, + )); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultRecv", + }) + match self { + TestTestEnumVarTypeNameConflictResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestEnumResultRecv { + #[derivative(Default)] + Ok(Err), + } + + impl ::pilota::thrift::Message for TestTestEnumResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultRecv", + })?; + match self { + TestTestEnumResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultRecv", + }) + match self { + TestTestEnumResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Err(i32); + + impl Err { + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Err { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Err) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Err { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Err, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Err, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + } + pub use enum_test::*; +} diff --git a/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/lib.rs b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/enum_test/enum_test/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/multi.thrift b/pilota-build/test_data/thrift_workspace/multi.thrift new file mode 100644 index 00000000..cc3fb25c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi.thrift @@ -0,0 +1,11 @@ +include "default_value.thrift" +include "recursive_type.thrift" + +struct A { + 1: default_value.C c = {"off": "off"}, +} + +struct B { + 1: recursive_type.A a, + 2: recursive_type.C c, +} diff --git a/pilota-build/test_data/thrift_workspace/multi/Cargo.toml b/pilota-build/test_data/thrift_workspace/multi/Cargo.toml new file mode 100644 index 00000000..2f78d8c3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ "common","multi"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/multi/common/Cargo.toml b/pilota-build/test_data/thrift_workspace/multi/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/multi/common/src/gen.rs b/pilota-build/test_data/thrift_workspace/multi/common/src/gen.rs new file mode 100644 index 00000000..f3f9438a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/common/src/gen.rs @@ -0,0 +1,1450 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + + impl Default for C { + fn default() -> Self { + C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Some(0i8), + } + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] + pub struct C { + pub off: ::std::option::Option<::pilota::FastStr>, + + pub test_byte: ::std::option::Option, + } + impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.off.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.test_byte.as_ref() { + __protocol.write_i8_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_2 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self + .off + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .test_byte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub const A_S: &'static str = "string"; + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct B(i32); + + impl B { + pub const READ: Self = Self(1); + pub const WRITE: Self = Self(2); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("READ"), + Self(2) => ::std::string::String::from("WRITE"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for B { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: B) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + impl Default for A { + fn default() -> Self { + A { + faststr: ::pilota::FastStr::from_static_str("hello world"), + string: "test".to_string(), + a: Some(false), + test_b: Some(B::READ), + test_b2: Some(B::WRITE), + test_b3: Some((B::READ.inner() as i8)), + map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }), + test_double: Some(1f64), + test_double2: Some(1.2f64), + alias_str: Some(::pilota::FastStr::from_static_str(A_S)), + empty: ::pilota::Bytes::from_static("".as_bytes()), + test_map: { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }, + test_set: ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]), + a2: Some(true), + map2: Some(::pilota::AHashMap::new()), + } + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, + + pub a: ::std::option::Option, + + pub test_b: ::std::option::Option, + + pub test_b2: ::std::option::Option, + + pub test_b3: ::std::option::Option, + + pub map: + ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + + pub test_double: ::std::option::Option, + + pub test_double2: ::std::option::Option, + + pub alias_str: ::std::option::Option<::pilota::FastStr>, + + pub empty: ::pilota::Bytes, + + pub test_map: ::pilota::AHashMap<::pilota::OrderedFloat, f64>, + + pub test_set: ::pilota::AHashSet<::pilota::OrderedFloat>, + + pub a2: ::std::option::Option, + + pub map2: + ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_bool_field(3, *value)?; + } + if let Some(value) = self.test_b.as_ref() { + __protocol.write_i32_field(4, (value).inner())?; + } + if let Some(value) = self.test_b2.as_ref() { + __protocol.write_i32_field(5, (value).inner())?; + } + if let Some(value) = self.test_b3.as_ref() { + __protocol.write_i8_field(6, *value)?; + } + if let Some(value) = self.map.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.test_double.as_ref() { + __protocol.write_double_field(8, *value)?; + } + if let Some(value) = self.test_double2.as_ref() { + __protocol.write_double_field(9, *value)?; + } + if let Some(value) = self.alias_str.as_ref() { + __protocol.write_faststr_field(10, (value).clone())?; + } + __protocol.write_bytes_field(11, (&self.empty).clone())?; + __protocol.write_map_field( + 12, + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &&self.test_map, + |__protocol, key| { + __protocol.write_double(key.0)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_double(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_set_field( + 13, + ::pilota::thrift::TType::Double, + &&self.test_set, + |__protocol, val| { + __protocol.write_double(val.0)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.a2.as_ref() { + __protocol.write_bool_field(14, *value)?; + } + if let Some(value) = self.map2.as_ref() { + __protocol.write_map_field( + 15, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = __protocol.read_faststr()?; + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8()?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(8) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_8 = Some(__protocol.read_double()?); + } + Some(9) + if field_ident.field_type == ::pilota::thrift::TType::Double => + { + var_9 = Some(__protocol.read_double()?); + } + Some(10) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_10 = Some(__protocol.read_faststr()?); + } + Some(11) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_11 = __protocol.read_bytes()?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double()?), + __protocol.read_double()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double()?, + )); + } + __protocol.read_set_end()?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool()?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + __protocol.read_faststr()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = var_13 + .unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = __protocol.read_faststr().await?; + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string().await?); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_3 = Some(__protocol.read_bool().await?); + } + Some(4) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_4 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(5) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_5 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(6) + if field_ident.field_type == ::pilota::thrift::TType::I8 => + { + var_6 = Some(__protocol.read_i8().await?); + } + Some(7) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(8) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_8 = Some(__protocol.read_double().await?); + } + Some(9) + if field_ident.field_type + == ::pilota::thrift::TType::Double => + { + var_9 = Some(__protocol.read_double().await?); + } + Some(10) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_10 = Some(__protocol.read_faststr().await?); + } + Some(11) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_11 = __protocol.read_bytes().await?; + } + Some(12) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_12 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat( + __protocol.read_double().await?, + ), + __protocol.read_double().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(13) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_13 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double().await?, + )); + } + __protocol.read_set_end().await?; + val + }); + } + Some(14) + if field_ident.field_type == ::pilota::thrift::TType::Bool => + { + var_14 = Some(__protocol.read_bool().await?); + } + Some(15) + if field_ident.field_type == ::pilota::thrift::TType::Map => + { + var_15 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = var_13.unwrap_or_else(|| { + ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]) + }); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(3), *value)) + + self.test_b.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(4), (value).inner()) + }) + + self.test_b2.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(5), (value).inner()) + }) + + self + .test_b3 + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(6), *value)) + + self.map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + self + .test_double + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(8), *value)) + + self + .test_double2 + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(9), *value)) + + self + .alias_str + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(10), value)) + + __protocol.bytes_field_len(Some(11), &self.empty) + + __protocol.map_field_len( + Some(12), + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &self.test_map, + |__protocol, key| __protocol.double_len(key.0), + |__protocol, val| __protocol.double_len(*val), + ) + + __protocol.set_field_len( + Some(13), + ::pilota::thrift::TType::Double, + &self.test_set, + |__protocol, el| __protocol.double_len(el.0), + ) + + self + .a2 + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(14), *value)) + + self.map2.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(15), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + + pub mod recursive_type { + #[derive(Debug, Default, Clone, PartialEq)] + pub struct C { + pub c: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.c.as_ref() { + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self.c.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub a: ::std::option::Option<::std::boxed::Box>, + + pub a_b: ::std::option::Option<::std::boxed::Box>, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.a_b.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .a_b + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct B { + pub b_a: ::std::option::Option<::std::boxed::Box>, + } + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b_a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .b_a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } +} diff --git a/pilota-build/test_data/thrift_workspace/multi/common/src/lib.rs b/pilota-build/test_data/thrift_workspace/multi/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/multi/multi/Cargo.toml b/pilota-build/test_data/thrift_workspace/multi/multi/Cargo.toml new file mode 100644 index 00000000..60675327 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/multi/Cargo.toml @@ -0,0 +1,19 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.common] +path = "../common" + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "multi" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/multi/multi/src/gen.rs b/pilota-build/test_data/thrift_workspace/multi/multi/src/gen.rs new file mode 100644 index 00000000..fe3a8974 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/multi/src/gen.rs @@ -0,0 +1,345 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + pub use ::common::default_value::C; + } + + pub mod multi { + + impl Default for A { + fn default() -> Self { + A { + c: Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }), + } + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] + pub struct A { + pub c: ::std::option::Option<::common::default_value::C>, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.c.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_1.is_none() { + var_1 = Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }); + } + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::default_value::C as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `A` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_1.is_none() { + var_1 = Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }); + } + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .c + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct B { + pub a: ::std::option::Option<::common::recursive_type::A>, + + pub c: ::std::option::Option<::common::recursive_type::C>, + } + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.c.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { a: var_1, c: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::recursive_type::A as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(<::common::recursive_type::C as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `B` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { a: var_1, c: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .c + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + + pub mod recursive_type { + pub use ::common::recursive_type::A; + pub use ::common::recursive_type::B; + pub use ::common::recursive_type::C; + } + pub use multi::*; +} diff --git a/pilota-build/test_data/thrift_workspace/multi/multi/src/lib.rs b/pilota-build/test_data/thrift_workspace/multi/multi/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/multi/multi/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/normal.thrift b/pilota-build/test_data/thrift_workspace/normal.thrift new file mode 100644 index 00000000..11699ed6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal.thrift @@ -0,0 +1,37 @@ + + +struct A { + 1: i32 a, +} + +struct b { + 2: A a, +} + +struct SubMessage { + 2: optional string value; +} + +struct Message { + 1: uuid uid; + 2: optional string value; + 3: optional list subMessages; +} + +struct ObjReq { + 1: required Message msg + 2: required map msgMap + 3: required list subMsgs + 4: optional set msgSet + 5: required string flagMsg + 6: optional string mockCost, +} + +exception STException { + 1: string message; +} + +service Test { + void test_123(); + ObjReq testException(1: ObjReq req) throws (1: STException stException); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/normal/Cargo.toml b/pilota-build/test_data/thrift_workspace/normal/Cargo.toml new file mode 100644 index 00000000..7f54eb77 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["normal"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/normal/normal/Cargo.toml b/pilota-build/test_data/thrift_workspace/normal/normal/Cargo.toml new file mode 100644 index 00000000..b0679404 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal/normal/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "normal" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/normal/normal/src/gen.rs b/pilota-build/test_data/thrift_workspace/normal/normal/src/gen.rs new file mode 100644 index 00000000..bdb1f87b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal/normal/src/gen.rs @@ -0,0 +1,2436 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod normal { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub a: ::std::option::Option, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::I32 => + { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct TestTestExceptionArgsSend { + pub req: ObjReq, + } + impl ::pilota::thrift::Message for TestTestExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTest123ArgsRecv {} + impl ::pilota::thrift::Message for TestTest123ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTest123ResultSend { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for TestTest123ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + })?; + match self { + TestTest123ResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + }) + match self { + TestTest123ResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct StException { + pub message: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for StException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "StException", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { message: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { message: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "StException", + }) + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct SubMessage { + pub value: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for SubMessage { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "SubMessage" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.value.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `SubMessage` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { value: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `SubMessage` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { value: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "SubMessage" }) + + self + .value + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait Test {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTest123ArgsSend {} + impl ::pilota::thrift::Message for TestTest123ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct ObjReq { + pub msg: Message, + + pub msg_map: ::pilota::AHashMap, + + pub sub_msgs: ::std::vec::Vec, + + pub msg_set: ::std::option::Option<::pilota::AHashSet>, + + pub flag_msg: ::pilota::FastStr, + + pub mock_cost: ::std::option::Option<::pilota::FastStr>, + } + impl ::pilota::thrift::Message for ObjReq { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "ObjReq" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.msg, ::pilota::thrift::TType::Struct)?; + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Struct, + &&self.msg_map, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Struct, + &&self.sub_msgs, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.msg_set.as_ref() { + __protocol.write_set_field( + 4, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_faststr_field(5, (&self.flag_msg).clone())?; + if let Some(value) = self.mock_cost.as_ref() { + __protocol.write_faststr_field(6, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_4 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?); + } + __protocol.read_set_end()?; + val + }); + } + Some(5) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_5 = Some(__protocol.read_faststr()?); + } + Some(6) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_6 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ObjReq` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg_map is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field sub_msgs is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field flag_msg is required".to_string(), + )); + }; + + let data = Self { + msg: var_1, + msg_map: var_2, + sub_msgs: var_3, + msg_set: var_4, + flag_msg: var_5, + mock_cost: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::decode_async(__protocol).await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::decode_async(__protocol).await?, ::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_4 = Some({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::decode_async(__protocol).await?); + }; + __protocol.read_set_end().await?; + val}); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_5 = Some(__protocol.read_faststr().await?); + + },Some(6) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_6 = Some(__protocol.read_faststr().await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ObjReq` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg_map is required".to_string(), + ), + ); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field sub_msgs is required".to_string(), + ), + ); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field flag_msg is required".to_string(), + ), + ); + }; + + let data = Self { + msg: var_1, + msg_map: var_2, + sub_msgs: var_3, + msg_set: var_4, + flag_msg: var_5, + mock_cost: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "ObjReq" }) + + __protocol.struct_field_len(Some(1), &self.msg) + + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Struct, + &self.msg_map, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Struct, + &self.sub_msgs, + |__protocol, el| __protocol.struct_len(el), + ) + + self.msg_set.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(4), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.faststr_field_len(Some(5), &self.flag_msg) + + self + .mock_cost + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(6), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct B { + pub a: ::std::option::Option, + } + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { a: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { a: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct TestTestExceptionArgsRecv { + pub req: ObjReq, + } + impl ::pilota::thrift::Message for TestTestExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestExceptionException { + #[derivative(Default)] + StException(StException), + } + + impl ::pilota::thrift::Message for TestTestExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionException", + })?; + match self { + TestTestExceptionException::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionException::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = + Some(TestTestExceptionException::StException(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionException", + }) + match self { + TestTestExceptionException::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestExceptionResultSend { + #[derivative(Default)] + Ok(ObjReq), + + StException(StException), + } + + impl ::pilota::thrift::Message for TestTestExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultSend", + })?; + match self { + TestTestExceptionResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + TestTestExceptionResultSend::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultSend::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = + Some(TestTestExceptionResultSend::StException(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultSend", + }) + match self { + TestTestExceptionResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + TestTestExceptionResultSend::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTestExceptionResultRecv { + #[derivative(Default)] + Ok(ObjReq), + + StException(StException), + } + + impl ::pilota::thrift::Message for TestTestExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultRecv", + })?; + match self { + TestTestExceptionResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + TestTestExceptionResultRecv::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultRecv::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = + Some(TestTestExceptionResultRecv::StException(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultRecv", + }) + match self { + TestTestExceptionResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + TestTestExceptionResultRecv::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTest123ResultRecv { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for TestTest123ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + })?; + match self { + TestTest123ResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + }) + match self { + TestTest123ResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Message { + pub uid: ::std::option::Option<[u8; 16]>, + + pub value: ::std::option::Option<::pilota::FastStr>, + + pub sub_messages: ::std::option::Option<::std::vec::Vec>, + } + impl ::pilota::thrift::Message for Message { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Message" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.uid.as_ref() { + __protocol.write_uuid_field(1, *value)?; + } + if let Some(value) = self.value.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + if let Some(value) = self.sub_messages.as_ref() { + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Message` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + uid: var_1, + value: var_2, + sub_messages: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Message` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + uid: var_1, + value: var_2, + sub_messages: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol + .struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Message" }) + + self + .uid + .as_ref() + .map_or(0, |value| __protocol.uuid_field_len(Some(1), *value)) + + self + .value + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + self.sub_messages.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use normal::*; +} diff --git a/pilota-build/test_data/thrift_workspace/normal/normal/src/lib.rs b/pilota-build/test_data/thrift_workspace/normal/normal/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/normal/normal/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/path_keyword.thrift b/pilota-build/test_data/thrift_workspace/path_keyword.thrift new file mode 100644 index 00000000..00d6e57f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword.thrift @@ -0,0 +1,5 @@ +namespace rs enum; +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/path_keyword/Cargo.toml b/pilota-build/test_data/thrift_workspace/path_keyword/Cargo.toml new file mode 100644 index 00000000..bc22561f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["path_keyword"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/Cargo.toml b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/Cargo.toml new file mode 100644 index 00000000..028187ac --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "path_keyword" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/gen.rs b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/gen.rs new file mode 100644 index 00000000..9ef04455 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/gen.rs @@ -0,0 +1,197 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod r#enum { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub bytes: ::pilota::Bytes, + + pub vec: ::std::vec::Vec, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.bytes).clone())?; + __protocol.write_bytes_vec_field(2, &self.vec)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_bytes_vec()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_bytes().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_bytes_vec().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + ), + ); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.bytes_field_len(Some(1), &self.bytes) + + __protocol.bytes_vec_field_len(Some(2), &self.vec) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use r#enum::*; +} diff --git a/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/lib.rs b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/path_keyword/path_keyword/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/pilota_name.thrift b/pilota-build/test_data/thrift_workspace/pilota_name.thrift new file mode 100644 index 00000000..17264f2c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name.thrift @@ -0,0 +1,20 @@ + +struct TEST { + 1: required string ID, +}(pilota.name="Test2") + +const string id = "id" (pilota.name="LANG_ID"); + +struct Test { + 1: required string ID, + 2: required string Id (pilota.name="hello"), +}(pilota.name="Test1") + +enum Index { + A (pilota.name="AA"), + B, +} + +service TestService { + Test test(1: TEST req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/pilota_name/Cargo.toml b/pilota-build/test_data/thrift_workspace/pilota_name/Cargo.toml new file mode 100644 index 00000000..cf8bdce7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["pilota_name"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/Cargo.toml b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/Cargo.toml new file mode 100644 index 00000000..e1d5693b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "pilota_name" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/gen.rs b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/gen.rs new file mode 100644 index 00000000..865cda82 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/gen.rs @@ -0,0 +1,1037 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod pilota_name { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Test2 { + pub id: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for Test2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test2" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + + let data = Self { id: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + ), + ); + }; + + let data = Self { id: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test2" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestServiceTestArgsSend { + pub req: Test2, + } + impl ::pilota::thrift::Message for TestServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub const LANG_ID: &'static str = "id"; + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestServiceTestArgsRecv { + pub req: Test2, + } + impl ::pilota::thrift::Message for TestServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestServiceTestResultSend { + #[derivative(Default)] + Ok(Test1), + } + + impl ::pilota::thrift::Message for TestServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + })?; + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + }) + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Test1 { + pub id: ::pilota::FastStr, + + pub hello: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for Test1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test1" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_faststr_field(2, (&self.hello).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + ), + ); + }; + + let data = Self { + id: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test1" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.faststr_field_len(Some(2), &self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait TestService {} + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestServiceTestResultRecv { + #[derivative(Default)] + Ok(Test1), + } + + impl ::pilota::thrift::Message for TestServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + })?; + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + }) + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Index(i32); + + impl Index { + pub const AA: Self = Self(0); + pub const B: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("AA"), + Self(1) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + } + pub use pilota_name::*; +} diff --git a/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/lib.rs b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/pilota_name/pilota_name/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/recursive_type.thrift b/pilota-build/test_data/thrift_workspace/recursive_type.thrift new file mode 100644 index 00000000..c5828f68 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type.thrift @@ -0,0 +1,12 @@ +struct A { + 1: optional A a, + 2: optional B a_b, +} + +struct B { + 1: optional A b_a, +} + +struct C { + 1: set c, +} diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/Cargo.toml b/pilota-build/test_data/thrift_workspace/recursive_type/Cargo.toml new file mode 100644 index 00000000..28d2aa02 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ "common","recursive_type"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/common/Cargo.toml b/pilota-build/test_data/thrift_workspace/recursive_type/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/common/src/gen.rs b/pilota-build/test_data/thrift_workspace/recursive_type/common/src/gen.rs new file mode 100644 index 00000000..bc5f0378 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/common/src/gen.rs @@ -0,0 +1,333 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod recursive_type { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub a: ::std::option::Option<::std::boxed::Box>, + + pub a_b: ::std::option::Option<::std::boxed::Box>, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.a_b.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_2 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .a_b + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct B { + pub b_a: ::std::option::Option<::std::boxed::Box>, + } + impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b_a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .b_a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } +} diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/common/src/lib.rs b/pilota-build/test_data/thrift_workspace/recursive_type/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/Cargo.toml b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/Cargo.toml new file mode 100644 index 00000000..6296d223 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "recursive_type" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/gen.rs b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/gen.rs new file mode 100644 index 00000000..ce9ee3f9 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/gen.rs @@ -0,0 +1,176 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod recursive_type { + #[derive(Debug, Default, Clone, PartialEq)] + pub struct C { + pub c: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, + } + impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.c.as_ref() { + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Set => + { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self.c.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use recursive_type::*; +} diff --git a/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/lib.rs b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/recursive_type/recursive_type/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/self_kw.thrift b/pilota-build/test_data/thrift_workspace/self_kw.thrift new file mode 100644 index 00000000..8c7d7551 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw.thrift @@ -0,0 +1,10 @@ +enum Index { + A = 0, + Self = 1, +} + +struct A { + 1: required string type, + 2: required string self, + 3: required string protocol, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/self_kw/Cargo.toml b/pilota-build/test_data/thrift_workspace/self_kw/Cargo.toml new file mode 100644 index 00000000..99fa3f00 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["self_kw"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/self_kw/self_kw/Cargo.toml b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/Cargo.toml new file mode 100644 index 00000000..05b3420a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "self_kw" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/gen.rs b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/gen.rs new file mode 100644 index 00000000..579fa1eb --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/gen.rs @@ -0,0 +1,321 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod self_kw { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq, Copy)] + #[repr(transparent)] + pub struct Index(i32); + + impl Index { + pub const A: Self = Self(0); + pub const SELF: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("SELF"), + Self(val) => val.to_string(), + } + } + } + + impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } + } + + impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } + } + + impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err( + |err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub r#type: ::pilota::FastStr, + + pub self_: ::pilota::FastStr, + + pub protocol: ::pilota::FastStr, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.r#type).clone())?; + __protocol.write_faststr_field(2, (&self.self_).clone())?; + __protocol.write_faststr_field(3, (&self.protocol).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr()?); + } + Some(3) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field protocol is required".to_string(), + )); + }; + + let data = Self { + r#type: var_1, + self_: var_2, + protocol: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_faststr().await?); + } + Some(3) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_3 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + ), + ); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field protocol is required".to_string(), + ), + ); + }; + + let data = Self { + r#type: var_1, + self_: var_2, + protocol: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.r#type) + + __protocol.faststr_field_len(Some(2), &self.self_) + + __protocol.faststr_field_len(Some(3), &self.protocol) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use self_kw::*; +} diff --git a/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/lib.rs b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/self_kw/self_kw/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/string.thrift b/pilota-build/test_data/thrift_workspace/string.thrift new file mode 100644 index 00000000..8894e584 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required string faststr, + 2: required string string(pilota.rust_type = "string"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/string/Cargo.toml b/pilota-build/test_data/thrift_workspace/string/Cargo.toml new file mode 100644 index 00000000..0f970afd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["string"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/string/string/Cargo.toml b/pilota-build/test_data/thrift_workspace/string/string/Cargo.toml new file mode 100644 index 00000000..a04b3edc --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string/string/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "string" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/string/string/src/gen.rs b/pilota-build/test_data/thrift_workspace/string/string/src/gen.rs new file mode 100644 index 00000000..6cdd24fa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string/string/src/gen.rs @@ -0,0 +1,197 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod string { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field faststr is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field string is required".to_string(), + )); + }; + + let data = Self { + faststr: var_1, + string: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) + if field_ident.field_type + == ::pilota::thrift::TType::Binary => + { + var_2 = Some(__protocol.read_string().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field faststr is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field string is required".to_string(), + ), + ); + }; + + let data = Self { + faststr: var_1, + string: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use string::*; +} diff --git a/pilota-build/test_data/thrift_workspace/string/string/src/lib.rs b/pilota-build/test_data/thrift_workspace/string/string/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/string/string/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/union.thrift b/pilota-build/test_data/thrift_workspace/union.thrift new file mode 100644 index 00000000..a1bbd6b8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union.thrift @@ -0,0 +1,12 @@ +union Union { + 1: string a, + 2: binary b, +} + +struct A { + 1: Union u, +} + +union Empty { + +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/union/Cargo.toml b/pilota-build/test_data/thrift_workspace/union/Cargo.toml new file mode 100644 index 00000000..5dd14e9e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["union"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/union/union/Cargo.toml b/pilota-build/test_data/thrift_workspace/union/union/Cargo.toml new file mode 100644 index 00000000..d8f52c2d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union/union/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "union" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/union/union/src/gen.rs b/pilota-build/test_data/thrift_workspace/union/union/src/gen.rs new file mode 100644 index 00000000..edd9f40c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union/union/src/gen.rs @@ -0,0 +1,423 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod union { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum Union { + #[derivative(Default)] + A(::pilota::FastStr), + + B(::pilota::Bytes), + } + + impl ::pilota::thrift::Message for Union { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol + .write_struct_begin(&::pilota::thrift::TStructIdentifier { name: "Union" })?; + match self { + Union::A(ref value) => { + __protocol.write_faststr_field(1, (value).clone())?; + } + Union::B(ref value) => { + __protocol.write_bytes_field(2, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(Union::A(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(Union::B(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(Union::A(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(Union::B(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Union" }) + + match self { + Union::A(ref value) => __protocol.faststr_field_len(Some(1), value), + Union::B(ref value) => __protocol.bytes_field_len(Some(2), value), + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] + pub enum Empty {} + + impl ::pilota::thrift::Message for Empty { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol + .write_struct_begin(&::pilota::thrift::TStructIdentifier { name: "Empty" })?; + match self { + _ => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Empty" }) + + match self { + _ => 0, + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A { + pub u: ::std::option::Option, + } + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.u.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { u: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { u: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .u + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use union::*; +} diff --git a/pilota-build/test_data/thrift_workspace/union/union/src/lib.rs b/pilota-build/test_data/thrift_workspace/union/union/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/union/union/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/void.thrift b/pilota-build/test_data/thrift_workspace/void.thrift new file mode 100644 index 00000000..91c35d7b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void.thrift @@ -0,0 +1,3 @@ +service Test { + void test_123(); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace/void/Cargo.toml b/pilota-build/test_data/thrift_workspace/void/Cargo.toml new file mode 100644 index 00000000..f7a4f773 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["void"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/void/void/Cargo.toml b/pilota-build/test_data/thrift_workspace/void/void/Cargo.toml new file mode 100644 index 00000000..cbb855a2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void/void/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "void" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/void/void/src/gen.rs b/pilota-build/test_data/thrift_workspace/void/void/src/gen.rs new file mode 100644 index 00000000..07806985 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void/void/src/gen.rs @@ -0,0 +1,450 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod void { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTest123ResultRecv { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for TestTest123ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + })?; + match self { + TestTest123ResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + }) + match self { + TestTest123ResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTest123ArgsRecv {} + impl ::pilota::thrift::Message for TestTest123ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestTest123ResultSend { + #[derivative(Default)] + Ok(()), + } + + impl ::pilota::thrift::Message for TestTest123ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + })?; + match self { + TestTest123ResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + }) + match self { + TestTest123ResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct TestTest123ArgsSend {} + impl ::pilota::thrift::Message for TestTest123ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait Test {} + } + pub use void::*; +} diff --git a/pilota-build/test_data/thrift_workspace/void/void/src/lib.rs b/pilota-build/test_data/thrift_workspace/void/void/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/void/void/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift b/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift new file mode 100644 index 00000000..6bb95526 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc.thrift @@ -0,0 +1,13 @@ +struct A { + +} + +struct TEST { + 1: required string ID, + 2: required list> Name2(pilota.rust_wrapper_arc="true"), + 3: required map> Name3(pilota.rust_wrapper_arc="true"), +} + +service TestService { + TEST(pilota.rust_wrapper_arc="true") test(1: TEST req(pilota.rust_wrapper_arc="true")); +} diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc/Cargo.toml b/pilota-build/test_data/thrift_workspace/wrapper_arc/Cargo.toml new file mode 100644 index 00000000..bc9f3b17 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["wrapper_arc"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/Cargo.toml b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/Cargo.toml new file mode 100644 index 00000000..c5cd0d42 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "wrapper_arc" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/gen.rs b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/gen.rs new file mode 100644 index 00000000..736aa5a3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/gen.rs @@ -0,0 +1,1080 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod wrapper_arc { + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct A {} + impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + pub trait TestService {} + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestServiceTestResultRecv { + #[derivative(Default)] + Ok(Test), + } + + impl ::pilota::thrift::Message for TestServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + })?; + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + }) + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct TestServiceTestArgsRecv { + pub req: Test, + } + impl ::pilota::thrift::Message for TestServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, ::pilota::derivative::Derivative)] + #[derivative(Default)] + #[derive(Clone, PartialEq)] + pub enum TestServiceTestResultSend { + #[derivative(Default)] + Ok(::std::sync::Arc), + } + + impl ::pilota::thrift::Message for TestServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + })?; + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::std::sync::Arc::new( + ::pilota::thrift::Message::decode(__protocol)?, + ); + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::std::sync::Arc::new( + ::decode_async( + __protocol, + ) + .await?, + ); + + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message" + )); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + }) + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct Test { + pub id: ::pilota::FastStr, + + pub name2: ::std::vec::Vec<::std::vec::Vec<::std::sync::Arc>>, + + pub name3: ::pilota::AHashMap>>, + } + impl ::pilota::thrift::Message for Test { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_list_field( + 2, + ::pilota::thrift::TType::List, + &&self.name2, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_map_field( + 3, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::List, + &&self.name3, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Binary => + { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::sync::Arc>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::sync::Arc> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::std::sync::Arc::new( + ::pilota::thrift::Message::decode( + __protocol, + )?, + ), + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_3 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::sync::Arc> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::std::sync::Arc::new( + ::pilota::thrift::Message::decode( + __protocol, + )?, + ), + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name2 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name3 is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + name2: var_2, + name3: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::std::sync::Arc::new(::decode_async(__protocol).await?)); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_3 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::std::sync::Arc::new(::decode_async(__protocol).await?)); + }; + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Test` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + ), + ); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name2 is required".to_string(), + ), + ); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name3 is required".to_string(), + ), + ); + }; + + let data = Self { + id: var_1, + name2: var_2, + name3: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.list_field_len( + Some(2), + ::pilota::thrift::TType::List, + &self.name2, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::Struct, + el, + |__protocol, el| __protocol.struct_len(el), + ) + }, + ) + + __protocol.map_field_len( + Some(3), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::List, + &self.name3, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.list_len( + ::pilota::thrift::TType::Struct, + val, + |__protocol, el| __protocol.struct_len(el), + ) + }, + ) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + #[derive(Debug, Default, Clone, PartialEq)] + pub struct TestServiceTestArgsSend { + pub req: ::std::sync::Arc, + } + impl ::pilota::thrift::Message for TestServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::sync::Arc::new( + ::pilota::thrift::Message::decode(__protocol)?, + )); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) + if field_ident.field_type + == ::pilota::thrift::TType::Struct => + { + var_1 = Some(::std::sync::Arc::new( + ::decode_async( + __protocol, + ) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + ), + ); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } + } + } + pub use wrapper_arc::*; +} diff --git a/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/lib.rs b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace/wrapper_arc/wrapper_arc/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache.thrift b/pilota-build/test_data/thrift_workspace_with_split/apache.thrift new file mode 100644 index 00000000..8de93e4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache.thrift @@ -0,0 +1,426 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + * Contains some contributions under the Thrift Software License. + * Please see doc/old-thrift-license.txt in the Thrift distribution for + * details. + */ + +namespace c_glib TTest +namespace cpp thrift.test +namespace delphi Thrift.Test +namespace go thrifttest +namespace java thrift.test +namespace js ThriftTest +namespace lua ThriftTest +namespace netstd ThriftTest +namespace perl ThriftTest +namespace php ThriftTest +namespace py ThriftTest +namespace py.twisted ThriftTest +namespace rb Thrift.Test +namespace st ThriftTest +namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest') + +// Presence of namespaces and sub-namespaces for which there is +// no generator should compile with warnings only +// namespace noexist ThriftTest +// namespace cpp.noexist ThriftTest + +namespace * thrift.test + +/** + * Docstring! + */ +enum Numberz +{ + ONE = 1, + TWO, + THREE, + FIVE = 5, + SIX, + EIGHT = 8 +} + +const Numberz myNumberz = Numberz.ONE; +// the following is expected to fail: +// const Numberz urNumberz = ONE; + +typedef i64 UserId + +struct Bonk +{ + 1: string message, + 2: i32 type +} + +typedef map MapType + +struct Bools { + 1: bool im_true, + 2: bool im_false, +} + +struct Xtruct +{ + 1: string string_thing, + 4: i8 byte_thing, + 9: i32 i32_thing, + 11: i64 i64_thing +} + +struct Xtruct2 +{ + 1: i8 byte_thing, // used to be byte, hence the name + 2: Xtruct struct_thing, + 3: i32 i32_thing +} + +struct Xtruct3 +{ + 1: string string_thing, + 4: i32 changed, + 9: i32 i32_thing, + 11: i64 i64_thing +} + + +struct Insanity +{ + 1: map userMap, + 2: list xtructs +} (python.immutable= "") + +struct CrazyNesting { + 1: string string_field, + 2: optional set set_field, + // Do not insert line break as test/go/Makefile.am is removing this line with pattern match + 3: required list (python.immutable = ""), map(python.immutable = "")> (python.immutable = "")>>>> list_field, + 4: binary binary_field + 5: uuid uuid_field +} + +union SomeUnion { + 1: map map_thing, + 2: string string_thing, + 3: i32 i32_thing, + 4: Xtruct3 xtruct_thing, + 5: Insanity insanity_thing +} + +exception Xception { + 1: i32 errorCode, + 2: string message +} + +exception Xception2 { + 1: i32 errorCode, + 2: Xtruct struct_thing +} + +struct EmptyStruct {} + +struct OneField { + 1: EmptyStruct field +} + +service ThriftTest +{ + /** + * Prints "testVoid()" and returns nothing. + */ + void testVoid(), + + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string testString(1: string thing), + + /** + * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false' + * @param bool thing - the bool data to print + * @return bool - returns the bool 'thing' + */ + bool testBool(1: bool thing), + + /** + * Prints 'testByte("%d")' with thing as '%d' + * The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility. + * @param byte thing - the i8/byte to print + * @return i8 - returns the i8/byte 'thing' + */ + i8 testByte(1: i8 thing), + + /** + * Prints 'testI32("%d")' with thing as '%d' + * @param i32 thing - the i32 to print + * @return i32 - returns the i32 'thing' + */ + i32 testI32(1: i32 thing), + + /** + * Prints 'testI64("%d")' with thing as '%d' + * @param i64 thing - the i64 to print + * @return i64 - returns the i64 'thing' + */ + i64 testI64(1: i64 thing), + + /** + * Prints 'testDouble("%f")' with thing as '%f' + * @param double thing - the double to print + * @return double - returns the double 'thing' + */ + double testDouble(1: double thing), + + /** + * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data + * @param binary thing - the binary data to print + * @return binary - returns the binary 'thing' + */ + binary testBinary(1: binary thing), + + /** + * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct. + * @param uuid thing - the uuid to print + * @return uuid - returns the uuid 'thing' + */ + uuid testUuid(1: uuid thing), + + /** + * Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values + * @param Xtruct thing - the Xtruct to print + * @return Xtruct - returns the Xtruct 'thing' + */ + Xtruct testStruct(1: Xtruct thing), + + /** + * Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct + * @param Xtruct2 thing - the Xtruct2 to print + * @return Xtruct2 - returns the Xtruct2 'thing' + */ + Xtruct2 testNest(1: Xtruct2 thing), + + /** + * Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testMap(1: map thing), + + /** + * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs + * separated by commas and new lines + * @param map thing - the map to print + * @return map - returns the map 'thing' + */ + map testStringMap(1: map thing), + + /** + * Prints 'testSet("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param set thing - the set to print + * @return set - returns the set 'thing' + */ + set testSet(1: set thing), + + /** + * Prints 'testList("{%s}")' where thing has been formatted into a string of values + * separated by commas and new lines + * @param list thing - the list to print + * @return list - returns the list 'thing' + */ + list testList(1: list thing), + + /** + * Prints 'testEnum("%d")' where thing has been formatted into its numeric value + * @param Numberz thing - the Numberz to print + * @return Numberz - returns the Numberz 'thing' + */ + Numberz testEnum(1: Numberz thing), + + /** + * Prints 'testTypedef("%d")' with thing as '%d' + * @param UserId thing - the UserId to print + * @return UserId - returns the UserId 'thing' + */ + UserId testTypedef(1: UserId thing), + + /** + * Prints 'testMapMap("%d")' with hello as '%d' + * @param i32 hello - the i32 to print + * @return map> - returns a dictionary with these values: + * {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } + */ + map> testMapMap(1: i32 hello), + + /** + * So you think you've got this all worked out, eh? + * + * Creates a map with these values and prints it out: + * { 1 => { 2 => argument, + * 3 => argument, + * }, + * 2 => { 6 => , }, + * } + * @return map> - a map with the above values + */ + map> testInsanity(1: Insanity argument), + + /** + * Prints 'testMulti()' + * @param i8 arg0 - + * @param i32 arg1 - + * @param i64 arg2 - + * @param map arg3 - + * @param Numberz arg4 - + * @param UserId arg5 - + * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 + * and i64_thing = arg2 + */ + Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map arg3, 5: Numberz arg4, 6: UserId arg5), + + /** + * Print 'testException(%s)' with arg as '%s' + * @param string arg - a string indication what type of exception to throw + * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg + * else if arg == "TException" throw TException + * else do not throw anything + */ + void testException(1: string arg) throws(1: Xception err1), + + /** + * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' + * @param string arg - a string indicating what type of exception to throw + * if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" + * else if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2" + * else do not throw anything + * @return Xtruct - an Xtruct with string_thing = arg1 + */ + Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2) + + /** + * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' + * sleep 'secondsToSleep' + * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' + * @param i32 secondsToSleep - the number of seconds to sleep + */ + oneway void testOneway(1:i32 secondsToSleep) +} + +service SecondService +{ + /** + * Prints 'testString("%s")' with thing as '%s' + * @param string thing - the string to print + * @return string - returns the string 'thing' + */ + string secondtestString(1: string thing) +} + +struct VersioningTestV1 { + 1: i32 begin_in_both, + 3: string old_string, + 12: i32 end_in_both +} + +struct VersioningTestV2 { + 1: i32 begin_in_both, + + 2: i32 newint, + 3: i8 newbyte, + 4: i16 newshort, + 5: i64 newlong, + 6: double newdouble + 7: Bonk newstruct, + 8: list newlist, + 9: set newset, + 10: map newmap, + 11: string newstring, + 12: i32 end_in_both +} + +struct ListTypeVersioningV1 { + 1: list myints; + 2: string hello; +} + +struct ListTypeVersioningV2 { + 1: list strings; + 2: string hello; +} + +struct GuessProtocolStruct { + 7: map map_field, +} + +struct LargeDeltas { + 1: Bools b1, + 10: Bools b10, + 100: Bools b100, + 500: bool check_true, + 1000: Bools b1000, + 1500: bool check_false, + 2000: VersioningTestV2 vertwo2000, + 2500: set a_set2500, + 3000: VersioningTestV2 vertwo3000, + 4000: list big_numbers +} + +struct NestedListsI32x2 { + 1: list> integerlist +} +struct NestedListsI32x3 { + 1: list>> integerlist +} +struct NestedMixedx2 { + 1: list> int_set_list + 2: map> map_int_strset + 3: list>> map_int_strset_list +} +struct ListBonks { + 1: list bonk +} +struct NestedListsBonk { + 1: list>> bonk +} + +struct BoolTest { + 1: optional bool b = true; + 2: optional string s = "true"; +} + +struct StructA { + 1: required string s; +} + +struct StructB { + 1: optional StructA aa; + 2: required StructA ab; +} + +struct OptionalSetDefaultTest { + 1: optional set with_default = [ "test" ] +} + +struct OptionalBinary { +//1: optional set bin_set = [] + 2: optional map bin_map = {} +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/apache/Cargo.toml new file mode 100644 index 00000000..712a9f57 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["apache"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/Cargo.toml new file mode 100644 index 00000000..f9e139ef --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/Cargo.toml @@ -0,0 +1,19 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.common] +path = "../common" + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "apache" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/const_myNumberz.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/const_myNumberz.rs new file mode 100644 index 00000000..fc5ac867 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/const_myNumberz.rs @@ -0,0 +1 @@ +pub const MY_NUMBERZ: ::common::apache::Numberz = ::common::apache::Numberz::ONE; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_Numberz.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_Numberz.rs new file mode 100644 index 00000000..8cfc3a39 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_Numberz.rs @@ -0,0 +1 @@ +pub use ::common::apache::Numberz; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultRecv.rs new file mode 100644 index 00000000..3baf853a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum SecondServiceSecondtestStringResultRecv { + #[derivative(Default)] + Ok(::pilota::FastStr), +} + +impl ::pilota::thrift::Message for SecondServiceSecondtestStringResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultRecv", + })?; + match self { + SecondServiceSecondtestStringResultRecv::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(SecondServiceSecondtestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SecondServiceSecondtestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultRecv", + }) + match self { + SecondServiceSecondtestStringResultRecv::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultSend.rs new file mode 100644 index 00000000..65569df4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SecondServiceSecondtestStringResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum SecondServiceSecondtestStringResultSend { + #[derivative(Default)] + Ok(::pilota::FastStr), +} + +impl ::pilota::thrift::Message for SecondServiceSecondtestStringResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultSend", + })?; + match self { + SecondServiceSecondtestStringResultSend::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(SecondServiceSecondtestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SecondServiceSecondtestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringResultSend", + }) + match self { + SecondServiceSecondtestStringResultSend::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SomeUnion.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SomeUnion.rs new file mode 100644 index 00000000..3d986aed --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_SomeUnion.rs @@ -0,0 +1,322 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum SomeUnion { + #[derivative(Default)] + MapThing(::pilota::AHashMap<::common::apache::Numberz, ::common::apache::UserId>), + + StringThing(::pilota::FastStr), + + I32Thing(i32), + + XtructThing(Xtruct3), + + InsanityThing(Insanity), +} + +impl ::pilota::thrift::Message for SomeUnion { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol + .write_struct_begin(&::pilota::thrift::TStructIdentifier { name: "SomeUnion" })?; + match self { + SomeUnion::MapThing(ref value) => { + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + SomeUnion::StringThing(ref value) => { + __protocol.write_faststr_field(2, (value).clone())?; + } + SomeUnion::I32Thing(ref value) => { + __protocol.write_i32_field(3, *value)?; + } + SomeUnion::XtructThing(ref value) => { + __protocol.write_struct_field(4, value, ::pilota::thrift::TType::Struct)?; + } + SomeUnion::InsanityThing(ref value) => { + __protocol.write_struct_field(5, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ); + ret = Some(SomeUnion::MapThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(SomeUnion::StringThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(3) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(SomeUnion::I32Thing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(4) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(SomeUnion::XtructThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(5) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(SomeUnion::InsanityThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(SomeUnion::MapThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(SomeUnion::StringThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(3) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(SomeUnion::I32Thing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(4) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(SomeUnion::XtructThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(5) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(SomeUnion::InsanityThing(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "SomeUnion" }) + + match self { + SomeUnion::MapThing(ref value) => __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ), + SomeUnion::StringThing(ref value) => __protocol.faststr_field_len(Some(2), value), + SomeUnion::I32Thing(ref value) => __protocol.i32_field_len(Some(3), *value), + SomeUnion::XtructThing(ref value) => __protocol.struct_field_len(Some(4), value), + SomeUnion::InsanityThing(ref value) => __protocol.struct_field_len(Some(5), value), + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultRecv.rs new file mode 100644 index 00000000..176d0709 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestBinaryResultRecv { + #[derivative(Default)] + Ok(::pilota::Bytes), +} + +impl ::pilota::thrift::Message for ThriftTestTestBinaryResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultRecv", + })?; + match self { + ThriftTestTestBinaryResultRecv::Ok(ref value) => { + __protocol.write_bytes_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(ThriftTestTestBinaryResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(ThriftTestTestBinaryResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultRecv", + }) + match self { + ThriftTestTestBinaryResultRecv::Ok(ref value) => { + __protocol.bytes_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultSend.rs new file mode 100644 index 00000000..8f2779b2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBinaryResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestBinaryResultSend { + #[derivative(Default)] + Ok(::pilota::Bytes), +} + +impl ::pilota::thrift::Message for ThriftTestTestBinaryResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultSend", + })?; + match self { + ThriftTestTestBinaryResultSend::Ok(ref value) => { + __protocol.write_bytes_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(ThriftTestTestBinaryResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(ThriftTestTestBinaryResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryResultSend", + }) + match self { + ThriftTestTestBinaryResultSend::Ok(ref value) => { + __protocol.bytes_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultRecv.rs new file mode 100644 index 00000000..e9813164 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestBoolResultRecv { + #[derivative(Default)] + Ok(bool), +} + +impl ::pilota::thrift::Message for ThriftTestTestBoolResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultRecv", + })?; + match self { + ThriftTestTestBoolResultRecv::Ok(ref value) => { + __protocol.write_bool_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool()?; + __protocol.bool_len(*&field_ident); + ret = Some(ThriftTestTestBoolResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool().await?; + + ret = Some(ThriftTestTestBoolResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultRecv", + }) + match self { + ThriftTestTestBoolResultRecv::Ok(ref value) => { + __protocol.bool_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultSend.rs new file mode 100644 index 00000000..a2d29c79 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestBoolResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestBoolResultSend { + #[derivative(Default)] + Ok(bool), +} + +impl ::pilota::thrift::Message for ThriftTestTestBoolResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultSend", + })?; + match self { + ThriftTestTestBoolResultSend::Ok(ref value) => { + __protocol.write_bool_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool()?; + __protocol.bool_len(*&field_ident); + ret = Some(ThriftTestTestBoolResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_bool().await?; + + ret = Some(ThriftTestTestBoolResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolResultSend", + }) + match self { + ThriftTestTestBoolResultSend::Ok(ref value) => { + __protocol.bool_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultRecv.rs new file mode 100644 index 00000000..e5a59300 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultRecv.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestByteResultRecv { + #[derivative(Default)] + Ok(i8), +} + +impl ::pilota::thrift::Message for ThriftTestTestByteResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultRecv", + })?; + match self { + ThriftTestTestByteResultRecv::Ok(ref value) => { + __protocol.write_i8_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8()?; + __protocol.i8_len(*&field_ident); + ret = Some(ThriftTestTestByteResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8().await?; + + ret = Some(ThriftTestTestByteResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultRecv", + }) + match self { + ThriftTestTestByteResultRecv::Ok(ref value) => __protocol.i8_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultSend.rs new file mode 100644 index 00000000..4d493536 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestByteResultSend.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestByteResultSend { + #[derivative(Default)] + Ok(i8), +} + +impl ::pilota::thrift::Message for ThriftTestTestByteResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultSend", + })?; + match self { + ThriftTestTestByteResultSend::Ok(ref value) => { + __protocol.write_i8_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8()?; + __protocol.i8_len(*&field_ident); + ret = Some(ThriftTestTestByteResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i8().await?; + + ret = Some(ThriftTestTestByteResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteResultSend", + }) + match self { + ThriftTestTestByteResultSend::Ok(ref value) => __protocol.i8_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultRecv.rs new file mode 100644 index 00000000..852fea6e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestDoubleResultRecv { + #[derivative(Default)] + Ok(f64), +} + +impl ::pilota::thrift::Message for ThriftTestTestDoubleResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultRecv", + })?; + match self { + ThriftTestTestDoubleResultRecv::Ok(ref value) => { + __protocol.write_double_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double()?; + __protocol.double_len(*&field_ident); + ret = Some(ThriftTestTestDoubleResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double().await?; + + ret = Some(ThriftTestTestDoubleResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultRecv", + }) + match self { + ThriftTestTestDoubleResultRecv::Ok(ref value) => { + __protocol.double_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultSend.rs new file mode 100644 index 00000000..ddb4abbf --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestDoubleResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestDoubleResultSend { + #[derivative(Default)] + Ok(f64), +} + +impl ::pilota::thrift::Message for ThriftTestTestDoubleResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultSend", + })?; + match self { + ThriftTestTestDoubleResultSend::Ok(ref value) => { + __protocol.write_double_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double()?; + __protocol.double_len(*&field_ident); + ret = Some(ThriftTestTestDoubleResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_double().await?; + + ret = Some(ThriftTestTestDoubleResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleResultSend", + }) + match self { + ThriftTestTestDoubleResultSend::Ok(ref value) => { + __protocol.double_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultRecv.rs new file mode 100644 index 00000000..1fb9fab8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestEnumResultRecv { + #[derivative(Default)] + Ok(::common::apache::Numberz), +} + +impl ::pilota::thrift::Message for ThriftTestTestEnumResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultRecv", + })?; + match self { + ThriftTestTestEnumResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultRecv", + }) + match self { + ThriftTestTestEnumResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultSend.rs new file mode 100644 index 00000000..217256ff --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestEnumResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestEnumResultSend { + #[derivative(Default)] + Ok(::common::apache::Numberz), +} + +impl ::pilota::thrift::Message for ThriftTestTestEnumResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultSend", + })?; + match self { + ThriftTestTestEnumResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumResultSend", + }) + match self { + ThriftTestTestEnumResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionException.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionException.rs new file mode 100644 index 00000000..e8175b80 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionException.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestExceptionException { + #[derivative(Default)] + Err1(Xception), +} + +impl ::pilota::thrift::Message for ThriftTestTestExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionException", + })?; + match self { + ThriftTestTestExceptionException::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionException", + }) + match self { + ThriftTestTestExceptionException::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultRecv.rs new file mode 100644 index 00000000..63b3f30d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestExceptionResultRecv { + #[derivative(Default)] + Ok(()), + + Err1(Xception), +} + +impl ::pilota::thrift::Message for ThriftTestTestExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultRecv", + })?; + match self { + ThriftTestTestExceptionResultRecv::Ok(ref value) => {} + ThriftTestTestExceptionResultRecv::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultRecv", + }) + match self { + ThriftTestTestExceptionResultRecv::Ok(ref value) => 0, + ThriftTestTestExceptionResultRecv::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultSend.rs new file mode 100644 index 00000000..9e5e4ef0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestExceptionResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestExceptionResultSend { + #[derivative(Default)] + Ok(()), + + Err1(Xception), +} + +impl ::pilota::thrift::Message for ThriftTestTestExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultSend", + })?; + match self { + ThriftTestTestExceptionResultSend::Ok(ref value) => {} + ThriftTestTestExceptionResultSend::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestExceptionResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionResultSend", + }) + match self { + ThriftTestTestExceptionResultSend::Ok(ref value) => 0, + ThriftTestTestExceptionResultSend::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultRecv.rs new file mode 100644 index 00000000..a5549a95 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultRecv.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestI32ResultRecv { + #[derivative(Default)] + Ok(i32), +} + +impl ::pilota::thrift::Message for ThriftTestTestI32ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultRecv", + })?; + match self { + ThriftTestTestI32ResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(ThriftTestTestI32ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(ThriftTestTestI32ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultRecv", + }) + match self { + ThriftTestTestI32ResultRecv::Ok(ref value) => __protocol.i32_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultSend.rs new file mode 100644 index 00000000..fff0f352 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI32ResultSend.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestI32ResultSend { + #[derivative(Default)] + Ok(i32), +} + +impl ::pilota::thrift::Message for ThriftTestTestI32ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultSend", + })?; + match self { + ThriftTestTestI32ResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32()?; + __protocol.i32_len(*&field_ident); + ret = Some(ThriftTestTestI32ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i32().await?; + + ret = Some(ThriftTestTestI32ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ResultSend", + }) + match self { + ThriftTestTestI32ResultSend::Ok(ref value) => __protocol.i32_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultRecv.rs new file mode 100644 index 00000000..005e4dfa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultRecv.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestI64ResultRecv { + #[derivative(Default)] + Ok(i64), +} + +impl ::pilota::thrift::Message for ThriftTestTestI64ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultRecv", + })?; + match self { + ThriftTestTestI64ResultRecv::Ok(ref value) => { + __protocol.write_i64_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64()?; + __protocol.i64_len(*&field_ident); + ret = Some(ThriftTestTestI64ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64().await?; + + ret = Some(ThriftTestTestI64ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultRecv", + }) + match self { + ThriftTestTestI64ResultRecv::Ok(ref value) => __protocol.i64_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultSend.rs new file mode 100644 index 00000000..8dd39271 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestI64ResultSend.rs @@ -0,0 +1,138 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestI64ResultSend { + #[derivative(Default)] + Ok(i64), +} + +impl ::pilota::thrift::Message for ThriftTestTestI64ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultSend", + })?; + match self { + ThriftTestTestI64ResultSend::Ok(ref value) => { + __protocol.write_i64_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64()?; + __protocol.i64_len(*&field_ident); + ret = Some(ThriftTestTestI64ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_i64().await?; + + ret = Some(ThriftTestTestI64ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ResultSend", + }) + match self { + ThriftTestTestI64ResultSend::Ok(ref value) => __protocol.i64_field_len(Some(0), *value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultRecv.rs new file mode 100644 index 00000000..9f23d76f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultRecv.rs @@ -0,0 +1,232 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestInsanityResultRecv { + #[derivative(Default)] + Ok( + ::pilota::AHashMap< + ::common::apache::UserId, + ::pilota::AHashMap<::common::apache::Numberz, Insanity>, + >, + ), +} + +impl ::pilota::thrift::Message for ThriftTestTestInsanityResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultRecv", + })?; + match self { + ThriftTestTestInsanityResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ); + ret = Some(ThriftTestTestInsanityResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, ::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestInsanityResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultRecv", + }) + match self { + ThriftTestTestInsanityResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultSend.rs new file mode 100644 index 00000000..1d4ce75c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestInsanityResultSend.rs @@ -0,0 +1,232 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestInsanityResultSend { + #[derivative(Default)] + Ok( + ::pilota::AHashMap< + ::common::apache::UserId, + ::pilota::AHashMap<::common::apache::Numberz, Insanity>, + >, + ), +} + +impl ::pilota::thrift::Message for ThriftTestTestInsanityResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultSend", + })?; + match self { + ThriftTestTestInsanityResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ); + ret = Some(ThriftTestTestInsanityResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, ::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestInsanityResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityResultSend", + }) + match self { + ThriftTestTestInsanityResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I64, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Struct, + val, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultRecv.rs new file mode 100644 index 00000000..f78c3f44 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultRecv.rs @@ -0,0 +1,174 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestListResultRecv { + #[derivative(Default)] + Ok(::std::vec::Vec), +} + +impl ::pilota::thrift::Message for ThriftTestTestListResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultRecv", + })?; + match self { + ThriftTestTestListResultRecv::Ok(ref value) => { + __protocol.write_list_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }; + __protocol.list_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestListResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }; + + ret = Some(ThriftTestTestListResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultRecv", + }) + match self { + ThriftTestTestListResultRecv::Ok(ref value) => __protocol.list_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultSend.rs new file mode 100644 index 00000000..edbaf390 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestListResultSend.rs @@ -0,0 +1,174 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestListResultSend { + #[derivative(Default)] + Ok(::std::vec::Vec), +} + +impl ::pilota::thrift::Message for ThriftTestTestListResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultSend", + })?; + match self { + ThriftTestTestListResultSend::Ok(ref value) => { + __protocol.write_list_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }; + __protocol.list_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestListResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }; + + ret = Some(ThriftTestTestListResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListResultSend", + }) + match self { + ThriftTestTestListResultSend::Ok(ref value) => __protocol.list_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultRecv.rs new file mode 100644 index 00000000..481f3a9b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultRecv.rs @@ -0,0 +1,228 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMapMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap>), +} + +impl ::pilota::thrift::Message for ThriftTestTestMapMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultRecv", + })?; + match self { + ThriftTestTestMapMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ); + ret = Some(ThriftTestTestMapMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultRecv", + }) + match self { + ThriftTestTestMapMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultSend.rs new file mode 100644 index 00000000..8abff94f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapMapResultSend.rs @@ -0,0 +1,228 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMapMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap>), +} + +impl ::pilota::thrift::Message for ThriftTestTestMapMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultSend", + })?; + match self { + ThriftTestTestMapMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ); + ret = Some(ThriftTestTestMapMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapResultSend", + }) + match self { + ThriftTestTestMapMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Map, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }, + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultRecv.rs new file mode 100644 index 00000000..94f3bd97 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultRecv.rs @@ -0,0 +1,183 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap), +} + +impl ::pilota::thrift::Message for ThriftTestTestMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultRecv", + })?; + match self { + ThriftTestTestMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ); + ret = Some(ThriftTestTestMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultRecv", + }) + match self { + ThriftTestTestMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultSend.rs new file mode 100644 index 00000000..4b004be0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMapResultSend.rs @@ -0,0 +1,183 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap), +} + +impl ::pilota::thrift::Message for ThriftTestTestMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultSend", + })?; + match self { + ThriftTestTestMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ); + ret = Some(ThriftTestTestMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapResultSend", + }) + match self { + ThriftTestTestMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionException.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionException.rs new file mode 100644 index 00000000..eec18084 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionException.rs @@ -0,0 +1,180 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMultiExceptionException { + #[derivative(Default)] + Err1(Xception), + + Err2(Xception2), +} + +impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionException", + })?; + match self { + ThriftTestTestMultiExceptionException::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionException::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionException::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionException::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionException::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionException", + }) + match self { + ThriftTestTestMultiExceptionException::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionException::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultRecv.rs new file mode 100644 index 00000000..952b784c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultRecv.rs @@ -0,0 +1,216 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMultiExceptionResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + + Err1(Xception), + + Err2(Xception2), +} + +impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultRecv", + })?; + match self { + ThriftTestTestMultiExceptionResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultRecv::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultRecv::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultRecv::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultRecv", + }) + match self { + ThriftTestTestMultiExceptionResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ThriftTestTestMultiExceptionResultRecv::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionResultRecv::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultSend.rs new file mode 100644 index 00000000..08ba658a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiExceptionResultSend.rs @@ -0,0 +1,216 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMultiExceptionResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), + + Err1(Xception), + + Err2(Xception2), +} + +impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultSend", + })?; + match self { + ThriftTestTestMultiExceptionResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultSend::Err1(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + ThriftTestTestMultiExceptionResultSend::Err2(ref value) => { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiExceptionResultSend::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Err1(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestMultiExceptionResultSend::Err2(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionResultSend", + }) + match self { + ThriftTestTestMultiExceptionResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + ThriftTestTestMultiExceptionResultSend::Err1(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + ThriftTestTestMultiExceptionResultSend::Err2(ref value) => { + __protocol.struct_field_len(Some(2), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultRecv.rs new file mode 100644 index 00000000..75fd8da4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMultiResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), +} + +impl ::pilota::thrift::Message for ThriftTestTestMultiResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultRecv", + })?; + match self { + ThriftTestTestMultiResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultRecv", + }) + match self { + ThriftTestTestMultiResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultSend.rs new file mode 100644 index 00000000..71078aaf --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestMultiResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestMultiResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), +} + +impl ::pilota::thrift::Message for ThriftTestTestMultiResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultSend", + })?; + match self { + ThriftTestTestMultiResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestMultiResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestMultiResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiResultSend", + }) + match self { + ThriftTestTestMultiResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultRecv.rs new file mode 100644 index 00000000..08ea10ad --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultRecv.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestNestResultRecv { + #[derivative(Default)] + Ok(Xtruct2), +} + +impl ::pilota::thrift::Message for ThriftTestTestNestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultRecv", + })?; + match self { + ThriftTestTestNestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestNestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestNestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultRecv", + }) + match self { + ThriftTestTestNestResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultSend.rs new file mode 100644 index 00000000..578cbf0a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestNestResultSend.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestNestResultSend { + #[derivative(Default)] + Ok(Xtruct2), +} + +impl ::pilota::thrift::Message for ThriftTestTestNestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultSend", + })?; + match self { + ThriftTestTestNestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestNestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ThriftTestTestNestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestResultSend", + }) + match self { + ThriftTestTestNestResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultRecv.rs new file mode 100644 index 00000000..2a918e27 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultRecv.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestOnewayResultRecv { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for ThriftTestTestOnewayResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultRecv", + })?; + match self { + ThriftTestTestOnewayResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultRecv", + }) + match self { + ThriftTestTestOnewayResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultSend.rs new file mode 100644 index 00000000..446bdc22 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestOnewayResultSend.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestOnewayResultSend { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for ThriftTestTestOnewayResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultSend", + })?; + match self { + ThriftTestTestOnewayResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestOnewayResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayResultSend", + }) + match self { + ThriftTestTestOnewayResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultRecv.rs new file mode 100644 index 00000000..ff4a48c7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultRecv.rs @@ -0,0 +1,171 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestSetResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashSet), +} + +impl ::pilota::thrift::Message for ThriftTestTestSetResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultRecv", + })?; + match self { + ThriftTestTestSetResultRecv::Ok(ref value) => { + __protocol.write_set_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }; + __protocol.set_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestSetResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }; + + ret = Some(ThriftTestTestSetResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultRecv", + }) + match self { + ThriftTestTestSetResultRecv::Ok(ref value) => __protocol.set_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultSend.rs new file mode 100644 index 00000000..10bd27a9 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestSetResultSend.rs @@ -0,0 +1,171 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestSetResultSend { + #[derivative(Default)] + Ok(::pilota::AHashSet), +} + +impl ::pilota::thrift::Message for ThriftTestTestSetResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultSend", + })?; + match self { + ThriftTestTestSetResultSend::Ok(ref value) => { + __protocol.write_set_field( + 0, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }; + __protocol.set_len( + ::pilota::thrift::TType::I32, + &field_ident, + |__protocol, el| __protocol.i32_len(*el), + ); + ret = Some(ThriftTestTestSetResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }; + + ret = Some(ThriftTestTestSetResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetResultSend", + }) + match self { + ThriftTestTestSetResultSend::Ok(ref value) => __protocol.set_field_len( + Some(0), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultRecv.rs new file mode 100644 index 00000000..a662ff5b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultRecv.rs @@ -0,0 +1,183 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStringMapResultRecv { + #[derivative(Default)] + Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), +} + +impl ::pilota::thrift::Message for ThriftTestTestStringMapResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultRecv", + })?; + match self { + ThriftTestTestStringMapResultRecv::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &field_ident, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ); + ret = Some(ThriftTestTestStringMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestStringMapResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultRecv", + }) + match self { + ThriftTestTestStringMapResultRecv::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultSend.rs new file mode 100644 index 00000000..06dc7e2e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringMapResultSend.rs @@ -0,0 +1,183 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStringMapResultSend { + #[derivative(Default)] + Ok(::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>), +} + +impl ::pilota::thrift::Message for ThriftTestTestStringMapResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultSend", + })?; + match self { + ThriftTestTestStringMapResultSend::Ok(ref value) => { + __protocol.write_map_field( + 0, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &field_ident, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ); + ret = Some(ThriftTestTestStringMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }; + + ret = Some(ThriftTestTestStringMapResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapResultSend", + }) + match self { + ThriftTestTestStringMapResultSend::Ok(ref value) => __protocol.map_field_len( + Some(0), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultRecv.rs new file mode 100644 index 00000000..52f11c6e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStringResultRecv { + #[derivative(Default)] + Ok(::pilota::FastStr), +} + +impl ::pilota::thrift::Message for ThriftTestTestStringResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultRecv", + })?; + match self { + ThriftTestTestStringResultRecv::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(ThriftTestTestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(ThriftTestTestStringResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultRecv", + }) + match self { + ThriftTestTestStringResultRecv::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultSend.rs new file mode 100644 index 00000000..5b90e359 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStringResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStringResultSend { + #[derivative(Default)] + Ok(::pilota::FastStr), +} + +impl ::pilota::thrift::Message for ThriftTestTestStringResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultSend", + })?; + match self { + ThriftTestTestStringResultSend::Ok(ref value) => { + __protocol.write_faststr_field(0, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(ThriftTestTestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(ThriftTestTestStringResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringResultSend", + }) + match self { + ThriftTestTestStringResultSend::Ok(ref value) => { + __protocol.faststr_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultRecv.rs new file mode 100644 index 00000000..98c30f8a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStructResultRecv { + #[derivative(Default)] + Ok(::common::apache::Xtruct), +} + +impl ::pilota::thrift::Message for ThriftTestTestStructResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultRecv", + })?; + match self { + ThriftTestTestStructResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestStructResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestStructResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultRecv", + }) + match self { + ThriftTestTestStructResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultSend.rs new file mode 100644 index 00000000..e9d966cc --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestStructResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestStructResultSend { + #[derivative(Default)] + Ok(::common::apache::Xtruct), +} + +impl ::pilota::thrift::Message for ThriftTestTestStructResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultSend", + })?; + match self { + ThriftTestTestStructResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestStructResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestStructResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructResultSend", + }) + match self { + ThriftTestTestStructResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultRecv.rs new file mode 100644 index 00000000..e695a096 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestTypedefResultRecv { + #[derivative(Default)] + Ok(::common::apache::UserId), +} + +impl ::pilota::thrift::Message for ThriftTestTestTypedefResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultRecv", + })?; + match self { + ThriftTestTestTypedefResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::I64)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestTypedefResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestTypedefResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultRecv", + }) + match self { + ThriftTestTestTypedefResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultSend.rs new file mode 100644 index 00000000..9eb65749 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestTypedefResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestTypedefResultSend { + #[derivative(Default)] + Ok(::common::apache::UserId), +} + +impl ::pilota::thrift::Message for ThriftTestTestTypedefResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultSend", + })?; + match self { + ThriftTestTestTypedefResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::I64)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ThriftTestTestTypedefResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?; + + ret = Some(ThriftTestTestTypedefResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefResultSend", + }) + match self { + ThriftTestTestTypedefResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultRecv.rs new file mode 100644 index 00000000..da25a8d0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestUuidResultRecv { + #[derivative(Default)] + Ok([u8; 16]), +} + +impl ::pilota::thrift::Message for ThriftTestTestUuidResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultRecv", + })?; + match self { + ThriftTestTestUuidResultRecv::Ok(ref value) => { + __protocol.write_uuid_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid()?; + __protocol.uuid_len(*&field_ident); + ret = Some(ThriftTestTestUuidResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid().await?; + + ret = Some(ThriftTestTestUuidResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultRecv", + }) + match self { + ThriftTestTestUuidResultRecv::Ok(ref value) => { + __protocol.uuid_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultSend.rs new file mode 100644 index 00000000..7e4afeee --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestUuidResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestUuidResultSend { + #[derivative(Default)] + Ok([u8; 16]), +} + +impl ::pilota::thrift::Message for ThriftTestTestUuidResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultSend", + })?; + match self { + ThriftTestTestUuidResultSend::Ok(ref value) => { + __protocol.write_uuid_field(0, *value)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid()?; + __protocol.uuid_len(*&field_ident); + ret = Some(ThriftTestTestUuidResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = __protocol.read_uuid().await?; + + ret = Some(ThriftTestTestUuidResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidResultSend", + }) + match self { + ThriftTestTestUuidResultSend::Ok(ref value) => { + __protocol.uuid_field_len(Some(0), *value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultRecv.rs new file mode 100644 index 00000000..82035d26 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultRecv.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestVoidResultRecv { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for ThriftTestTestVoidResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultRecv", + })?; + match self { + ThriftTestTestVoidResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultRecv", + }) + match self { + ThriftTestTestVoidResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultSend.rs new file mode 100644 index 00000000..bec1f9ee --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/enum_ThriftTestTestVoidResultSend.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ThriftTestTestVoidResultSend { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for ThriftTestTestVoidResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultSend", + })?; + match self { + ThriftTestTestVoidResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(ThriftTestTestVoidResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidResultSend", + }) + match self { + ThriftTestTestVoidResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/gen.rs new file mode 100644 index 00000000..0e8a8c33 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/gen.rs @@ -0,0 +1,139 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod apache { + include!("src/message_LargeDeltas.rs"); + include!("src/message_ThriftTestTestEnumArgsRecv.rs"); + include!("src/message_ThriftTestTestI32ArgsSend.rs"); + include!("src/enum_SecondServiceSecondtestStringResultRecv.rs"); + include!("src/message_ThriftTestTestSetArgsRecv.rs"); + include!("src/message_ThriftTestTestBoolArgsSend.rs"); + include!("src/enum_ThriftTestTestMultiExceptionException.rs"); + include!("src/message_ThriftTestTestMapArgsRecv.rs"); + include!("src/message_ThriftTestTestVoidArgsSend.rs"); + include!("src/enum_ThriftTestTestExceptionException.rs"); + include!("src/message_ThriftTestTestStructArgsRecv.rs"); + include!("src/enum_ThriftTestTestMultiResultRecv.rs"); + include!("src/message_ThriftTestTestBinaryArgsRecv.rs"); + include!("src/const_myNumberz.rs"); + include!("src/message_StructA.rs"); + include!("src/enum_ThriftTestTestMapMapResultRecv.rs"); + include!("src/message_ThriftTestTestI64ArgsRecv.rs"); + include!("src/message_VersioningTestV1.rs"); + include!("src/enum_ThriftTestTestEnumResultRecv.rs"); + include!("src/message_ThriftTestTestByteArgsRecv.rs"); + include!("src/enum_ThriftTestTestOnewayResultSend.rs"); + include!("src/enum_ThriftTestTestSetResultRecv.rs"); + include!("src/message_ThriftTestTestStringArgsRecv.rs"); + include!("src/enum_ThriftTestTestMapResultRecv.rs"); + include!("src/message_OneField.rs"); + include!("src/enum_ThriftTestTestStructResultRecv.rs"); + include!("src/message_Xtruct3.rs"); + include!("src/enum_ThriftTestTestBinaryResultRecv.rs"); + include!("src/message_NestedListsI32x3.rs"); + include!("src/enum_ThriftTestTestI64ResultRecv.rs"); + include!("src/enum_SecondServiceSecondtestStringResultSend.rs"); + include!("src/enum_ThriftTestTestByteResultRecv.rs"); + include!("src/enum_ThriftTestTestStringResultRecv.rs"); + include!("src/message_ThriftTestTestExceptionArgsSend.rs"); + include!("src/enum_ThriftTestTestMultiResultSend.rs"); + include!("src/message_Bonk.rs"); + include!("src/message_OptionalSetDefaultTest.rs"); + include!("src/enum_ThriftTestTestMapMapResultSend.rs"); + include!("src/message_ListTypeVersioningV1.rs"); + include!("src/enum_ThriftTestTestEnumResultSend.rs"); + include!("src/message_ThriftTestTestOnewayArgsSend.rs"); + include!("src/enum_ThriftTestTestSetResultSend.rs"); + include!("src/enum_ThriftTestTestMapResultSend.rs"); + include!("src/enum_ThriftTestTestExceptionResultSend.rs"); + include!("src/enum_ThriftTestTestStructResultSend.rs"); + include!("src/message_CrazyNesting.rs"); + include!("src/enum_ThriftTestTestBinaryResultSend.rs"); + include!("src/message_ListBonks.rs"); + include!("src/enum_ThriftTestTestI64ResultSend.rs"); + include!("src/message_SecondServiceSecondtestStringArgsSend.rs"); + include!("src/enum_ThriftTestTestByteResultSend.rs"); + include!("src/message_ThriftTestTestMultiExceptionArgsRecv.rs"); + include!("src/enum_ThriftTestTestStringResultSend.rs"); + include!("src/enum_ThriftTestTestMultiExceptionResultRecv.rs"); + include!("src/message_Xception.rs"); + include!("src/message_ThriftTestTestMultiArgsSend.rs"); + include!("src/message_Bools.rs"); + include!("src/message_ThriftTestTestMapMapArgsSend.rs"); + include!("src/message_GuessProtocolStruct.rs"); + include!("src/message_ThriftTestTestEnumArgsSend.rs"); + include!("src/service_ThriftTest.rs"); + include!("src/message_ThriftTestTestSetArgsSend.rs"); + include!("src/message_ThriftTestTestMapArgsSend.rs"); + include!("src/message_ThriftTestTestStructArgsSend.rs"); + include!("src/message_ThriftTestTestInsanityArgsRecv.rs"); + include!("src/message_ThriftTestTestBinaryArgsSend.rs"); + include!("src/message_BoolTest.rs"); + include!("src/message_ThriftTestTestTypedefArgsRecv.rs"); + include!("src/message_ThriftTestTestI64ArgsSend.rs"); + include!("src/service_SecondService.rs"); + include!("src/message_ThriftTestTestListArgsRecv.rs"); + include!("src/message_ThriftTestTestByteArgsSend.rs"); + include!("src/message_ThriftTestTestStringMapArgsRecv.rs"); + include!("src/message_ThriftTestTestStringArgsSend.rs"); + include!("src/message_ThriftTestTestNestArgsRecv.rs"); + include!("src/message_EmptyStruct.rs"); + include!("src/enum_ThriftTestTestExceptionResultRecv.rs"); + include!("src/message_ThriftTestTestUuidArgsRecv.rs"); + include!("src/message_Xtruct2.rs"); + include!("src/enum_ThriftTestTestInsanityResultRecv.rs"); + include!("src/message_ThriftTestTestDoubleArgsRecv.rs"); + include!("src/message_NestedListsI32x2.rs"); + include!("src/enum_ThriftTestTestTypedefResultRecv.rs"); + include!("src/message_ThriftTestTestI32ArgsRecv.rs"); + include!("src/enum_ThriftTestTestListResultRecv.rs"); + include!("src/message_ThriftTestTestBoolArgsRecv.rs"); + include!("src/enum_ThriftTestTestStringMapResultRecv.rs"); + include!("src/message_ThriftTestTestVoidArgsRecv.rs"); + include!("src/enum_ThriftTestTestNestResultRecv.rs"); + include!("src/enum_ThriftTestTestUuidResultRecv.rs"); + include!("src/message_StructB.rs"); + include!("src/enum_ThriftTestTestDoubleResultRecv.rs"); + include!("src/message_VersioningTestV2.rs"); + include!("src/enum_ThriftTestTestI32ResultRecv.rs"); + include!("src/enum_ThriftTestTestBoolResultRecv.rs"); + include!("src/enum_ThriftTestTestMultiExceptionResultSend.rs"); + include!("src/enum_ThriftTestTestVoidResultRecv.rs"); + include!("src/message_Insanity.rs"); + include!("src/enum_ThriftTestTestInsanityResultSend.rs"); + include!("src/message_NestedMixedx2.rs"); + include!("src/enum_ThriftTestTestTypedefResultSend.rs"); + include!("src/enum_ThriftTestTestListResultSend.rs"); + include!("src/message_ThriftTestTestMultiExceptionArgsSend.rs"); + include!("src/enum_ThriftTestTestStringMapResultSend.rs"); + include!("src/message_ThriftTestTestExceptionArgsRecv.rs"); + include!("src/enum_ThriftTestTestNestResultSend.rs"); + include!("src/enum_ThriftTestTestUuidResultSend.rs"); + include!("src/new_type_MapType.rs"); + include!("src/message_OptionalBinary.rs"); + include!("src/enum_ThriftTestTestDoubleResultSend.rs"); + include!("src/message_ListTypeVersioningV2.rs"); + include!("src/enum_ThriftTestTestI32ResultSend.rs"); + include!("src/message_ThriftTestTestOnewayArgsRecv.rs"); + include!("src/enum_ThriftTestTestBoolResultSend.rs"); + include!("src/enum_ThriftTestTestVoidResultSend.rs"); + include!("src/enum_SomeUnion.rs"); + include!("src/message_ThriftTestTestInsanityArgsSend.rs"); + include!("src/message_NestedListsBonk.rs"); + include!("src/message_ThriftTestTestTypedefArgsSend.rs"); + include!("src/message_SecondServiceSecondtestStringArgsRecv.rs"); + include!("src/message_ThriftTestTestListArgsSend.rs"); + include!("src/enum_ThriftTestTestOnewayResultRecv.rs"); + include!("src/message_ThriftTestTestStringMapArgsSend.rs"); + include!("src/message_ThriftTestTestNestArgsSend.rs"); + include!("src/message_Xception2.rs"); + include!("src/message_ThriftTestTestMultiArgsRecv.rs"); + include!("src/message_ThriftTestTestUuidArgsSend.rs"); + include!("src/message_ThriftTestTestMapMapArgsRecv.rs"); + include!("src/message_ThriftTestTestDoubleArgsSend.rs"); + include!("src/enum_Numberz.rs"); + include!("src/new_type_UserId.rs"); + include!("src/message_Xtruct.rs"); + } + pub use apache::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bonk.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bonk.rs new file mode 100644 index 00000000..ed98de3b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bonk.rs @@ -0,0 +1,160 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Bonk { + pub message: ::std::option::Option<::pilota::FastStr>, + + pub r#type: ::std::option::Option, +} +impl ::pilota::thrift::Message for Bonk { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Bonk" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.r#type.as_ref() { + __protocol.write_i32_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + message: var_1, + r#type: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + message: var_1, + r#type: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Bonk" }) + + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .r#type + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_BoolTest.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_BoolTest.rs new file mode 100644 index 00000000..89cde08e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_BoolTest.rs @@ -0,0 +1,163 @@ + +impl Default for BoolTest { + fn default() -> Self { + BoolTest { + b: Some(true), + s: Some(::pilota::FastStr::from_static_str("true")), + } + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] +pub struct BoolTest { + pub b: ::std::option::Option, + + pub s: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for BoolTest { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "BoolTest" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b.as_ref() { + __protocol.write_bool_field(1, *value)?; + } + if let Some(value) = self.s.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(true); + let mut var_2 = Some(::pilota::FastStr::from_static_str("true")); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `BoolTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b: var_1, s: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(true); + let mut var_2 = Some(::pilota::FastStr::from_static_str("true")); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `BoolTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b: var_1, s: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "BoolTest" }) + + self + .b + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1), *value)) + + self + .s + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bools.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bools.rs new file mode 100644 index 00000000..94a83921 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Bools.rs @@ -0,0 +1,160 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Bools { + pub im_true: ::std::option::Option, + + pub im_false: ::std::option::Option, +} +impl ::pilota::thrift::Message for Bools { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Bools" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.im_true.as_ref() { + __protocol.write_bool_field(1, *value)?; + } + if let Some(value) = self.im_false.as_ref() { + __protocol.write_bool_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_2 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bools` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + im_true: var_1, + im_false: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_2 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Bools` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + im_true: var_1, + im_false: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Bools" }) + + self + .im_true + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1), *value)) + + self + .im_false + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_CrazyNesting.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_CrazyNesting.rs new file mode 100644 index 00000000..05f318e5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_CrazyNesting.rs @@ -0,0 +1,502 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct CrazyNesting { + pub string_field: ::std::option::Option<::pilota::FastStr>, + + pub set_field: ::std::option::Option<::pilota::AHashSet>, + + pub list_field: ::std::vec::Vec< + ::pilota::AHashMap< + ::pilota::AHashSet, + ::pilota::AHashMap< + i32, + ::pilota::AHashSet< + ::std::vec::Vec<::pilota::AHashMap>, + >, + >, + >, + >, + + pub binary_field: ::std::option::Option<::pilota::Bytes>, + + pub uuid_field: ::std::option::Option<[u8; 16]>, +} +impl ::pilota::thrift::Message for CrazyNesting { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "CrazyNesting", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_field.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.set_field.as_ref() { + __protocol.write_set_field( + 2, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Map, + &&self.list_field, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::Set, + ::pilota::thrift::TType::Map, + &val, + |__protocol, key| { + __protocol.write_set( + ::pilota::thrift::TType::I32, + &key, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Map, + &val, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Binary, + &val, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.binary_field.as_ref() { + __protocol.write_bytes_field(4, (value).clone())?; + } + if let Some(value) = self.uuid_field.as_ref() { + __protocol.write_uuid_field(5, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?); + } + __protocol.read_set_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec< + ::pilota::AHashMap< + ::pilota::AHashSet, + ::pilota::AHashMap< + i32, + ::pilota::AHashSet< + ::std::vec::Vec< + ::pilota::AHashMap, + >, + >, + >, + >, + > = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert({let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + }; + __protocol.read_set_end()?; + val}, { + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, {let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::AHashMap> = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + }; + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + }; + __protocol.read_set_end()?; + val}); + } + __protocol.read_map_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_4 = Some(__protocol.read_bytes()?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_5 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `CrazyNesting` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field list_field is required".to_string(), + )); + }; + + let data = Self { + string_field: var_1, + set_field: var_2, + list_field: var_3, + binary_field: var_4, + uuid_field: var_5, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2 = Some({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::decode_async(__protocol).await?); + }; + __protocol.read_set_end().await?; + val}); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert({let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + }; + __protocol.read_set_end().await?; + val}, { + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, {let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(::decode_async(__protocol).await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_set_end().await?; + val}); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_4 = Some(__protocol.read_bytes().await?); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_5 = Some(__protocol.read_uuid().await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `CrazyNesting` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field list_field is required".to_string(), + )); + }; + + let data = Self { + string_field: var_1, + set_field: var_2, + list_field: var_3, + binary_field: var_4, + uuid_field: var_5, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "CrazyNesting", + }) + self + .string_field + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self.set_field.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Map, + &self.list_field, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::Set, + ::pilota::thrift::TType::Map, + el, + |__protocol, key| { + __protocol.set_len( + ::pilota::thrift::TType::I32, + key, + |__protocol, el| __protocol.i32_len(*el), + ) + }, + |__protocol, val| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + val, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len( + ::pilota::thrift::TType::List, + val, + |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::Map, + el, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Binary, + el, + |__protocol, key| { + __protocol.struct_len(key) + }, + |__protocol, val| { + __protocol.faststr_len(val) + }, + ) + }, + ) + }, + ) + }, + ) + }, + ) + }, + ) + + self + .binary_field + .as_ref() + .map_or(0, |value| __protocol.bytes_field_len(Some(4), value)) + + self + .uuid_field + .as_ref() + .map_or(0, |value| __protocol.uuid_field_len(Some(5), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_EmptyStruct.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_EmptyStruct.rs new file mode 100644 index 00000000..47ee4766 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_EmptyStruct.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct EmptyStruct {} +impl ::pilota::thrift::Message for EmptyStruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "EmptyStruct", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `EmptyStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `EmptyStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "EmptyStruct", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_GuessProtocolStruct.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_GuessProtocolStruct.rs new file mode 100644 index 00000000..13db1c09 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_GuessProtocolStruct.rs @@ -0,0 +1,177 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct GuessProtocolStruct { + pub map_field: ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, +} +impl ::pilota::thrift::Message for GuessProtocolStruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "GuessProtocolStruct", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.map_field.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_7 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `GuessProtocolStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { map_field: var_7 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_7 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `GuessProtocolStruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { map_field: var_7 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "GuessProtocolStruct", + }) + self.map_field.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Insanity.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Insanity.rs new file mode 100644 index 00000000..046b5194 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Insanity.rs @@ -0,0 +1,235 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct Insanity { + pub user_map: ::std::option::Option< + ::pilota::AHashMap<::common::apache::Numberz, ::common::apache::UserId>, + >, + + pub xtructs: ::std::option::Option<::std::vec::Vec<::common::apache::Xtruct>>, +} +impl ::pilota::thrift::Message for Insanity { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Insanity" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.user_map.as_ref() { + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + &value, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.xtructs.as_ref() { + __protocol.write_list_field( + 2, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::common::apache::Xtruct> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Insanity` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + user_map: var_1, + xtructs: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?, <::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Insanity` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + user_map: var_1, + xtructs: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Insanity" }) + + self.user_map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I64, + value, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + }) + + self.xtructs.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_LargeDeltas.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_LargeDeltas.rs new file mode 100644 index 00000000..3fcfab17 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_LargeDeltas.rs @@ -0,0 +1,396 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct LargeDeltas { + pub b1: ::std::option::Option, + + pub b10: ::std::option::Option, + + pub b100: ::std::option::Option, + + pub check_true: ::std::option::Option, + + pub b1000: ::std::option::Option, + + pub check_false: ::std::option::Option, + + pub vertwo2000: ::std::option::Option, + + pub a_set2500: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, + + pub vertwo3000: ::std::option::Option, + + pub big_numbers: ::std::option::Option<::std::vec::Vec>, +} +impl ::pilota::thrift::Message for LargeDeltas { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "LargeDeltas", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b1.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.b10.as_ref() { + __protocol.write_struct_field(10, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.b100.as_ref() { + __protocol.write_struct_field(100, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.check_true.as_ref() { + __protocol.write_bool_field(500, *value)?; + } + if let Some(value) = self.b1000.as_ref() { + __protocol.write_struct_field(1000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.check_false.as_ref() { + __protocol.write_bool_field(1500, *value)?; + } + if let Some(value) = self.vertwo2000.as_ref() { + __protocol.write_struct_field(2000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.a_set2500.as_ref() { + __protocol.write_set_field( + 2500, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.vertwo3000.as_ref() { + __protocol.write_struct_field(3000, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.big_numbers.as_ref() { + __protocol.write_list_field( + 4000, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_10 = None; + let mut var_100 = None; + let mut var_500 = None; + let mut var_1000 = None; + let mut var_1500 = None; + let mut var_2000 = None; + let mut var_2500 = None; + let mut var_3000 = None; + let mut var_4000 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_10 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(100) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_100 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_500 = Some(__protocol.read_bool()?); + } + Some(1000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(1500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1500 = Some(__protocol.read_bool()?); + } + Some(2000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2500) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2500 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + Some(3000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_3000 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(4000) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_4000 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `LargeDeltas` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + b1: var_1, + b10: var_10, + b100: var_100, + check_true: var_500, + b1000: var_1000, + check_false: var_1500, + vertwo2000: var_2000, + a_set2500: var_2500, + vertwo3000: var_3000, + big_numbers: var_4000, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_10 = None; + let mut var_100 = None; + let mut var_500 = None; + let mut var_1000 = None; + let mut var_1500 = None; + let mut var_2000 = None; + let mut var_2500 = None; + let mut var_3000 = None; + let mut var_4000 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_10 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(100) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_100 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_500 = Some(__protocol.read_bool().await?); + } + Some(1000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1000 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(1500) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1500 = Some(__protocol.read_bool().await?); + } + Some(2000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2000 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(2500) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_2500 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + Some(3000) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_3000 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + Some(4000) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_4000 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `LargeDeltas` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + b1: var_1, + b10: var_10, + b100: var_100, + check_true: var_500, + b1000: var_1000, + check_false: var_1500, + vertwo2000: var_2000, + a_set2500: var_2500, + vertwo3000: var_3000, + big_numbers: var_4000, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "LargeDeltas", + }) + self + .b1 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .b10 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(10), value)) + + self + .b100 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(100), value)) + + self + .check_true + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(500), *value)) + + self + .b1000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1000), value)) + + self + .check_false + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(1500), *value)) + + self + .vertwo2000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2000), value)) + + self.a_set2500.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(2500), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + + self + .vertwo3000 + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(3000), value)) + + self.big_numbers.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(4000), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListBonks.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListBonks.rs new file mode 100644 index 00000000..57665361 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListBonks.rs @@ -0,0 +1,173 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ListBonks { + pub bonk: ::std::option::Option<::std::vec::Vec>, +} +impl ::pilota::thrift::Message for ListBonks { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "ListBonks" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bonk.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListBonks` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push( + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListBonks` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "ListBonks" }) + + self.bonk.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV1.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV1.rs new file mode 100644 index 00000000..771ee459 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV1.rs @@ -0,0 +1,193 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ListTypeVersioningV1 { + pub myints: ::std::option::Option<::std::vec::Vec>, + + pub hello: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for ListTypeVersioningV1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV1", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.myints.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.hello.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + myints: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + myints: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV1", + }) + self.myints.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + self + .hello + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV2.rs new file mode 100644 index 00000000..c1914e64 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ListTypeVersioningV2.rs @@ -0,0 +1,194 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ListTypeVersioningV2 { + pub strings: ::std::option::Option<::std::vec::Vec<::pilota::FastStr>>, + + pub hello: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for ListTypeVersioningV2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.strings.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.hello.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::FastStr> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_faststr()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + strings: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_faststr().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ListTypeVersioningV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + strings: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ListTypeVersioningV2", + }) + self.strings.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + self + .hello + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsBonk.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsBonk.rs new file mode 100644 index 00000000..3884a11a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsBonk.rs @@ -0,0 +1,232 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct NestedListsBonk { + pub bonk: ::std::option::Option<::std::vec::Vec<::std::vec::Vec<::std::vec::Vec>>>, +} +impl ::pilota::thrift::Message for NestedListsBonk { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsBonk", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bonk.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::vec::Vec>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsBonk` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::decode_async(__protocol).await?); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + }; + __protocol.read_list_end().await?; + val + }); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `NestedListsBonk` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { bonk: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsBonk", + }) + self.bonk.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len(::pilota::thrift::TType::List, el, |__protocol, el| { + __protocol.list_len( + ::pilota::thrift::TType::Struct, + el, + |__protocol, el| __protocol.struct_len(el), + ) + }) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x2.rs new file mode 100644 index 00000000..d119372d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x2.rs @@ -0,0 +1,199 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct NestedListsI32x2 { + pub integerlist: ::std::option::Option<::std::vec::Vec<::std::vec::Vec>>, +} +impl ::pilota::thrift::Message for NestedListsI32x2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.integerlist.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x2", + }) + self.integerlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len(::pilota::thrift::TType::I32, el, |__protocol, el| { + __protocol.i32_len(*el) + }) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x3.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x3.rs new file mode 100644 index 00000000..e11b9341 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedListsI32x3.rs @@ -0,0 +1,228 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct NestedListsI32x3 { + pub integerlist: ::std::option::Option<::std::vec::Vec<::std::vec::Vec<::std::vec::Vec>>>, +} +impl ::pilota::thrift::Message for NestedListsI32x3 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x3", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.integerlist.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::List, + &value, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::List, + &val, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::vec::Vec>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = + __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedListsI32x3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { integerlist: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedListsI32x3", + }) + self.integerlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::List, + value, + |__protocol, el| { + __protocol.list_len(::pilota::thrift::TType::List, el, |__protocol, el| { + __protocol.list_len(::pilota::thrift::TType::I32, el, |__protocol, el| { + __protocol.i32_len(*el) + }) + }) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedMixedx2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedMixedx2.rs new file mode 100644 index 00000000..b5cec4f5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_NestedMixedx2.rs @@ -0,0 +1,406 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct NestedMixedx2 { + pub int_set_list: ::std::option::Option<::std::vec::Vec<::pilota::AHashSet>>, + + pub map_int_strset: + ::std::option::Option<::pilota::AHashMap>>, + + pub map_int_strset_list: ::std::option::Option< + ::std::vec::Vec<::pilota::AHashMap>>, + >, +} +impl ::pilota::thrift::Message for NestedMixedx2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "NestedMixedx2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.int_set_list.as_ref() { + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::Set, + &value, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::I32, + &val, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.map_int_strset.as_ref() { + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::Binary, + &val, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.map_int_strset_list.as_ref() { + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Map, + &value, + |__protocol, val| { + __protocol.write_map( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + &val, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_set( + ::pilota::thrift::TType::Binary, + &val, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::pilota::AHashSet> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec< + ::pilota::AHashMap>, + > = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, { + let list_ident = __protocol.read_set_begin()?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedMixedx2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + int_set_list: var_1, + map_int_strset: var_2, + map_int_strset_list: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = __protocol.read_set_begin().await?; + let mut val = + ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = + ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = + __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity( + list_ident.size, + ); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `NestedMixedx2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + int_set_list: var_1, + map_int_strset: var_2, + map_int_strset_list: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "NestedMixedx2", + }) + self.int_set_list.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::Set, + value, + |__protocol, el| { + __protocol.set_len(::pilota::thrift::TType::I32, el, |__protocol, el| { + __protocol.i32_len(*el) + }) + }, + ) + }) + self.map_int_strset.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len(::pilota::thrift::TType::Binary, val, |__protocol, el| { + __protocol.faststr_len(el) + }) + }, + ) + }) + self.map_int_strset_list.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Map, + value, + |__protocol, el| { + __protocol.map_len( + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::Set, + el, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.set_len( + ::pilota::thrift::TType::Binary, + val, + |__protocol, el| __protocol.faststr_len(el), + ) + }, + ) + }, + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OneField.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OneField.rs new file mode 100644 index 00000000..f9dc8196 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OneField.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct OneField { + pub field: ::std::option::Option, +} +impl ::pilota::thrift::Message for OneField { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "OneField" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.field.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OneField` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { field: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OneField` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { field: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "OneField" }) + + self + .field + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalBinary.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalBinary.rs new file mode 100644 index 00000000..3e0b9561 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalBinary.rs @@ -0,0 +1,205 @@ + +impl Default for OptionalBinary { + fn default() -> Self { + OptionalBinary { + bin_map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }), + } + } +} +#[derive(Debug, Clone, PartialEq)] +pub struct OptionalBinary { + pub bin_map: ::std::option::Option<::pilota::AHashMap<::pilota::Bytes, i32>>, +} +impl ::pilota::thrift::Message for OptionalBinary { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "OptionalBinary", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.bin_map.as_ref() { + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_bytes(key.clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_bytes()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalBinary` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_2.is_none() { + var_2 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }); + } + + let data = Self { bin_map: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_bytes().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalBinary` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_2.is_none() { + var_2 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(0); + + map + }); + } + + let data = Self { bin_map: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "OptionalBinary", + }) + self.bin_map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.bytes_len(key), + |__protocol, val| __protocol.i32_len(*val), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalSetDefaultTest.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalSetDefaultTest.rs new file mode 100644 index 00000000..29fe8db5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_OptionalSetDefaultTest.rs @@ -0,0 +1,193 @@ + +impl Default for OptionalSetDefaultTest { + fn default() -> Self { + OptionalSetDefaultTest { + with_default: Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])), + } + } +} +#[derive(Debug, Clone, PartialEq)] +pub struct OptionalSetDefaultTest { + pub with_default: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, +} +impl ::pilota::thrift::Message for OptionalSetDefaultTest { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "OptionalSetDefaultTest", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.with_default.as_ref() { + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalSetDefaultTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_1.is_none() { + var_1 = Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])); + } + + let data = Self { + with_default: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `OptionalSetDefaultTest` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_1.is_none() { + var_1 = Some(::pilota::AHashSet::from([ + ::pilota::FastStr::from_static_str("test"), + ])); + } + + let data = Self { + with_default: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "OptionalSetDefaultTest", + }) + self.with_default.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsRecv.rs new file mode 100644 index 00000000..516fc400 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsRecv.rs @@ -0,0 +1,143 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct SecondServiceSecondtestStringArgsRecv { + pub thing: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for SecondServiceSecondtestStringArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsSend.rs new file mode 100644 index 00000000..55b5c964 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_SecondServiceSecondtestStringArgsSend.rs @@ -0,0 +1,143 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct SecondServiceSecondtestStringArgsSend { + pub thing: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for SecondServiceSecondtestStringArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `SecondServiceSecondtestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "SecondServiceSecondtestStringArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructA.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructA.rs new file mode 100644 index 00000000..c5a905ce --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructA.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct StructA { + pub s: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for StructA { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "StructA" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.s).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructA` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field s is required".to_string(), + )); + }; + + let data = Self { s: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructA` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field s is required".to_string(), + )); + }; + + let data = Self { s: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "StructA" }) + + __protocol.faststr_field_len(Some(1), &self.s) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructB.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructB.rs new file mode 100644 index 00000000..fd309c1a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_StructB.rs @@ -0,0 +1,175 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct StructB { + pub aa: ::std::option::Option, + + pub ab: StructA, +} +impl ::pilota::thrift::Message for StructB { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "StructB" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.aa.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_struct_field(2, &self.ab, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructB` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ab is required".to_string(), + )); + }; + + let data = Self { + aa: var_1, + ab: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StructB` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ab is required".to_string(), + )); + }; + + let data = Self { + aa: var_1, + ab: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "StructB" }) + + self + .aa + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.struct_field_len(Some(2), &self.ab) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsRecv.rs new file mode 100644 index 00000000..f9a0cf0b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsRecv.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestBinaryArgsRecv { + pub thing: ::pilota::Bytes, +} +impl ::pilota::thrift::Message for ThriftTestTestBinaryArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBinaryArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsRecv", + }) + __protocol.bytes_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsSend.rs new file mode 100644 index 00000000..9d4f3613 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBinaryArgsSend.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestBinaryArgsSend { + pub thing: ::pilota::Bytes, +} +impl ::pilota::thrift::Message for ThriftTestTestBinaryArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBinaryArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestBinaryArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBinaryArgsSend", + }) + __protocol.bytes_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsRecv.rs new file mode 100644 index 00000000..7173e40e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestBoolArgsRecv { + pub thing: bool, +} +impl ::pilota::thrift::Message for ThriftTestTestBoolArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bool_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBoolArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBoolArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsRecv", + }) + __protocol.bool_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsSend.rs new file mode 100644 index 00000000..e9e4e8a1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestBoolArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestBoolArgsSend { + pub thing: bool, +} +impl ::pilota::thrift::Message for ThriftTestTestBoolArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bool_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBoolArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_1 = Some(__protocol.read_bool().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestBoolArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestBoolArgsSend", + }) + __protocol.bool_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsRecv.rs new file mode 100644 index 00000000..30f7a88a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestByteArgsRecv { + pub thing: i8, +} +impl ::pilota::thrift::Message for ThriftTestTestByteArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestByteArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestByteArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsRecv", + }) + __protocol.i8_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsSend.rs new file mode 100644 index 00000000..33a00745 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestByteArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestByteArgsSend { + pub thing: i8, +} +impl ::pilota::thrift::Message for ThriftTestTestByteArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestByteArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestByteArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestByteArgsSend", + }) + __protocol.i8_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsRecv.rs new file mode 100644 index 00000000..56f07ef0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsRecv.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestDoubleArgsRecv { + pub thing: f64, +} +impl ::pilota::thrift::Message for ThriftTestTestDoubleArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_double_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_1 = Some(__protocol.read_double()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestDoubleArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_1 = Some(__protocol.read_double().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsRecv", + }) + __protocol.double_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsSend.rs new file mode 100644 index 00000000..9cb80e77 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestDoubleArgsSend.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestDoubleArgsSend { + pub thing: f64, +} +impl ::pilota::thrift::Message for ThriftTestTestDoubleArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_double_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_1 = Some(__protocol.read_double()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestDoubleArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_1 = Some(__protocol.read_double().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestDoubleArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestDoubleArgsSend", + }) + __protocol.double_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsRecv.rs new file mode 100644 index 00000000..4b580277 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestEnumArgsRecv { + pub thing: ::common::apache::Numberz, +} +impl ::pilota::thrift::Message for ThriftTestTestEnumArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.thing).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestEnumArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsRecv", + }) + __protocol.i32_field_len(Some(1), (&self.thing).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsSend.rs new file mode 100644 index 00000000..bf1af53e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestEnumArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestEnumArgsSend { + pub thing: ::common::apache::Numberz, +} +impl ::pilota::thrift::Message for ThriftTestTestEnumArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.thing).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestEnumArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestEnumArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestEnumArgsSend", + }) + __protocol.i32_field_len(Some(1), (&self.thing).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsRecv.rs new file mode 100644 index 00000000..4219e356 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsRecv.rs @@ -0,0 +1,143 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestExceptionArgsRecv { + pub arg: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.arg) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsSend.rs new file mode 100644 index 00000000..fea8e054 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestExceptionArgsSend.rs @@ -0,0 +1,143 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestExceptionArgsSend { + pub arg: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg is required".to_string(), + )); + }; + + let data = Self { arg: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestExceptionArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.arg) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsRecv.rs new file mode 100644 index 00000000..54540894 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestI32ArgsRecv { + pub thing: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestI32ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI32ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI32ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsSend.rs new file mode 100644 index 00000000..693e0738 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI32ArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestI32ArgsSend { + pub thing: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestI32ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI32ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI32ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI32ArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsRecv.rs new file mode 100644 index 00000000..f4529b82 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestI64ArgsRecv { + pub thing: i64, +} +impl ::pilota::thrift::Message for ThriftTestTestI64ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i64_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI64ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI64ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsRecv", + }) + __protocol.i64_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsSend.rs new file mode 100644 index 00000000..500b3a33 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestI64ArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestI64ArgsSend { + pub thing: i64, +} +impl ::pilota::thrift::Message for ThriftTestTestI64ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i64_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI64ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestI64ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestI64ArgsSend", + }) + __protocol.i64_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsRecv.rs new file mode 100644 index 00000000..3fff4989 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestInsanityArgsRecv { + pub argument: Insanity, +} +impl ::pilota::thrift::Message for ThriftTestTestInsanityArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.argument, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestInsanityArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.argument) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsSend.rs new file mode 100644 index 00000000..94e9761b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestInsanityArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestInsanityArgsSend { + pub argument: Insanity, +} +impl ::pilota::thrift::Message for ThriftTestTestInsanityArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.argument, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestInsanityArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestInsanityArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field argument is required".to_string(), + )); + }; + + let data = Self { argument: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestInsanityArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.argument) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsRecv.rs new file mode 100644 index 00000000..19f24f7e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsRecv.rs @@ -0,0 +1,180 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestListArgsRecv { + pub thing: ::std::vec::Vec, +} +impl ::pilota::thrift::Message for ThriftTestTestListArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestListArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestListArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsRecv", + }) + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsSend.rs new file mode 100644 index 00000000..1f2856b3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestListArgsSend.rs @@ -0,0 +1,180 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestListArgsSend { + pub thing: ::std::vec::Vec, +} +impl ::pilota::thrift::Message for ThriftTestTestListArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_list_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestListArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_1 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestListArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestListArgsSend", + }) + __protocol.list_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsRecv.rs new file mode 100644 index 00000000..c27de213 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsRecv.rs @@ -0,0 +1,187 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMapArgsRecv { + pub thing: ::pilota::AHashMap, +} +impl ::pilota::thrift::Message for ThriftTestTestMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsRecv", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsSend.rs new file mode 100644 index 00000000..ef32fd6f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapArgsSend.rs @@ -0,0 +1,187 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMapArgsSend { + pub thing: ::pilota::AHashMap, +} +impl ::pilota::thrift::Message for ThriftTestTestMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapArgsSend", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsRecv.rs new file mode 100644 index 00000000..c0e5136d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsRecv.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMapMapArgsRecv { + pub hello: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestMapMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.hello)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapMapArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsSend.rs new file mode 100644 index 00000000..55e85373 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMapMapArgsSend.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMapMapArgsSend { + pub hello: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestMapMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.hello)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMapMapArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMapMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { hello: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMapMapArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsRecv.rs new file mode 100644 index 00000000..3dca7f9e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsRecv.rs @@ -0,0 +1,322 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMultiArgsRecv { + pub arg0: i8, + + pub arg1: i32, + + pub arg2: i64, + + pub arg3: ::pilota::AHashMap, + + pub arg4: ::common::apache::Numberz, + + pub arg5: ::common::apache::UserId, +} +impl ::pilota::thrift::Message for ThriftTestTestMultiArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.arg0)?; + __protocol.write_i32_field(2, *&self.arg1)?; + __protocol.write_i64_field(3, *&self.arg2)?; + __protocol.write_map_field( + 4, + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &&self.arg3, + |__protocol, key| { + __protocol.write_i16(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_i32_field(5, (&self.arg4).inner())?; + __protocol.write_struct_field(6, &self.arg5, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMultiArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64().await?); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16().await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsRecv", + }) + __protocol.i8_field_len(Some(1), *&self.arg0) + + __protocol.i32_field_len(Some(2), *&self.arg1) + + __protocol.i64_field_len(Some(3), *&self.arg2) + + __protocol.map_field_len( + Some(4), + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &self.arg3, + |__protocol, key| __protocol.i16_len(*key), + |__protocol, val| __protocol.faststr_len(val), + ) + + __protocol.i32_field_len(Some(5), (&self.arg4).inner()) + + __protocol.struct_field_len(Some(6), &self.arg5) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsSend.rs new file mode 100644 index 00000000..c5285165 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiArgsSend.rs @@ -0,0 +1,322 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMultiArgsSend { + pub arg0: i8, + + pub arg1: i32, + + pub arg2: i64, + + pub arg3: ::pilota::AHashMap, + + pub arg4: ::common::apache::Numberz, + + pub arg5: ::common::apache::UserId, +} +impl ::pilota::thrift::Message for ThriftTestTestMultiArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i8_field(1, *&self.arg0)?; + __protocol.write_i32_field(2, *&self.arg1)?; + __protocol.write_i64_field(3, *&self.arg2)?; + __protocol.write_map_field( + 4, + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &&self.arg3, + |__protocol, key| { + __protocol.write_i16(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_i32_field(5, (&self.arg4).inner())?; + __protocol.write_struct_field(6, &self.arg5, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestMultiArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_3 = Some(__protocol.read_i64().await?); + + },Some(4) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_4 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i16().await?, __protocol.read_faststr().await?); + } + __protocol.read_map_end().await?; + val + }); + + },Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(<::common::apache::Numberz as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(6) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_6 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg2 is required".to_string(), + )); + }; + let Some(var_4) = var_4 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg3 is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg4 is required".to_string(), + )); + }; + let Some(var_6) = var_6 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg5 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + arg2: var_3, + arg3: var_4, + arg4: var_5, + arg5: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiArgsSend", + }) + __protocol.i8_field_len(Some(1), *&self.arg0) + + __protocol.i32_field_len(Some(2), *&self.arg1) + + __protocol.i64_field_len(Some(3), *&self.arg2) + + __protocol.map_field_len( + Some(4), + ::pilota::thrift::TType::I16, + ::pilota::thrift::TType::Binary, + &self.arg3, + |__protocol, key| __protocol.i16_len(*key), + |__protocol, val| __protocol.faststr_len(val), + ) + + __protocol.i32_field_len(Some(5), (&self.arg4).inner()) + + __protocol.struct_field_len(Some(6), &self.arg5) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsRecv.rs new file mode 100644 index 00000000..92924b70 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsRecv.rs @@ -0,0 +1,173 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMultiExceptionArgsRecv { + pub arg0: ::pilota::FastStr, + + pub arg1: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg0).clone())?; + __protocol.write_faststr_field(2, (&self.arg1).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.arg0) + + __protocol.faststr_field_len(Some(2), &self.arg1) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsSend.rs new file mode 100644 index 00000000..603920fc --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestMultiExceptionArgsSend.rs @@ -0,0 +1,173 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestMultiExceptionArgsSend { + pub arg0: ::pilota::FastStr, + + pub arg1: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestMultiExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.arg0).clone())?; + __protocol.write_faststr_field(2, (&self.arg1).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestMultiExceptionArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg0 is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field arg1 is required".to_string(), + )); + }; + + let data = Self { + arg0: var_1, + arg1: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestMultiExceptionArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.arg0) + + __protocol.faststr_field_len(Some(2), &self.arg1) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsRecv.rs new file mode 100644 index 00000000..dcbfaf0d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestNestArgsRecv { + pub thing: Xtruct2, +} +impl ::pilota::thrift::Message for ThriftTestTestNestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestNestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestNestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsSend.rs new file mode 100644 index 00000000..ddc95d13 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestNestArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestNestArgsSend { + pub thing: Xtruct2, +} +impl ::pilota::thrift::Message for ThriftTestTestNestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestNestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestNestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestNestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsRecv.rs new file mode 100644 index 00000000..9df58aeb --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsRecv.rs @@ -0,0 +1,150 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestOnewayArgsRecv { + pub seconds_to_sleep: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestOnewayArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.seconds_to_sleep)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestOnewayArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsRecv", + }) + __protocol.i32_field_len(Some(1), *&self.seconds_to_sleep) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsSend.rs new file mode 100644 index 00000000..515c43ec --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestOnewayArgsSend.rs @@ -0,0 +1,150 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestOnewayArgsSend { + pub seconds_to_sleep: i32, +} +impl ::pilota::thrift::Message for ThriftTestTestOnewayArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, *&self.seconds_to_sleep)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestOnewayArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestOnewayArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field seconds_to_sleep is required".to_string(), + )); + }; + + let data = Self { + seconds_to_sleep: var_1, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestOnewayArgsSend", + }) + __protocol.i32_field_len(Some(1), *&self.seconds_to_sleep) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsRecv.rs new file mode 100644 index 00000000..9a53dd83 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsRecv.rs @@ -0,0 +1,177 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestSetArgsRecv { + pub thing: ::pilota::AHashSet, +} +impl ::pilota::thrift::Message for ThriftTestTestSetArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestSetArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestSetArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsRecv", + }) + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsSend.rs new file mode 100644 index 00000000..9085c10a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestSetArgsSend.rs @@ -0,0 +1,177 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestSetArgsSend { + pub thing: ::pilota::AHashSet, +} +impl ::pilota::thrift::Message for ThriftTestTestSetArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::I32, + &&self.thing, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestSetArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestSetArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestSetArgsSend", + }) + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::I32, + &self.thing, + |__protocol, el| __protocol.i32_len(*el), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsRecv.rs new file mode 100644 index 00000000..60057f77 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsRecv.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStringArgsRecv { + pub thing: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestStringArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestStringArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsRecv", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsSend.rs new file mode 100644 index 00000000..2320c445 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringArgsSend.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStringArgsSend { + pub thing: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for ThriftTestTestStringArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.thing).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestStringArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringArgsSend", + }) + __protocol.faststr_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsRecv.rs new file mode 100644 index 00000000..917f6e0a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsRecv.rs @@ -0,0 +1,181 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStringMapArgsRecv { + pub thing: ::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>, +} +impl ::pilota::thrift::Message for ThriftTestTestStringMapArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &&self.thing, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsRecv", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &self.thing, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsSend.rs new file mode 100644 index 00000000..dd0ff541 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStringMapArgsSend.rs @@ -0,0 +1,181 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStringMapArgsSend { + pub thing: ::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>, +} +impl ::pilota::thrift::Message for ThriftTestTestStringMapArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_map_field( + 1, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &&self.thing, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_1 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStringMapArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStringMapArgsSend", + }) + __protocol.map_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &self.thing, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsRecv.rs new file mode 100644 index 00000000..7230e2cb --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStructArgsRecv { + pub thing: ::common::apache::Xtruct, +} +impl ::pilota::thrift::Message for ThriftTestTestStructArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestStructArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsSend.rs new file mode 100644 index 00000000..0139185f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestStructArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestStructArgsSend { + pub thing: ::common::apache::Xtruct, +} +impl ::pilota::thrift::Message for ThriftTestTestStructArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestStructArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestStructArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestStructArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsRecv.rs new file mode 100644 index 00000000..7b296a65 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestTypedefArgsRecv { + pub thing: ::common::apache::UserId, +} +impl ::pilota::thrift::Message for ThriftTestTestTypedefArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestTypedefArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsSend.rs new file mode 100644 index 00000000..f2d3ee27 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestTypedefArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestTypedefArgsSend { + pub thing: ::common::apache::UserId, +} +impl ::pilota::thrift::Message for ThriftTestTestTypedefArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.thing, ::pilota::thrift::TType::I64)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestTypedefArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_1 = Some(<::common::apache::UserId as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `ThriftTestTestTypedefArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestTypedefArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsRecv.rs new file mode 100644 index 00000000..6aaf721b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsRecv.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestUuidArgsRecv { + pub thing: [u8; 16], +} +impl ::pilota::thrift::Message for ThriftTestTestUuidArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_uuid_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestUuidArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestUuidArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsRecv", + }) + __protocol.uuid_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsSend.rs new file mode 100644 index 00000000..854b20c1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestUuidArgsSend.rs @@ -0,0 +1,149 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestUuidArgsSend { + pub thing: [u8; 16], +} +impl ::pilota::thrift::Message for ThriftTestTestUuidArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_uuid_field(1, *&self.thing)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestUuidArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestUuidArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field thing is required".to_string(), + )); + }; + + let data = Self { thing: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestUuidArgsSend", + }) + __protocol.uuid_field_len(Some(1), *&self.thing) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsRecv.rs new file mode 100644 index 00000000..753d6267 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsRecv.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestVoidArgsRecv {} +impl ::pilota::thrift::Message for ThriftTestTestVoidArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestVoidArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestVoidArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsSend.rs new file mode 100644 index 00000000..8792ea5f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_ThriftTestTestVoidArgsSend.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ThriftTestTestVoidArgsSend {} +impl ::pilota::thrift::Message for ThriftTestTestVoidArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestVoidArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ThriftTestTestVoidArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ThriftTestTestVoidArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV1.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV1.rs new file mode 100644 index 00000000..08c6dfa7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV1.rs @@ -0,0 +1,182 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct VersioningTestV1 { + pub begin_in_both: ::std::option::Option, + + pub old_string: ::std::option::Option<::pilota::FastStr>, + + pub end_in_both: ::std::option::Option, +} +impl ::pilota::thrift::Message for VersioningTestV1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "VersioningTestV1", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.begin_in_both.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.old_string.as_ref() { + __protocol.write_faststr_field(3, (value).clone())?; + } + if let Some(value) = self.end_in_both.as_ref() { + __protocol.write_i32_field(12, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_3 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr()?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + begin_in_both: var_1, + old_string: var_3, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_3 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr().await?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + begin_in_both: var_1, + old_string: var_3, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "VersioningTestV1", + }) + self + .begin_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .old_string + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(3), value)) + + self + .end_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(12), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV2.rs new file mode 100644 index 00000000..01f2007c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_VersioningTestV2.rs @@ -0,0 +1,453 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct VersioningTestV2 { + pub begin_in_both: ::std::option::Option, + + pub newint: ::std::option::Option, + + pub newbyte: ::std::option::Option, + + pub newshort: ::std::option::Option, + + pub newlong: ::std::option::Option, + + pub newdouble: ::std::option::Option, + + pub newstruct: ::std::option::Option, + + pub newlist: ::std::option::Option<::std::vec::Vec>, + + pub newset: ::std::option::Option<::pilota::AHashSet>, + + pub newmap: ::std::option::Option<::pilota::AHashMap>, + + pub newstring: ::std::option::Option<::pilota::FastStr>, + + pub end_in_both: ::std::option::Option, +} +impl ::pilota::thrift::Message for VersioningTestV2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "VersioningTestV2", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.begin_in_both.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.newint.as_ref() { + __protocol.write_i32_field(2, *value)?; + } + if let Some(value) = self.newbyte.as_ref() { + __protocol.write_i8_field(3, *value)?; + } + if let Some(value) = self.newshort.as_ref() { + __protocol.write_i16_field(4, *value)?; + } + if let Some(value) = self.newlong.as_ref() { + __protocol.write_i64_field(5, *value)?; + } + if let Some(value) = self.newdouble.as_ref() { + __protocol.write_double_field(6, *value)?; + } + if let Some(value) = self.newstruct.as_ref() { + __protocol.write_struct_field(7, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.newlist.as_ref() { + __protocol.write_list_field( + 8, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newset.as_ref() { + __protocol.write_set_field( + 9, + ::pilota::thrift::TType::I32, + &value, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newmap.as_ref() { + __protocol.write_map_field( + 10, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + &value, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_i32(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.newstring.as_ref() { + __protocol.write_faststr_field(11, (value).clone())?; + } + if let Some(value) = self.end_in_both.as_ref() { + __protocol.write_i32_field(12, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + let mut var_7 = None; + let mut var_8 = None; + let mut var_9 = None; + let mut var_10 = None; + let mut var_11 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_3 = Some(__protocol.read_i8()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I16 => { + var_4 = Some(__protocol.read_i16()?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_5 = Some(__protocol.read_i64()?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_6 = Some(__protocol.read_double()?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_7 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_8 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(__protocol.read_i32()?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_9 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32()?); + } + __protocol.read_set_end()?; + val + }); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_10 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, __protocol.read_i32()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = Some(__protocol.read_faststr()?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + begin_in_both: var_1, + newint: var_2, + newbyte: var_3, + newshort: var_4, + newlong: var_5, + newdouble: var_6, + newstruct: var_7, + newlist: var_8, + newset: var_9, + newmap: var_10, + newstring: var_11, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + let mut var_7 = None; + let mut var_8 = None; + let mut var_9 = None; + let mut var_10 = None; + let mut var_11 = None; + let mut var_12 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(__protocol.read_i32().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_3 = Some(__protocol.read_i8().await?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I16 => { + var_4 = Some(__protocol.read_i16().await?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_5 = Some(__protocol.read_i64().await?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_6 = Some(__protocol.read_double().await?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_7 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_8 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(__protocol.read_i32().await?); + } + __protocol.read_list_end().await?; + val + }); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_9 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_i32().await?); + } + __protocol.read_set_end().await?; + val + }); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_10 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_i32().await?, + __protocol.read_i32().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = Some(__protocol.read_faststr().await?); + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_12 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `VersioningTestV2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + begin_in_both: var_1, + newint: var_2, + newbyte: var_3, + newshort: var_4, + newlong: var_5, + newdouble: var_6, + newstruct: var_7, + newlist: var_8, + newset: var_9, + newmap: var_10, + newstring: var_11, + end_in_both: var_12, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "VersioningTestV2", + }) + self + .begin_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .newint + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(2), *value)) + + self + .newbyte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(3), *value)) + + self + .newshort + .as_ref() + .map_or(0, |value| __protocol.i16_field_len(Some(4), *value)) + + self + .newlong + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(5), *value)) + + self + .newdouble + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(6), *value)) + + self + .newstruct + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(7), value)) + + self.newlist.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(8), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + self.newset.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(9), + ::pilota::thrift::TType::I32, + value, + |__protocol, el| __protocol.i32_len(*el), + ) + }) + + self.newmap.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(10), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::I32, + value, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| __protocol.i32_len(*val), + ) + }) + + self + .newstring + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(11), value)) + + self + .end_in_both + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(12), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception.rs new file mode 100644 index 00000000..299330cb --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception.rs @@ -0,0 +1,160 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Xception { + pub error_code: ::std::option::Option, + + pub message: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for Xception { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xception" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.error_code.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + error_code: var_1, + message: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + error_code: var_1, + message: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xception" }) + + self + .error_code + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception2.rs new file mode 100644 index 00000000..90ad91b2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xception2.rs @@ -0,0 +1,163 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Xception2 { + pub error_code: ::std::option::Option, + + pub struct_thing: ::std::option::Option<::common::apache::Xtruct>, +} +impl ::pilota::thrift::Message for Xception2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xception2" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.error_code.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + if let Some(value) = self.struct_thing.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xception2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + error_code: var_1, + struct_thing: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Xception2` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + error_code: var_1, + struct_thing: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xception2" }) + + self + .error_code + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + self + .struct_thing + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct.rs new file mode 100644 index 00000000..1e0da53a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct.rs @@ -0,0 +1 @@ +pub use ::common::apache::Xtruct; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct2.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct2.rs new file mode 100644 index 00000000..f2a4d87e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct2.rs @@ -0,0 +1,182 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Xtruct2 { + pub byte_thing: ::std::option::Option, + + pub struct_thing: ::std::option::Option<::common::apache::Xtruct>, + + pub i32_thing: ::std::option::Option, +} +impl ::pilota::thrift::Message for Xtruct2 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct2" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.byte_thing.as_ref() { + __protocol.write_i8_field(1, *value)?; + } + if let Some(value) = self.struct_thing.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(3, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_3 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct2` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + byte_thing: var_1, + struct_thing: var_2, + i32_thing: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_1 = Some(__protocol.read_i8().await?); + + },Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(<::common::apache::Xtruct as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + },Some(3) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_3 = Some(__protocol.read_i32().await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `Xtruct2` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + byte_thing: var_1, + struct_thing: var_2, + i32_thing: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct2" }) + + self + .byte_thing + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(1), *value)) + + self + .struct_thing + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(3), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct3.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct3.rs new file mode 100644 index 00000000..7a5d09a5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/message_Xtruct3.rs @@ -0,0 +1,198 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Xtruct3 { + pub string_thing: ::std::option::Option<::pilota::FastStr>, + + pub changed: ::std::option::Option, + + pub i32_thing: ::std::option::Option, + + pub i64_thing: ::std::option::Option, +} +impl ::pilota::thrift::Message for Xtruct3 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct3" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_thing.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.changed.as_ref() { + __protocol.write_i32_field(4, *value)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(9, *value)?; + } + if let Some(value) = self.i64_thing.as_ref() { + __protocol.write_i64_field(11, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(__protocol.read_i32()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + string_thing: var_1, + changed: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(__protocol.read_i32().await?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32().await?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct3` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + string_thing: var_1, + changed: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct3" }) + + self + .string_thing + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .changed + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(4), *value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(9), *value)) + + self + .i64_thing + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(11), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_MapType.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_MapType.rs new file mode 100644 index 00000000..3cea0d02 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_MapType.rs @@ -0,0 +1,97 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct MapType(pub ::pilota::AHashMap<::pilota::FastStr, Bonk>); + +impl ::std::ops::Deref for MapType { + type Target = ::pilota::AHashMap<::pilota::FastStr, Bonk>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From<::pilota::AHashMap<::pilota::FastStr, Bonk>> for MapType { + fn from(v: ::pilota::AHashMap<::pilota::FastStr, Bonk>) -> Self { + Self(v) + } +} + +impl ::pilota::thrift::Message for MapType { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_map( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Struct, + &(&**self), + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(MapType({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr()?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + })) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(MapType({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + ::decode_async(__protocol).await?, + ); + } + __protocol.read_map_end().await?; + val + })) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.map_len( + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Struct, + &**self, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_UserId.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_UserId.rs new file mode 100644 index 00000000..98ea3f99 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/new_type_UserId.rs @@ -0,0 +1 @@ +pub use ::common::apache::UserId; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_SecondService.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_SecondService.rs new file mode 100644 index 00000000..fbcd93b7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_SecondService.rs @@ -0,0 +1,2 @@ + +pub trait SecondService {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_ThriftTest.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_ThriftTest.rs new file mode 100644 index 00000000..4c0808c4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/apache/src/service_ThriftTest.rs @@ -0,0 +1,2 @@ + +pub trait ThriftTest {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/apache/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/enum_Numberz.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/enum_Numberz.rs new file mode 100644 index 00000000..b65c3397 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/enum_Numberz.rs @@ -0,0 +1,95 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Numberz(i32); + +impl Numberz { + pub const ONE: Self = Self(1); + pub const TWO: Self = Self(2); + pub const THREE: Self = Self(3); + pub const FIVE: Self = Self(5); + pub const SIX: Self = Self(6); + pub const EIGHT: Self = Self(8); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("ONE"), + Self(2) => ::std::string::String::from("TWO"), + Self(3) => ::std::string::String::from("THREE"), + Self(5) => ::std::string::String::from("FIVE"), + Self(6) => ::std::string::String::from("SIX"), + Self(8) => ::std::string::String::from("EIGHT"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Numberz { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Numberz) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Numberz { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Numberz, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Numberz, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/gen.rs new file mode 100644 index 00000000..4fe64072 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/gen.rs @@ -0,0 +1,9 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod apache { + include!("src/enum_Numberz.rs"); + include!("src/new_type_UserId.rs"); + include!("src/message_Xtruct.rs"); + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/message_Xtruct.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/message_Xtruct.rs new file mode 100644 index 00000000..e98345f7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/message_Xtruct.rs @@ -0,0 +1,198 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Xtruct { + pub string_thing: ::std::option::Option<::pilota::FastStr>, + + pub byte_thing: ::std::option::Option, + + pub i32_thing: ::std::option::Option, + + pub i64_thing: ::std::option::Option, +} +impl ::pilota::thrift::Message for Xtruct { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Xtruct" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.string_thing.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.byte_thing.as_ref() { + __protocol.write_i8_field(4, *value)?; + } + if let Some(value) = self.i32_thing.as_ref() { + __protocol.write_i32_field(9, *value)?; + } + if let Some(value) = self.i64_thing.as_ref() { + __protocol.write_i64_field(11, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_4 = Some(__protocol.read_i8()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + string_thing: var_1, + byte_thing: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_4 = None; + let mut var_9 = None; + let mut var_11 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_4 = Some(__protocol.read_i8().await?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_9 = Some(__protocol.read_i32().await?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::I64 => { + var_11 = Some(__protocol.read_i64().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Xtruct` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + string_thing: var_1, + byte_thing: var_4, + i32_thing: var_9, + i64_thing: var_11, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Xtruct" }) + + self + .string_thing + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .byte_thing + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(4), *value)) + + self + .i32_thing + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(9), *value)) + + self + .i64_thing + .as_ref() + .map_or(0, |value| __protocol.i64_field_len(Some(11), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/new_type_UserId.rs b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/new_type_UserId.rs new file mode 100644 index 00000000..7e0c6f98 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/apache/common/src/new_type_UserId.rs @@ -0,0 +1,57 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct UserId(pub i64); + +impl ::std::ops::Deref for UserId { + type Target = i64; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for UserId { + fn from(v: i64) -> Self { + Self(v) + } +} + +impl ::pilota::thrift::Message for UserId { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i64(*(&**self))?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(UserId(__protocol.read_i64()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(UserId(__protocol.read_i64().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i64_len(*&**self) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift b/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift new file mode 100644 index 00000000..badc2e0c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name.thrift @@ -0,0 +1,33 @@ + +struct TEST { + 1: required string Id, +} + +const string ip = "ip"; +const string IP = "IP"; + +struct Test { + 1: required string ID, + 2: required string Id, +} + +enum Index { + A, + a, +} + +struct TestException { + +} + +service Service { + Test test(1: TEST req, 2: TEST Req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST type); +} + +service service { + Test test(1: TEST req) throws (1: TestException e); + Test Test(1: TEST Req) throws (1: TestException e); + Test Test2(1: TEST self); +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/auto_name/Cargo.toml new file mode 100644 index 00000000..1b42860e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["auto_name"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/Cargo.toml new file mode 100644 index 00000000..b005b796 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "auto_name" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/const_ip.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/const_ip.rs new file mode 100644 index 00000000..5fc45c72 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/const_ip.rs @@ -0,0 +1 @@ +pub const IP: &'static str = "IP"; diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_Index.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_Index.rs new file mode 100644 index 00000000..d8190fd9 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_Index.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Index(i32); + +impl Index { + pub const A: Self = Self(0); + pub const a: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("a"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultRecv.rs new file mode 100644 index 00000000..da942762 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ServiceTest2ResultRecv { + #[derivative(Default)] + Ok(Test), +} + +impl ::pilota::thrift::Message for ServiceTest2ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultRecv", + })?; + match self { + ServiceTest2ResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultRecv", + }) + match self { + ServiceTest2ResultRecv::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultSend.rs new file mode 100644 index 00000000..aba81667 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_serviceTest2ResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ServiceTest2ResultSend { + #[derivative(Default)] + Ok(Test), +} + +impl ::pilota::thrift::Message for ServiceTest2ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultSend", + })?; + match self { + ServiceTest2ResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ServiceTest2ResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ResultSend", + }) + match self { + ServiceTest2ResultSend::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestException.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestException.rs new file mode 100644 index 00000000..ee62aeb7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestException.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ServiceTestException { + #[derivative(Default)] + E(TestException), +} + +impl ::pilota::thrift::Message for ServiceTestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestException", + })?; + match self { + ServiceTestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestException::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestException", + }) + match self { + ServiceTestException::E(ref value) => __protocol.struct_field_len(Some(1), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultRecv.rs new file mode 100644 index 00000000..8713488b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultRecv.rs @@ -0,0 +1,178 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ServiceTestResultRecv { + #[derivative(Default)] + Ok(Test), + + E(TestException), +} + +impl ::pilota::thrift::Message for ServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultRecv", + })?; + match self { + ServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServiceTestResultRecv::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultRecv::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultRecv", + }) + match self { + ServiceTestResultRecv::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + ServiceTestResultRecv::E(ref value) => __protocol.struct_field_len(Some(1), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultSend.rs new file mode 100644 index 00000000..2f5a5c14 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/enum_servicetestResultSend.rs @@ -0,0 +1,178 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum ServiceTestResultSend { + #[derivative(Default)] + Ok(Test), + + E(TestException), +} + +impl ::pilota::thrift::Message for ServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultSend", + })?; + match self { + ServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + ServiceTestResultSend::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(ServiceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(ServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(ServiceTestResultSend::E(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestResultSend", + }) + match self { + ServiceTestResultSend::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + ServiceTestResultSend::E(ref value) => __protocol.struct_field_len(Some(1), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/gen.rs new file mode 100644 index 00000000..4f95482c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/gen.rs @@ -0,0 +1,43 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod auto_name { + include!("src/message_TEST.rs"); + include!("src/service_service.rs"); + include!("src/enum_serviceTest2ResultRecv.rs"); + include!("src/message_servicetestArgsSend.rs"); + include!("src/service_Service.rs"); + include!("src/enum_ServiceTest2ResultRecv.rs"); + include!("src/message_ServicetestArgsSend.rs"); + include!("src/message_TestException.rs"); + include!("src/enum_Index.rs"); + include!("src/const_ip.rs"); + include!("src/message_serviceTest2ArgsSend.rs"); + include!("src/message_serviceTestArgsSend.rs"); + include!("src/message_servicetestArgsRecv.rs"); + include!("src/enum_servicetestException.rs"); + include!("src/enum_servicetestResultSend.rs"); + include!("src/enum_servicetestResultRecv.rs"); + include!("src/message_ServiceTest2ArgsSend.rs"); + include!("src/message_ServiceTestArgsSend.rs"); + include!("src/message_ServicetestArgsRecv.rs"); + include!("src/enum_ServicetestException.rs"); + include!("src/enum_ServicetestResultSend.rs"); + include!("src/enum_ServicetestResultRecv.rs"); + include!("src/const_IP.rs"); + include!("src/message_serviceTest2ArgsRecv.rs"); + include!("src/enum_serviceTest2ResultSend.rs"); + include!("src/message_serviceTestArgsRecv.rs"); + include!("src/enum_serviceTestException.rs"); + include!("src/enum_serviceTestResultSend.rs"); + include!("src/enum_serviceTestResultRecv.rs"); + include!("src/message_ServiceTest2ArgsRecv.rs"); + include!("src/enum_ServiceTest2ResultSend.rs"); + include!("src/message_ServiceTestArgsRecv.rs"); + include!("src/enum_ServiceTestException.rs"); + include!("src/enum_ServiceTestResultSend.rs"); + include!("src/enum_ServiceTestResultRecv.rs"); + include!("src/message_Test.rs"); + } + pub use auto_name::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TEST.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TEST.rs new file mode 100644 index 00000000..0d8b2dd0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TEST.rs @@ -0,0 +1,176 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Test { + pub ID: ::pilota::FastStr, + + pub Id: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for Test { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.ID).clone())?; + __protocol.write_faststr_field(2, (&self.Id).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ID is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Id is required".to_string(), + )); + }; + + let data = Self { + ID: var_1, + Id: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field ID is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Id is required".to_string(), + )); + }; + + let data = Self { + ID: var_1, + Id: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + + __protocol.faststr_field_len(Some(1), &self.ID) + + __protocol.faststr_field_len(Some(2), &self.Id) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TestException.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TestException.rs new file mode 100644 index 00000000..4036fea4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_TestException.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestException {} +impl ::pilota::thrift::Message for TestException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestException", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestException", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsRecv.rs new file mode 100644 index 00000000..bef48c58 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ServiceTest2ArgsRecv { + pub r#type: TEST, +} +impl ::pilota::thrift::Message for ServiceTest2ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.r#type) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsSend.rs new file mode 100644 index 00000000..bca0ccd6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_serviceTest2ArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ServiceTest2ArgsSend { + pub r#type: TEST, +} +impl ::pilota::thrift::Message for ServiceTest2ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTest2ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + + let data = Self { r#type: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTest2ArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.r#type) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsRecv.rs new file mode 100644 index 00000000..efec557e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ServiceTestArgsRecv { + pub req: TEST, +} +impl ::pilota::thrift::Message for ServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsSend.rs new file mode 100644 index 00000000..772d8aa3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/message_servicetestArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct ServiceTestArgsSend { + pub req: TEST, +} +impl ::pilota::thrift::Message for ServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/service_service.rs b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/service_service.rs new file mode 100644 index 00000000..f517f142 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/auto_name/auto_name/src/service_service.rs @@ -0,0 +1,2 @@ + +pub trait Service {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift new file mode 100644 index 00000000..48422250 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/Cargo.toml new file mode 100644 index 00000000..f1fc84a1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["binary_bytes"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/Cargo.toml new file mode 100644 index 00000000..6c087b8d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "binary_bytes" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/gen.rs new file mode 100644 index 00000000..2af4c501 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/gen.rs @@ -0,0 +1,8 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod binary_bytes { + include!("src/message_A.rs"); + } + pub use binary_bytes::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/message_A.rs new file mode 100644 index 00000000..bb8d7e93 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/binary_bytes/binary_bytes/src/message_A.rs @@ -0,0 +1,176 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub bytes: ::pilota::Bytes, + + pub vec: ::std::vec::Vec, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.bytes).clone())?; + __protocol.write_bytes_vec_field(2, &self.vec)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_bytes_vec()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_bytes_vec().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.bytes_field_len(Some(1), &self.bytes) + + __protocol.bytes_vec_field_len(Some(2), &self.vec) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift b/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift new file mode 100644 index 00000000..ff758be7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0, + B = 1, +} + +const map TEST_MAP = { + Index.A: "hello", + Index.B: "world", +}; + + +const list TEST_LIST = [ + "hello", + "world", +]; + + +const map> TEST_MAP_LIST = { + 1: ["hello"] +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/const_val/Cargo.toml new file mode 100644 index 00000000..6771b1c3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["const_val"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/Cargo.toml new file mode 100644 index 00000000..d76cc391 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "const_val" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_LIST.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_LIST.rs new file mode 100644 index 00000000..616ff9bd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_LIST.rs @@ -0,0 +1 @@ +pub const TEST_LIST: [&'static str; 2] = ["hello", "world"]; diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP.rs new file mode 100644 index 00000000..31c63bbd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP.rs @@ -0,0 +1,8 @@ + +::pilota::lazy_static::lazy_static! { + pub static ref TEST_MAP: ::pilota::AHashMap = { + let mut map = ::pilota::AHashMap::with_capacity(2); + map.insert(Index::A, "hello");map.insert(Index::B, "world"); + map +}; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP_LIST.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP_LIST.rs new file mode 100644 index 00000000..88f15755 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/const_TEST_MAP_LIST.rs @@ -0,0 +1,8 @@ + +::pilota::lazy_static::lazy_static! { + pub static ref TEST_MAP_LIST: ::pilota::AHashMap> = { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(1i32, ::std::vec!["hello"]); + map +}; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/enum_Index.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/enum_Index.rs new file mode 100644 index 00000000..558abf9f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/enum_Index.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Index(i32); + +impl Index { + pub const A: Self = Self(0); + pub const B: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/gen.rs new file mode 100644 index 00000000..1325f1f7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/gen.rs @@ -0,0 +1,11 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod const_val { + include!("src/enum_Index.rs"); + include!("src/const_TEST_MAP_LIST.rs"); + include!("src/const_TEST_LIST.rs"); + include!("src/const_TEST_MAP.rs"); + } + pub use const_val::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/const_val/const_val/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift b/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift new file mode 100644 index 00000000..003193aa --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error.thrift @@ -0,0 +1,14 @@ + + + +struct A { + 1: required B b, +} + +struct B { + 2: required C c, +} + +struct C { + 3: required string a, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/decode_error/Cargo.toml new file mode 100644 index 00000000..ccb7d65b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["decode_error"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/Cargo.toml new file mode 100644 index 00000000..afcb6003 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "decode_error" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/gen.rs new file mode 100644 index 00000000..5be93e64 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/gen.rs @@ -0,0 +1,10 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod decode_error { + include!("src/message_A.rs"); + include!("src/message_B.rs"); + include!("src/message_C.rs"); + } + pub use decode_error::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_A.rs new file mode 100644 index 00000000..4bc59414 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_A.rs @@ -0,0 +1,148 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub b: B, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.b, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field b is required".to_string(), + )); + }; + + let data = Self { b: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol).await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field b is required".to_string(), + )); + }; + + let data = Self { b: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.struct_field_len(Some(1), &self.b) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_B.rs b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_B.rs new file mode 100644 index 00000000..0c18653a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_B.rs @@ -0,0 +1,148 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct B { + pub c: C, +} +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(2, &self.c, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field c is required".to_string(), + )); + }; + + let data = Self { c: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some( + ::decode_async(__protocol).await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field c is required".to_string(), + )); + }; + + let data = Self { c: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + __protocol.struct_field_len(Some(2), &self.c) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_C.rs b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_C.rs new file mode 100644 index 00000000..eec66296 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/decode_error/decode_error/src/message_C.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct C { + pub a: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(3, (&self.a).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field a is required".to_string(), + )); + }; + + let data = Self { a: var_3 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field a is required".to_string(), + )); + }; + + let data = Self { a: var_3 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + __protocol.faststr_field_len(Some(3), &self.a) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift b/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift new file mode 100644 index 00000000..9db807a4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value.thrift @@ -0,0 +1,29 @@ +enum B { + Read = 1; + Write = 2; +} + +const string A_S = "string"; + +struct A { + 1: required string faststr = "hello world", + 2: required string string = "test"(pilota.rust_type = "string"), + 3: optional bool a = false, + 4: optional B test_b = B.Read, + 5: optional B test_b2 = 2, + 6: optional i8 test_b3 = B.Read, + 7: optional map map = {"hello": "world"}, + 8: optional double test_double = 1, + 9: optional double test_double2 = 1.2, + 10: optional string alias_str = A_S, + 11: required binary empty = "", + 12: required map test_map = {1.0: 2.0}, + 13: required set test_set = [1.0], + 14: bool a2 = 3, + 15: map map2 = [], + } + +struct C { + 1: string off = "off", + 2: optional byte test_byte = 0, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/default_value/Cargo.toml new file mode 100644 index 00000000..983f2173 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["default_value"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/Cargo.toml new file mode 100644 index 00000000..dbe4eae4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "default_value" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/const_A_S.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/const_A_S.rs new file mode 100644 index 00000000..d905a114 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/const_A_S.rs @@ -0,0 +1 @@ +pub const A_S: &'static str = "string"; diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/enum_B.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/enum_B.rs new file mode 100644 index 00000000..fd653b4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/enum_B.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct B(i32); + +impl B { + pub const READ: Self = Self(1); + pub const WRITE: Self = Self(2); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("READ"), + Self(2) => ::std::string::String::from("WRITE"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for B { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: B) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/gen.rs new file mode 100644 index 00000000..94213511 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/gen.rs @@ -0,0 +1,11 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + include!("src/enum_B.rs"); + include!("src/message_C.rs"); + include!("src/message_A.rs"); + include!("src/const_A_S.rs"); + } + pub use default_value::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_A.rs new file mode 100644 index 00000000..e7b391fe --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_A.rs @@ -0,0 +1,610 @@ + +impl Default for A { + fn default() -> Self { + A { + faststr: ::pilota::FastStr::from_static_str("hello world"), + string: "test".to_string(), + a: Some(false), + test_b: Some(B::READ), + test_b2: Some(B::WRITE), + test_b3: Some((B::READ.inner() as i8)), + map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }), + test_double: Some(1f64), + test_double2: Some(1.2f64), + alias_str: Some(::pilota::FastStr::from_static_str(A_S)), + empty: ::pilota::Bytes::from_static("".as_bytes()), + test_map: { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }, + test_set: ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]), + a2: Some(true), + map2: Some(::pilota::AHashMap::new()), + } + } +} +#[derive(Debug, Clone, PartialEq)] +pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, + + pub a: ::std::option::Option, + + pub test_b: ::std::option::Option, + + pub test_b2: ::std::option::Option, + + pub test_b3: ::std::option::Option, + + pub map: ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + + pub test_double: ::std::option::Option, + + pub test_double2: ::std::option::Option, + + pub alias_str: ::std::option::Option<::pilota::FastStr>, + + pub empty: ::pilota::Bytes, + + pub test_map: ::pilota::AHashMap<::pilota::OrderedFloat, f64>, + + pub test_set: ::pilota::AHashSet<::pilota::OrderedFloat>, + + pub a2: ::std::option::Option, + + pub map2: ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_bool_field(3, *value)?; + } + if let Some(value) = self.test_b.as_ref() { + __protocol.write_i32_field(4, (value).inner())?; + } + if let Some(value) = self.test_b2.as_ref() { + __protocol.write_i32_field(5, (value).inner())?; + } + if let Some(value) = self.test_b3.as_ref() { + __protocol.write_i8_field(6, *value)?; + } + if let Some(value) = self.map.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.test_double.as_ref() { + __protocol.write_double_field(8, *value)?; + } + if let Some(value) = self.test_double2.as_ref() { + __protocol.write_double_field(9, *value)?; + } + if let Some(value) = self.alias_str.as_ref() { + __protocol.write_faststr_field(10, (value).clone())?; + } + __protocol.write_bytes_field(11, (&self.empty).clone())?; + __protocol.write_map_field( + 12, + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &&self.test_map, + |__protocol, key| { + __protocol.write_double(key.0)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_double(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_set_field( + 13, + ::pilota::thrift::TType::Double, + &&self.test_set, + |__protocol, val| { + __protocol.write_double(val.0)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.a2.as_ref() { + __protocol.write_bool_field(14, *value)?; + } + if let Some(value) = self.map2.as_ref() { + __protocol.write_map_field( + 15, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = __protocol.read_faststr()?; + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8()?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_8 = Some(__protocol.read_double()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_9 = Some(__protocol.read_double()?); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_10 = Some(__protocol.read_faststr()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = __protocol.read_bytes()?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double()?), + __protocol.read_double()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat(__protocol.read_double()?)); + } + __protocol.read_set_end()?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool()?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = + var_13.unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = __protocol.read_faststr().await?; + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool().await?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some( + ::decode_async(__protocol).await?, + ); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some( + ::decode_async(__protocol).await?, + ); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8().await?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_8 = Some(__protocol.read_double().await?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_9 = Some(__protocol.read_double().await?); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_10 = Some(__protocol.read_faststr().await?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = __protocol.read_bytes().await?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double().await?), + __protocol.read_double().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double().await?, + )); + } + __protocol.read_set_end().await?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool().await?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = + var_13.unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(3), *value)) + + self.test_b.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(4), (value).inner()) + }) + + self.test_b2.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(5), (value).inner()) + }) + + self + .test_b3 + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(6), *value)) + + self.map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + self + .test_double + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(8), *value)) + + self + .test_double2 + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(9), *value)) + + self + .alias_str + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(10), value)) + + __protocol.bytes_field_len(Some(11), &self.empty) + + __protocol.map_field_len( + Some(12), + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &self.test_map, + |__protocol, key| __protocol.double_len(key.0), + |__protocol, val| __protocol.double_len(*val), + ) + + __protocol.set_field_len( + Some(13), + ::pilota::thrift::TType::Double, + &self.test_set, + |__protocol, el| __protocol.double_len(el.0), + ) + + self + .a2 + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(14), *value)) + + self.map2.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(15), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_C.rs b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_C.rs new file mode 100644 index 00000000..ccb08b53 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/default_value/default_value/src/message_C.rs @@ -0,0 +1,169 @@ + +impl Default for C { + fn default() -> Self { + C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Some(0i8), + } + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] +pub struct C { + pub off: ::std::option::Option<::pilota::FastStr>, + + pub test_byte: ::std::option::Option, +} +impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.off.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.test_byte.as_ref() { + __protocol.write_i8_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self + .off + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .test_byte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift b/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift new file mode 100644 index 00000000..16675284 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map.thrift @@ -0,0 +1,14 @@ +typedef i32 TypeB + +const TypeB TypeB1 = 1 +const TypeB TypeB2 = 2 + +typedef string TypeA + +const TypeA TypeA1 = "a1" +const TypeA TypeA2 = "a2" + +const map TypeAMap = { + TypeB1: TypeA1, + TypeB2: TypeA2, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/enum_map/Cargo.toml new file mode 100644 index 00000000..81b15212 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["enum_map"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/Cargo.toml new file mode 100644 index 00000000..b323b400 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "enum_map" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA1.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA1.rs new file mode 100644 index 00000000..8002fe30 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA1.rs @@ -0,0 +1 @@ +pub const TYPE_A1: TypeA = TypeA(::pilota::FastStr::from_static_str("a1")); diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA2.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA2.rs new file mode 100644 index 00000000..d27ac743 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeA2.rs @@ -0,0 +1 @@ +pub const TYPE_A2: TypeA = TypeA(::pilota::FastStr::from_static_str("a2")); diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeAMap.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeAMap.rs new file mode 100644 index 00000000..529c956c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeAMap.rs @@ -0,0 +1,8 @@ + +::pilota::lazy_static::lazy_static! { + pub static ref TYPE_A_MAP: ::pilota::AHashMap = { + let mut map = ::pilota::AHashMap::with_capacity(2); + map.insert(TYPE_B1, TYPE_A1);map.insert(TYPE_B2, TYPE_A2); + map +}; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB1.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB1.rs new file mode 100644 index 00000000..a46e11dd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB1.rs @@ -0,0 +1 @@ +pub const TYPE_B1: TypeB = TypeB(1i32); diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB2.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB2.rs new file mode 100644 index 00000000..d3a19354 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/const_TypeB2.rs @@ -0,0 +1 @@ +pub const TYPE_B2: TypeB = TypeB(2i32); diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/gen.rs new file mode 100644 index 00000000..c92c7b7c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/gen.rs @@ -0,0 +1,14 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod enum_map { + include!("src/new_type_TypeB.rs"); + include!("src/const_TypeA2.rs"); + include!("src/const_TypeB2.rs"); + include!("src/const_TypeA1.rs"); + include!("src/const_TypeB1.rs"); + include!("src/const_TypeAMap.rs"); + include!("src/new_type_TypeA.rs"); + } + pub use enum_map::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeA.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeA.rs new file mode 100644 index 00000000..c694424d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeA.rs @@ -0,0 +1,57 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TypeA(pub ::pilota::FastStr); + +impl ::std::ops::Deref for TypeA { + type Target = ::pilota::FastStr; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From<::pilota::FastStr> for TypeA { + fn from(v: ::pilota::FastStr) -> Self { + Self(v) + } +} + +impl ::pilota::thrift::Message for TypeA { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_faststr((&**self).clone())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(TypeA(__protocol.read_faststr()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(TypeA(__protocol.read_faststr().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.faststr_len(&**self) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeB.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeB.rs new file mode 100644 index 00000000..81959b9d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_map/enum_map/src/new_type_TypeB.rs @@ -0,0 +1,57 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TypeB(pub i32); + +impl ::std::ops::Deref for TypeB { + type Target = i32; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl From for TypeB { + fn from(v: i32) -> Self { + Self(v) + } +} + +impl ::pilota::thrift::Message for TypeB { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(*(&**self))?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + ::std::result::Result::Ok(TypeB(__protocol.read_i32()?)) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + ::std::result::Result::Ok(TypeB(__protocol.read_i32().await?)) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(*&**self) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift b/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift new file mode 100644 index 00000000..d0cbb42e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test.thrift @@ -0,0 +1,20 @@ +enum Index { + A = 0x01, + B = 0x10, +} + +enum Err { + +} + +enum Ok { +} + +struct Request { + 1: required Index Index, + 2: Index index, +} +service Test { + Err test_enum(1: Ok req); + Err test_enum_var_type_name_conflict (1: Request req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/enum_test/Cargo.toml new file mode 100644 index 00000000..2a0d1a05 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["enum_test"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/Cargo.toml new file mode 100644 index 00000000..3cd297ac --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "enum_test" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Err.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Err.rs new file mode 100644 index 00000000..76566729 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Err.rs @@ -0,0 +1,80 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Err(i32); + +impl Err { + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Err { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Err) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Err { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Err, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Err, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Index.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Index.rs new file mode 100644 index 00000000..915d2ddb --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Index.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Index(i32); + +impl Index { + pub const A: Self = Self(1); + pub const B: Self = Self(16); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("A"), + Self(16) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Ok.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Ok.rs new file mode 100644 index 00000000..7b6e767f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_Ok.rs @@ -0,0 +1,80 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Ok(i32); + +impl Ok { + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Ok { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Ok) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Ok { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Ok, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Ok, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultRecv.rs new file mode 100644 index 00000000..cd3fba26 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultRecv.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestEnumResultRecv { + #[derivative(Default)] + Ok(Err), +} + +impl ::pilota::thrift::Message for TestTestEnumResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultRecv", + })?; + match self { + TestTestEnumResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestEnumResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultRecv", + }) + match self { + TestTestEnumResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultSend.rs new file mode 100644 index 00000000..188e5a97 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumResultSend.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestEnumResultSend { + #[derivative(Default)] + Ok(Err), +} + +impl ::pilota::thrift::Message for TestTestEnumResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultSend", + })?; + match self { + TestTestEnumResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestEnumResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumResultSend", + }) + match self { + TestTestEnumResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultRecv.rs new file mode 100644 index 00000000..f33779a2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultRecv.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestEnumVarTypeNameConflictResultRecv { + #[derivative(Default)] + Ok(Err), +} + +impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultRecv", + })?; + match self { + TestTestEnumVarTypeNameConflictResultRecv::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumVarTypeNameConflictResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestEnumVarTypeNameConflictResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultRecv", + }) + match self { + TestTestEnumVarTypeNameConflictResultRecv::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultSend.rs new file mode 100644 index 00000000..ab2106d0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/enum_TestTestEnumVarTypeNameConflictResultSend.rs @@ -0,0 +1,142 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestEnumVarTypeNameConflictResultSend { + #[derivative(Default)] + Ok(Err), +} + +impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultSend", + })?; + match self { + TestTestEnumVarTypeNameConflictResultSend::Ok(ref value) => { + __protocol.write_i32_field(0, (value).inner())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestEnumVarTypeNameConflictResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestEnumVarTypeNameConflictResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictResultSend", + }) + match self { + TestTestEnumVarTypeNameConflictResultSend::Ok(ref value) => { + __protocol.i32_field_len(Some(0), (value).inner()) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/gen.rs new file mode 100644 index 00000000..79a8be23 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/gen.rs @@ -0,0 +1,20 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod enum_test { + include!("src/message_TestTestEnumVarTypeNameConflictArgsSend.rs"); + include!("src/enum_Index.rs"); + include!("src/message_TestTestEnumArgsSend.rs"); + include!("src/enum_Ok.rs"); + include!("src/message_TestTestEnumVarTypeNameConflictArgsRecv.rs"); + include!("src/enum_TestTestEnumVarTypeNameConflictResultSend.rs"); + include!("src/message_TestTestEnumArgsRecv.rs"); + include!("src/enum_TestTestEnumResultSend.rs"); + include!("src/message_Request.rs"); + include!("src/service_Test.rs"); + include!("src/enum_TestTestEnumVarTypeNameConflictResultRecv.rs"); + include!("src/enum_TestTestEnumResultRecv.rs"); + include!("src/enum_Err.rs"); + } + pub use enum_test::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_Request.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_Request.rs new file mode 100644 index 00000000..dd0b17fd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_Request.rs @@ -0,0 +1,174 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Request { + pub Index: Index, + + pub index: ::std::option::Option, +} +impl ::pilota::thrift::Message for Request { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Request" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.Index).inner())?; + if let Some(value) = self.index.as_ref() { + __protocol.write_i32_field(2, (value).inner())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Request` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Index is required".to_string(), + )); + }; + + let data = Self { + Index: var_1, + index: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_2 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Request` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field Index is required".to_string(), + )); + }; + + let data = Self { + Index: var_1, + index: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Request" }) + + __protocol.i32_field_len(Some(1), (&self.Index).inner()) + + self.index.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(2), (value).inner()) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsRecv.rs new file mode 100644 index 00000000..2af0c277 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsRecv.rs @@ -0,0 +1,151 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTestEnumArgsRecv { + pub req: Ok, +} +impl ::pilota::thrift::Message for TestTestEnumArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.req).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some( + ::decode_async(__protocol).await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsRecv", + }) + __protocol.i32_field_len(Some(1), (&self.req).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsSend.rs new file mode 100644 index 00000000..6580d1ce --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumArgsSend.rs @@ -0,0 +1,151 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTestEnumArgsSend { + pub req: Ok, +} +impl ::pilota::thrift::Message for TestTestEnumArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_i32_field(1, (&self.req).inner())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some( + ::decode_async(__protocol).await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestEnumArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumArgsSend", + }) + __protocol.i32_field_len(Some(1), (&self.req).inner()) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsRecv.rs new file mode 100644 index 00000000..33245bd9 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsRecv.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTestEnumVarTypeNameConflictArgsRecv { + pub req: Request, +} +impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsRecv` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsSend.rs new file mode 100644 index 00000000..adb1e81f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/message_TestTestEnumVarTypeNameConflictArgsSend.rs @@ -0,0 +1,146 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTestEnumVarTypeNameConflictArgsSend { + pub req: Request, +} +impl ::pilota::thrift::Message for TestTestEnumVarTypeNameConflictArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `TestTestEnumVarTypeNameConflictArgsSend` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestEnumVarTypeNameConflictArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/service_Test.rs b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/service_Test.rs new file mode 100644 index 00000000..0d0c0588 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/enum_test/enum_test/src/service_Test.rs @@ -0,0 +1,2 @@ + +pub trait Test {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi.thrift b/pilota-build/test_data/thrift_workspace_with_split/multi.thrift new file mode 100644 index 00000000..cc3fb25c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi.thrift @@ -0,0 +1,11 @@ +include "default_value.thrift" +include "recursive_type.thrift" + +struct A { + 1: default_value.C c = {"off": "off"}, +} + +struct B { + 1: recursive_type.A a, + 2: recursive_type.C c, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/multi/Cargo.toml new file mode 100644 index 00000000..2f78d8c3 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ "common","multi"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/multi/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/const_A_S.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/const_A_S.rs new file mode 100644 index 00000000..d905a114 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/const_A_S.rs @@ -0,0 +1 @@ +pub const A_S: &'static str = "string"; diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/enum_B.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/enum_B.rs new file mode 100644 index 00000000..fd653b4d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/enum_B.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct B(i32); + +impl B { + pub const READ: Self = Self(1); + pub const WRITE: Self = Self(2); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(1) => ::std::string::String::from("READ"), + Self(2) => ::std::string::String::from("WRITE"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for B { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: B) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for B, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/gen.rs new file mode 100644 index 00000000..77db97f5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/gen.rs @@ -0,0 +1,16 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + include!("src/message_C.rs"); + include!("src/const_A_S.rs"); + include!("src/enum_B.rs"); + include!("src/message_A.rs"); + } + + pub mod recursive_type { + include!("src/message_C.rs"); + include!("src/message_A.rs"); + include!("src/message_B.rs"); + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_A.rs new file mode 100644 index 00000000..e7b391fe --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_A.rs @@ -0,0 +1,610 @@ + +impl Default for A { + fn default() -> Self { + A { + faststr: ::pilota::FastStr::from_static_str("hello world"), + string: "test".to_string(), + a: Some(false), + test_b: Some(B::READ), + test_b2: Some(B::WRITE), + test_b3: Some((B::READ.inner() as i8)), + map: Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }), + test_double: Some(1f64), + test_double2: Some(1.2f64), + alias_str: Some(::pilota::FastStr::from_static_str(A_S)), + empty: ::pilota::Bytes::from_static("".as_bytes()), + test_map: { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }, + test_set: ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)]), + a2: Some(true), + map2: Some(::pilota::AHashMap::new()), + } + } +} +#[derive(Debug, Clone, PartialEq)] +pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, + + pub a: ::std::option::Option, + + pub test_b: ::std::option::Option, + + pub test_b2: ::std::option::Option, + + pub test_b3: ::std::option::Option, + + pub map: ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, + + pub test_double: ::std::option::Option, + + pub test_double2: ::std::option::Option, + + pub alias_str: ::std::option::Option<::pilota::FastStr>, + + pub empty: ::pilota::Bytes, + + pub test_map: ::pilota::AHashMap<::pilota::OrderedFloat, f64>, + + pub test_set: ::pilota::AHashSet<::pilota::OrderedFloat>, + + pub a2: ::std::option::Option, + + pub map2: ::std::option::Option<::pilota::AHashMap<::pilota::FastStr, ::pilota::FastStr>>, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_bool_field(3, *value)?; + } + if let Some(value) = self.test_b.as_ref() { + __protocol.write_i32_field(4, (value).inner())?; + } + if let Some(value) = self.test_b2.as_ref() { + __protocol.write_i32_field(5, (value).inner())?; + } + if let Some(value) = self.test_b3.as_ref() { + __protocol.write_i8_field(6, *value)?; + } + if let Some(value) = self.map.as_ref() { + __protocol.write_map_field( + 7, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + if let Some(value) = self.test_double.as_ref() { + __protocol.write_double_field(8, *value)?; + } + if let Some(value) = self.test_double2.as_ref() { + __protocol.write_double_field(9, *value)?; + } + if let Some(value) = self.alias_str.as_ref() { + __protocol.write_faststr_field(10, (value).clone())?; + } + __protocol.write_bytes_field(11, (&self.empty).clone())?; + __protocol.write_map_field( + 12, + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &&self.test_map, + |__protocol, key| { + __protocol.write_double(key.0)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_double(*val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_set_field( + 13, + ::pilota::thrift::TType::Double, + &&self.test_set, + |__protocol, val| { + __protocol.write_double(val.0)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.a2.as_ref() { + __protocol.write_bool_field(14, *value)?; + } + if let Some(value) = self.map2.as_ref() { + __protocol.write_map_field( + 15, + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, key| { + __protocol.write_faststr((key).clone())?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = __protocol.read_faststr()?; + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool()?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8()?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_8 = Some(__protocol.read_double()?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_9 = Some(__protocol.read_double()?); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_10 = Some(__protocol.read_faststr()?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = __protocol.read_bytes()?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double()?), + __protocol.read_double()?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat(__protocol.read_double()?)); + } + __protocol.read_set_end()?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool()?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_faststr()?, __protocol.read_faststr()?); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = + var_13.unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = ::pilota::FastStr::from_static_str("hello world"); + let mut var_2 = None; + let mut var_3 = Some(false); + let mut var_4 = Some(B::READ); + let mut var_5 = Some(B::WRITE); + let mut var_6 = Some((B::READ.inner() as i8)); + let mut var_7 = None; + let mut var_8 = Some(1f64); + let mut var_9 = Some(1.2f64); + let mut var_10 = Some(::pilota::FastStr::from_static_str(A_S)); + let mut var_11 = ::pilota::Bytes::from_static("".as_bytes()); + let mut var_12 = None; + let mut var_13 = None; + let mut var_14 = Some(true); + let mut var_15 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = __protocol.read_faststr().await?; + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_3 = Some(__protocol.read_bool().await?); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_4 = Some( + ::decode_async(__protocol).await?, + ); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_5 = Some( + ::decode_async(__protocol).await?, + ); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_6 = Some(__protocol.read_i8().await?); + } + Some(7) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_7 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(8) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_8 = Some(__protocol.read_double().await?); + } + Some(9) if field_ident.field_type == ::pilota::thrift::TType::Double => { + var_9 = Some(__protocol.read_double().await?); + } + Some(10) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_10 = Some(__protocol.read_faststr().await?); + } + Some(11) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_11 = __protocol.read_bytes().await?; + } + Some(12) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_12 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::OrderedFloat(__protocol.read_double().await?), + __protocol.read_double().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(13) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_13 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::OrderedFloat( + __protocol.read_double().await?, + )); + } + __protocol.read_set_end().await?; + val + }); + } + Some(14) if field_ident.field_type == ::pilota::thrift::TType::Bool => { + var_14 = Some(__protocol.read_bool().await?); + } + Some(15) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_15 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + __protocol.read_faststr().await?, + __protocol.read_faststr().await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let var_2 = var_2.unwrap_or_else(|| "test".to_string()); + if var_7.is_none() { + var_7 = Some({ + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert( + ::pilota::FastStr::from_static_str("hello"), + ::pilota::FastStr::from_static_str("world"), + ); + map + }); + } + let var_12 = var_12.unwrap_or_else(|| { + let mut map = ::pilota::AHashMap::with_capacity(1); + map.insert(::pilota::OrderedFloat(1f64), 2f64); + map + }); + let var_13 = + var_13.unwrap_or_else(|| ::pilota::AHashSet::from([::pilota::OrderedFloat(1f64)])); + if var_15.is_none() { + var_15 = Some(::pilota::AHashMap::new()); + } + + let data = Self { + faststr: var_1, + string: var_2, + a: var_3, + test_b: var_4, + test_b2: var_5, + test_b3: var_6, + map: var_7, + test_double: var_8, + test_double2: var_9, + alias_str: var_10, + empty: var_11, + test_map: var_12, + test_set: var_13, + a2: var_14, + map2: var_15, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(3), *value)) + + self.test_b.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(4), (value).inner()) + }) + + self.test_b2.as_ref().map_or(0, |value| { + __protocol.i32_field_len(Some(5), (value).inner()) + }) + + self + .test_b3 + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(6), *value)) + + self.map.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(7), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + self + .test_double + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(8), *value)) + + self + .test_double2 + .as_ref() + .map_or(0, |value| __protocol.double_field_len(Some(9), *value)) + + self + .alias_str + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(10), value)) + + __protocol.bytes_field_len(Some(11), &self.empty) + + __protocol.map_field_len( + Some(12), + ::pilota::thrift::TType::Double, + ::pilota::thrift::TType::Double, + &self.test_map, + |__protocol, key| __protocol.double_len(key.0), + |__protocol, val| __protocol.double_len(*val), + ) + + __protocol.set_field_len( + Some(13), + ::pilota::thrift::TType::Double, + &self.test_set, + |__protocol, el| __protocol.double_len(el.0), + ) + + self + .a2 + .as_ref() + .map_or(0, |value| __protocol.bool_field_len(Some(14), *value)) + + self.map2.as_ref().map_or(0, |value| { + __protocol.map_field_len( + Some(15), + ::pilota::thrift::TType::Binary, + ::pilota::thrift::TType::Binary, + value, + |__protocol, key| __protocol.faststr_len(key), + |__protocol, val| __protocol.faststr_len(val), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_B.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_B.rs new file mode 100644 index 00000000..eb6bb64a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_B.rs @@ -0,0 +1,141 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct B { + pub b_a: ::std::option::Option<::std::boxed::Box>, +} +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b_a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new(::pilota::thrift::Message::decode( + __protocol, + )?)); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol).await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .b_a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_C.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_C.rs new file mode 100644 index 00000000..ccb08b53 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/common/src/message_C.rs @@ -0,0 +1,169 @@ + +impl Default for C { + fn default() -> Self { + C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Some(0i8), + } + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] +pub struct C { + pub off: ::std::option::Option<::pilota::FastStr>, + + pub test_byte: ::std::option::Option, +} +impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.off.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + if let Some(value) = self.test_byte.as_ref() { + __protocol.write_i8_field(2, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = Some(::pilota::FastStr::from_static_str("off")); + let mut var_2 = Some(0i8); + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::I8 => { + var_2 = Some(__protocol.read_i8().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + off: var_1, + test_byte: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self + .off + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + self + .test_byte + .as_ref() + .map_or(0, |value| __protocol.i8_field_len(Some(2), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/Cargo.toml new file mode 100644 index 00000000..60675327 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/Cargo.toml @@ -0,0 +1,19 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.common] +path = "../common" + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "multi" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/gen.rs new file mode 100644 index 00000000..e2a287b0 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/gen.rs @@ -0,0 +1,19 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod default_value { + include!("src/message_C.rs"); + } + + pub mod multi { + include!("src/message_A.rs"); + include!("src/message_B.rs"); + } + + pub mod recursive_type { + include!("src/message_A.rs"); + include!("src/message_C.rs"); + include!("src/message_B.rs"); + } + pub use multi::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_A.rs new file mode 100644 index 00000000..2ccc966d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_A.rs @@ -0,0 +1,165 @@ + +impl Default for A { + fn default() -> Self { + A { + c: Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }), + } + } +} +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] +pub struct A { + pub c: ::std::option::Option<::common::default_value::C>, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.c.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + if var_1.is_none() { + var_1 = Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }); + } + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + + + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + + break; + } else { + + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(<::common::default_value::C as ::pilota::thrift::Message>::decode_async(__protocol).await?); + + }, + _ => { + __protocol.skip(field_ident.field_type).await?; + + }, + } + + __protocol.read_field_end().await?; + + + }; + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + }.await { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!("decode struct `A` field(#{}) failed, caused by: ", field_id)); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + if var_1.is_none() { + var_1 = Some(::common::default_value::C { + off: Some(::pilota::FastStr::from_static_str("off")), + test_byte: Default::default(), + }); + } + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .c + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_B.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_B.rs new file mode 100644 index 00000000..e21ca003 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_B.rs @@ -0,0 +1 @@ +pub use ::common::recursive_type::B; diff --git a/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_C.rs b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_C.rs new file mode 100644 index 00000000..fb24a32b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/multi/multi/src/message_C.rs @@ -0,0 +1 @@ +pub use ::common::recursive_type::C; diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal.thrift b/pilota-build/test_data/thrift_workspace_with_split/normal.thrift new file mode 100644 index 00000000..11699ed6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal.thrift @@ -0,0 +1,37 @@ + + +struct A { + 1: i32 a, +} + +struct b { + 2: A a, +} + +struct SubMessage { + 2: optional string value; +} + +struct Message { + 1: uuid uid; + 2: optional string value; + 3: optional list subMessages; +} + +struct ObjReq { + 1: required Message msg + 2: required map msgMap + 3: required list subMsgs + 4: optional set msgSet + 5: required string flagMsg + 6: optional string mockCost, +} + +exception STException { + 1: string message; +} + +service Test { + void test_123(); + ObjReq testException(1: ObjReq req) throws (1: STException stException); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/normal/Cargo.toml new file mode 100644 index 00000000..7f54eb77 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["normal"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/Cargo.toml new file mode 100644 index 00000000..b0679404 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "normal" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultRecv.rs new file mode 100644 index 00000000..8ad4895c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultRecv.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTest123ResultRecv { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for TestTest123ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + })?; + match self { + TestTest123ResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + }) + match self { + TestTest123ResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultSend.rs new file mode 100644 index 00000000..7b6300c2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTest123ResultSend.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTest123ResultSend { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for TestTest123ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + })?; + match self { + TestTest123ResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + }) + match self { + TestTest123ResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionException.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionException.rs new file mode 100644 index 00000000..3fd9a1a1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionException.rs @@ -0,0 +1,144 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestExceptionException { + #[derivative(Default)] + StException(StException), +} + +impl ::pilota::thrift::Message for TestTestExceptionException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionException", + })?; + match self { + TestTestExceptionException::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionException::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestExceptionException::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionException", + }) + match self { + TestTestExceptionException::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultRecv.rs new file mode 100644 index 00000000..e8ae1a68 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultRecv.rs @@ -0,0 +1,182 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestExceptionResultRecv { + #[derivative(Default)] + Ok(ObjReq), + + StException(StException), +} + +impl ::pilota::thrift::Message for TestTestExceptionResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultRecv", + })?; + match self { + TestTestExceptionResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + TestTestExceptionResultRecv::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultRecv::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestExceptionResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestExceptionResultRecv::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultRecv", + }) + match self { + TestTestExceptionResultRecv::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + TestTestExceptionResultRecv::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultSend.rs new file mode 100644 index 00000000..3d084cd4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/enum_TestTestExceptionResultSend.rs @@ -0,0 +1,182 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTestExceptionResultSend { + #[derivative(Default)] + Ok(ObjReq), + + StException(StException), +} + +impl ::pilota::thrift::Message for TestTestExceptionResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultSend", + })?; + match self { + TestTestExceptionResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + TestTestExceptionResultSend::StException(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestTestExceptionResultSend::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestTestExceptionResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(1) => { + if ret.is_none() { + let field_ident = + ::decode_async( + __protocol, + ) + .await?; + + ret = Some(TestTestExceptionResultSend::StException(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionResultSend", + }) + match self { + TestTestExceptionResultSend::Ok(ref value) => { + __protocol.struct_field_len(Some(0), value) + } + TestTestExceptionResultSend::StException(ref value) => { + __protocol.struct_field_len(Some(1), value) + } + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/gen.rs new file mode 100644 index 00000000..8f148dfd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/gen.rs @@ -0,0 +1,23 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod normal { + include!("src/message_A.rs"); + include!("src/message_TestTestExceptionArgsSend.rs"); + include!("src/message_TestTest123ArgsRecv.rs"); + include!("src/enum_TestTest123ResultSend.rs"); + include!("src/message_STException.rs"); + include!("src/message_SubMessage.rs"); + include!("src/service_Test.rs"); + include!("src/message_TestTest123ArgsSend.rs"); + include!("src/message_ObjReq.rs"); + include!("src/message_b.rs"); + include!("src/message_TestTestExceptionArgsRecv.rs"); + include!("src/enum_TestTestExceptionException.rs"); + include!("src/enum_TestTestExceptionResultSend.rs"); + include!("src/enum_TestTestExceptionResultRecv.rs"); + include!("src/enum_TestTest123ResultRecv.rs"); + include!("src/message_Message.rs"); + } + pub use normal::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_A.rs new file mode 100644 index 00000000..6d236089 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_A.rs @@ -0,0 +1,137 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub a: ::std::option::Option, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_i32_field(1, *value)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::I32 => { + var_1 = Some(__protocol.read_i32().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.i32_field_len(Some(1), *value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_Message.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_Message.rs new file mode 100644 index 00000000..ddd16568 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_Message.rs @@ -0,0 +1,215 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Message { + pub uid: ::std::option::Option<[u8; 16]>, + + pub value: ::std::option::Option<::pilota::FastStr>, + + pub sub_messages: ::std::option::Option<::std::vec::Vec>, +} +impl ::pilota::thrift::Message for Message { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Message" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.uid.as_ref() { + __protocol.write_uuid_field(1, *value)?; + } + if let Some(value) = self.value.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + if let Some(value) = self.sub_messages.as_ref() { + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Message` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + uid: var_1, + value: var_2, + sub_messages: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Uuid => { + var_1 = Some(__protocol.read_uuid().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push( + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_list_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Message` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + uid: var_1, + value: var_2, + sub_messages: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Message" }) + + self + .uid + .as_ref() + .map_or(0, |value| __protocol.uuid_field_len(Some(1), *value)) + + self + .value + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + self.sub_messages.as_ref().map_or(0, |value| { + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_ObjReq.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_ObjReq.rs new file mode 100644 index 00000000..c438c61e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_ObjReq.rs @@ -0,0 +1,387 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct ObjReq { + pub msg: Message, + + pub msg_map: ::pilota::AHashMap, + + pub sub_msgs: ::std::vec::Vec, + + pub msg_set: ::std::option::Option<::pilota::AHashSet>, + + pub flag_msg: ::pilota::FastStr, + + pub mock_cost: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for ObjReq { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "ObjReq" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.msg, ::pilota::thrift::TType::Struct)?; + __protocol.write_map_field( + 2, + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Struct, + &&self.msg_map, + |__protocol, key| { + __protocol.write_struct(key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_list_field( + 3, + ::pilota::thrift::TType::Struct, + &&self.sub_msgs, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + if let Some(value) = self.msg_set.as_ref() { + __protocol.write_set_field( + 4, + ::pilota::thrift::TType::Struct, + &value, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_faststr_field(5, (&self.flag_msg).clone())?; + if let Some(value) = self.mock_cost.as_ref() { + __protocol.write_faststr_field(6, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::pilota::thrift::Message::decode(__protocol)?, + ::pilota::thrift::Message::decode(__protocol)?, + ); + } + __protocol.read_map_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec = Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr() + .offset(i as isize) + .write(::pilota::thrift::Message::decode(__protocol)?); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_4 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(::pilota::thrift::Message::decode(__protocol)?); + } + __protocol.read_set_end()?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_5 = Some(__protocol.read_faststr()?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_6 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ObjReq` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg_map is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field sub_msgs is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field flag_msg is required".to_string(), + )); + }; + + let data = Self { + msg: var_1, + msg_map: var_2, + sub_msgs: var_3, + msg_set: var_4, + flag_msg: var_5, + mock_cost: var_6, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + let mut var_4 = None; + let mut var_5 = None; + let mut var_6 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_2 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert( + ::decode_async( + __protocol, + ) + .await?, + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_map_end().await?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_3 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push( + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_list_end().await?; + val + }); + } + Some(4) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_4 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert( + ::decode_async( + __protocol, + ) + .await?, + ); + } + __protocol.read_set_end().await?; + val + }); + } + Some(5) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_5 = Some(__protocol.read_faststr().await?); + } + Some(6) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_6 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `ObjReq` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field msg_map is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field sub_msgs is required".to_string(), + )); + }; + let Some(var_5) = var_5 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field flag_msg is required".to_string(), + )); + }; + + let data = Self { + msg: var_1, + msg_map: var_2, + sub_msgs: var_3, + msg_set: var_4, + flag_msg: var_5, + mock_cost: var_6, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "ObjReq" }) + + __protocol.struct_field_len(Some(1), &self.msg) + + __protocol.map_field_len( + Some(2), + ::pilota::thrift::TType::Struct, + ::pilota::thrift::TType::Struct, + &self.msg_map, + |__protocol, key| __protocol.struct_len(key), + |__protocol, val| __protocol.struct_len(val), + ) + + __protocol.list_field_len( + Some(3), + ::pilota::thrift::TType::Struct, + &self.sub_msgs, + |__protocol, el| __protocol.struct_len(el), + ) + + self.msg_set.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(4), + ::pilota::thrift::TType::Struct, + value, + |__protocol, el| __protocol.struct_len(el), + ) + }) + + __protocol.faststr_field_len(Some(5), &self.flag_msg) + + self + .mock_cost + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(6), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_STException.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_STException.rs new file mode 100644 index 00000000..771cf3fe --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_STException.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct StException { + pub message: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for StException { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "StException", + }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.message.as_ref() { + __protocol.write_faststr_field(1, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { message: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `StException` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { message: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "StException", + }) + self + .message + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_SubMessage.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_SubMessage.rs new file mode 100644 index 00000000..3a3d3529 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_SubMessage.rs @@ -0,0 +1,137 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct SubMessage { + pub value: ::std::option::Option<::pilota::FastStr>, +} +impl ::pilota::thrift::Message for SubMessage { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "SubMessage" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.value.as_ref() { + __protocol.write_faststr_field(2, (value).clone())?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `SubMessage` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { value: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `SubMessage` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { value: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "SubMessage" }) + + self + .value + .as_ref() + .map_or(0, |value| __protocol.faststr_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsRecv.rs new file mode 100644 index 00000000..8fb4e7e4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsRecv.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTest123ArgsRecv {} +impl ::pilota::thrift::Message for TestTest123ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsSend.rs new file mode 100644 index 00000000..f64a8bd6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTest123ArgsSend.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTest123ArgsSend {} +impl ::pilota::thrift::Message for TestTest123ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsRecv.rs new file mode 100644 index 00000000..5845f513 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct TestTestExceptionArgsRecv { + pub req: ObjReq, +} +impl ::pilota::thrift::Message for TestTestExceptionArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestExceptionArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestExceptionArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsSend.rs new file mode 100644 index 00000000..43593097 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_TestTestExceptionArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct TestTestExceptionArgsSend { + pub req: ObjReq, +} +impl ::pilota::thrift::Message for TestTestExceptionArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestExceptionArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTestExceptionArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTestExceptionArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_b.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_b.rs new file mode 100644 index 00000000..ad323115 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/message_b.rs @@ -0,0 +1,139 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct B { + pub a: ::std::option::Option, +} +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { a: var_2 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some( + ::decode_async(__protocol).await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { a: var_2 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/service_Test.rs b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/service_Test.rs new file mode 100644 index 00000000..0d0c0588 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/normal/normal/src/service_Test.rs @@ -0,0 +1,2 @@ + +pub trait Test {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift b/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift new file mode 100644 index 00000000..00d6e57f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword.thrift @@ -0,0 +1,5 @@ +namespace rs enum; +struct A { + 1: required binary bytes, + 2: required binary vec(pilota.rust_type="vec"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/Cargo.toml new file mode 100644 index 00000000..bc22561f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["path_keyword"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/Cargo.toml new file mode 100644 index 00000000..028187ac --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "path_keyword" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/gen.rs new file mode 100644 index 00000000..08f43aea --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/gen.rs @@ -0,0 +1,8 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod r#enum { + include!("src/message_A.rs"); + } + pub use r#enum::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/message_A.rs new file mode 100644 index 00000000..bb8d7e93 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/path_keyword/path_keyword/src/message_A.rs @@ -0,0 +1,176 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub bytes: ::pilota::Bytes, + + pub vec: ::std::vec::Vec, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_bytes_field(1, (&self.bytes).clone())?; + __protocol.write_bytes_vec_field(2, &self.vec)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_bytes_vec()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_bytes().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_bytes_vec().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field bytes is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field vec is required".to_string(), + )); + }; + + let data = Self { + bytes: var_1, + vec: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.bytes_field_len(Some(1), &self.bytes) + + __protocol.bytes_vec_field_len(Some(2), &self.vec) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift b/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift new file mode 100644 index 00000000..17264f2c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name.thrift @@ -0,0 +1,20 @@ + +struct TEST { + 1: required string ID, +}(pilota.name="Test2") + +const string id = "id" (pilota.name="LANG_ID"); + +struct Test { + 1: required string ID, + 2: required string Id (pilota.name="hello"), +}(pilota.name="Test1") + +enum Index { + A (pilota.name="AA"), + B, +} + +service TestService { + Test test(1: TEST req); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/Cargo.toml new file mode 100644 index 00000000..cf8bdce7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["pilota_name"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/Cargo.toml new file mode 100644 index 00000000..e1d5693b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "pilota_name" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/const_id.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/const_id.rs new file mode 100644 index 00000000..c272a4d2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/const_id.rs @@ -0,0 +1 @@ +pub const LANG_ID: &'static str = "id"; diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_Index.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_Index.rs new file mode 100644 index 00000000..6bcc31a8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_Index.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Index(i32); + +impl Index { + pub const AA: Self = Self(0); + pub const B: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("AA"), + Self(1) => ::std::string::String::from("B"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultRecv.rs new file mode 100644 index 00000000..1a0e2315 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestServiceTestResultRecv { + #[derivative(Default)] + Ok(Test1), +} + +impl ::pilota::thrift::Message for TestServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + })?; + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + }) + match self { + TestServiceTestResultRecv::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultSend.rs new file mode 100644 index 00000000..262e32c8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/enum_TestServiceTestResultSend.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestServiceTestResultSend { + #[derivative(Default)] + Ok(Test1), +} + +impl ::pilota::thrift::Message for TestServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + })?; + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + }) + match self { + TestServiceTestResultSend::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/gen.rs new file mode 100644 index 00000000..b3b7e37f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/gen.rs @@ -0,0 +1,16 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod pilota_name { + include!("src/message_TEST.rs"); + include!("src/message_TestServiceTestArgsSend.rs"); + include!("src/const_id.rs"); + include!("src/message_TestServiceTestArgsRecv.rs"); + include!("src/enum_TestServiceTestResultSend.rs"); + include!("src/message_Test.rs"); + include!("src/service_TestService.rs"); + include!("src/enum_TestServiceTestResultRecv.rs"); + include!("src/enum_Index.rs"); + } + pub use pilota_name::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TEST.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TEST.rs new file mode 100644 index 00000000..dddbc98c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TEST.rs @@ -0,0 +1,176 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct Test1 { + pub id: ::pilota::FastStr, + + pub hello: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for Test1 { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test1" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_faststr_field(2, (&self.hello).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test1` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field hello is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + hello: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test1" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.faststr_field_len(Some(2), &self.hello) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsRecv.rs new file mode 100644 index 00000000..563b5559 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestServiceTestArgsRecv { + pub req: Test2, +} +impl ::pilota::thrift::Message for TestServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsSend.rs new file mode 100644 index 00000000..67fc22f2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/message_TestServiceTestArgsSend.rs @@ -0,0 +1,152 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestServiceTestArgsSend { + pub req: Test2, +} +impl ::pilota::thrift::Message for TestServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/service_TestService.rs b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/service_TestService.rs new file mode 100644 index 00000000..bcfc2708 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/pilota_name/pilota_name/src/service_TestService.rs @@ -0,0 +1,2 @@ + +pub trait TestService {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift b/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift new file mode 100644 index 00000000..c5828f68 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type.thrift @@ -0,0 +1,12 @@ +struct A { + 1: optional A a, + 2: optional B a_b, +} + +struct B { + 1: optional A b_a, +} + +struct C { + 1: set c, +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/Cargo.toml new file mode 100644 index 00000000..28d2aa02 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = [ "common","recursive_type"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/Cargo.toml new file mode 100644 index 00000000..206531f6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "common" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/gen.rs new file mode 100644 index 00000000..10e60aa7 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/gen.rs @@ -0,0 +1,8 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod recursive_type { + include!("src/message_A.rs"); + include!("src/message_B.rs"); + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_A.rs new file mode 100644 index 00000000..923fb68e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_A.rs @@ -0,0 +1,168 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub a: ::std::option::Option<::std::boxed::Box>, + + pub a_b: ::std::option::Option<::std::boxed::Box>, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + if let Some(value) = self.a_b.as_ref() { + __protocol.write_struct_field(2, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new(::pilota::thrift::Message::decode( + __protocol, + )?)); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::std::boxed::Box::new(::pilota::thrift::Message::decode( + __protocol, + )?)); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol).await?, + )); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_2 = Some(::std::boxed::Box::new( + ::decode_async(__protocol).await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { + a: var_1, + a_b: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + self + .a_b + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(2), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_B.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_B.rs new file mode 100644 index 00000000..eb6bb64a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/common/src/message_B.rs @@ -0,0 +1,141 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct B { + pub b_a: ::std::option::Option<::std::boxed::Box>, +} +impl ::pilota::thrift::Message for B { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.b_a.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new(::pilota::thrift::Message::decode( + __protocol, + )?)); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::boxed::Box::new( + ::decode_async(__protocol).await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `B` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { b_a: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + + self + .b_a + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/Cargo.toml new file mode 100644 index 00000000..6296d223 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "recursive_type" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/gen.rs new file mode 100644 index 00000000..a9ba2fcf --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/gen.rs @@ -0,0 +1,8 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod recursive_type { + include!("src/message_C.rs"); + } + pub use recursive_type::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/message_C.rs b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/message_C.rs new file mode 100644 index 00000000..3d5f07a8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/recursive_type/recursive_type/src/message_C.rs @@ -0,0 +1,165 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct C { + pub c: ::std::option::Option<::pilota::AHashSet<::pilota::FastStr>>, +} +impl ::pilota::thrift::Message for C { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "C" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.c.as_ref() { + __protocol.write_set_field( + 1, + ::pilota::thrift::TType::Binary, + &value, + |__protocol, val| { + __protocol.write_faststr((val).clone())?; + ::std::result::Result::Ok(()) + }, + )?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin()?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr()?); + } + __protocol.read_set_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Set => { + var_1 = Some({ + let list_ident = __protocol.read_set_begin().await?; + let mut val = ::pilota::AHashSet::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.insert(__protocol.read_faststr().await?); + } + __protocol.read_set_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `C` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { c: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "C" }) + + self.c.as_ref().map_or(0, |value| { + __protocol.set_field_len( + Some(1), + ::pilota::thrift::TType::Binary, + value, + |__protocol, el| __protocol.faststr_len(el), + ) + }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift b/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift new file mode 100644 index 00000000..8c7d7551 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw.thrift @@ -0,0 +1,10 @@ +enum Index { + A = 0, + Self = 1, +} + +struct A { + 1: required string type, + 2: required string self, + 3: required string protocol, +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/self_kw/Cargo.toml new file mode 100644 index 00000000..99fa3f00 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["self_kw"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/Cargo.toml new file mode 100644 index 00000000..05b3420a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "self_kw" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/enum_Index.rs b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/enum_Index.rs new file mode 100644 index 00000000..a8036066 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/enum_Index.rs @@ -0,0 +1,87 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq, Copy)] +#[repr(transparent)] +pub struct Index(i32); + +impl Index { + pub const A: Self = Self(0); + pub const SELF: Self = Self(1); + + pub fn inner(&self) -> i32 { + self.0 + } + + pub fn to_string(&self) -> ::std::string::String { + match self { + Self(0) => ::std::string::String::from("A"), + Self(1) => ::std::string::String::from("SELF"), + Self(val) => val.to_string(), + } + } +} + +impl ::std::convert::From for Index { + fn from(value: i32) -> Self { + Self(value) + } +} + +impl ::std::convert::From for i32 { + fn from(value: Index) -> i32 { + value.0 + } +} + +impl ::pilota::thrift::Message for Index { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_i32(self.inner())?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let value = __protocol.read_i32()?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let value = __protocol.read_i32().await?; + ::std::result::Result::Ok(::std::convert::TryFrom::try_from(value).map_err(|err| { + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + format!("invalid enum value for Index, value: {}", value), + ) + })?) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.i32_len(self.inner()) + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/gen.rs new file mode 100644 index 00000000..031d3c37 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/gen.rs @@ -0,0 +1,9 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod self_kw { + include!("src/enum_Index.rs"); + include!("src/message_A.rs"); + } + pub use self_kw::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/message_A.rs new file mode 100644 index 00000000..bfc2964c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/self_kw/self_kw/src/message_A.rs @@ -0,0 +1,202 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub r#type: ::pilota::FastStr, + + pub self_: ::pilota::FastStr, + + pub protocol: ::pilota::FastStr, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.r#type).clone())?; + __protocol.write_faststr_field(2, (&self.self_).clone())?; + __protocol.write_faststr_field(3, (&self.protocol).clone())?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr()?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field protocol is required".to_string(), + )); + }; + + let data = Self { + r#type: var_1, + self_: var_2, + protocol: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_faststr().await?); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_3 = Some(__protocol.read_faststr().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field r#type is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field self_ is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field protocol is required".to_string(), + )); + }; + + let data = Self { + r#type: var_1, + self_: var_2, + protocol: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.r#type) + + __protocol.faststr_field_len(Some(2), &self.self_) + + __protocol.faststr_field_len(Some(3), &self.protocol) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/string.thrift b/pilota-build/test_data/thrift_workspace_with_split/string.thrift new file mode 100644 index 00000000..8894e584 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string.thrift @@ -0,0 +1,4 @@ +struct A { + 1: required string faststr, + 2: required string string(pilota.rust_type = "string"), +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/string/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/string/Cargo.toml new file mode 100644 index 00000000..0f970afd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["string"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/string/string/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/string/string/Cargo.toml new file mode 100644 index 00000000..a04b3edc --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string/string/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "string" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/string/string/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/gen.rs new file mode 100644 index 00000000..dfa81702 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/gen.rs @@ -0,0 +1,8 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod string { + include!("src/message_A.rs"); + } + pub use string::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/string/string/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/string/string/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/message_A.rs new file mode 100644 index 00000000..772b4d4f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/string/string/src/message_A.rs @@ -0,0 +1,176 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub faststr: ::pilota::FastStr, + + pub string: ::std::string::String, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.faststr).clone())?; + __protocol.write_string_field(2, &self.string)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string()?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field faststr is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field string is required".to_string(), + )); + }; + + let data = Self { + faststr: var_1, + string: var_2, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_2 = Some(__protocol.read_string().await?); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field faststr is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field string is required".to_string(), + )); + }; + + let data = Self { + faststr: var_1, + string: var_2, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.faststr_field_len(Some(1), &self.faststr) + + __protocol.string_field_len(Some(2), &&self.string) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/union.thrift b/pilota-build/test_data/thrift_workspace_with_split/union.thrift new file mode 100644 index 00000000..a1bbd6b8 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union.thrift @@ -0,0 +1,12 @@ +union Union { + 1: string a, + 2: binary b, +} + +struct A { + 1: Union u, +} + +union Empty { + +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/union/Cargo.toml new file mode 100644 index 00000000..5dd14e9e --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["union"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/union/union/Cargo.toml new file mode 100644 index 00000000..d8f52c2d --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "union" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Empty.rs b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Empty.rs new file mode 100644 index 00000000..18fcf2c2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Empty.rs @@ -0,0 +1,101 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Clone, PartialEq)] +pub enum Empty {} + +impl ::pilota::thrift::Message for Empty { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { name: "Empty" })?; + match self { + _ => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Empty" }) + + match self { + _ => 0, + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Union.rs b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Union.rs new file mode 100644 index 00000000..646101ac --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/enum_Union.rs @@ -0,0 +1,170 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum Union { + #[derivative(Default)] + A(::pilota::FastStr), + + B(::pilota::Bytes), +} + +impl ::pilota::thrift::Message for Union { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { name: "Union" })?; + match self { + Union::A(ref value) => { + __protocol.write_faststr_field(1, (value).clone())?; + } + Union::B(ref value) => { + __protocol.write_bytes_field(2, (value).clone())?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr()?; + __protocol.faststr_len(&field_ident); + ret = Some(Union::A(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes()?; + __protocol.bytes_len(&field_ident); + ret = Some(Union::B(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(1) => { + if ret.is_none() { + let field_ident = __protocol.read_faststr().await?; + + ret = Some(Union::A(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + Some(2) => { + if ret.is_none() { + let field_ident = __protocol.read_bytes().await?; + + ret = Some(Union::B(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Union" }) + + match self { + Union::A(ref value) => __protocol.faststr_field_len(Some(1), value), + Union::B(ref value) => __protocol.bytes_field_len(Some(2), value), + } + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/gen.rs new file mode 100644 index 00000000..e122a187 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/gen.rs @@ -0,0 +1,10 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod union { + include!("src/enum_Union.rs"); + include!("src/enum_Empty.rs"); + include!("src/message_A.rs"); + } + pub use union::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/union/union/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/message_A.rs new file mode 100644 index 00000000..f7111298 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/union/union/src/message_A.rs @@ -0,0 +1,140 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A { + pub u: ::std::option::Option, +} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + if let Some(value) = self.u.as_ref() { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self { u: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self { u: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + self + .u + .as_ref() + .map_or(0, |value| __protocol.struct_field_len(Some(1), value)) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void.thrift b/pilota-build/test_data/thrift_workspace_with_split/void.thrift new file mode 100644 index 00000000..91c35d7b --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void.thrift @@ -0,0 +1,3 @@ +service Test { + void test_123(); +} \ No newline at end of file diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/void/Cargo.toml new file mode 100644 index 00000000..f7a4f773 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["void"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/void/void/Cargo.toml new file mode 100644 index 00000000..cbb855a2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "void" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultRecv.rs new file mode 100644 index 00000000..8ad4895c --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultRecv.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTest123ResultRecv { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for TestTest123ResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + })?; + match self { + TestTest123ResultRecv::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultRecv::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultRecv", + }) + match self { + TestTest123ResultRecv::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultSend.rs new file mode 100644 index 00000000..7b6300c2 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/enum_TestTest123ResultSend.rs @@ -0,0 +1,102 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestTest123ResultSend { + #[derivative(Default)] + Ok(()), +} + +impl ::pilota::thrift::Message for TestTest123ResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + })?; + match self { + TestTest123ResultSend::Ok(ref value) => {} + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Ok(TestTest123ResultSend::Ok(())) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ResultSend", + }) + match self { + TestTest123ResultSend::Ok(ref value) => 0, + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/gen.rs new file mode 100644 index 00000000..591ee79f --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/gen.rs @@ -0,0 +1,12 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod void { + include!("src/enum_TestTest123ResultRecv.rs"); + include!("src/message_TestTest123ArgsRecv.rs"); + include!("src/enum_TestTest123ResultSend.rs"); + include!("src/message_TestTest123ArgsSend.rs"); + include!("src/service_Test.rs"); + } + pub use void::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsRecv.rs new file mode 100644 index 00000000..8fb4e7e4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsRecv.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTest123ArgsRecv {} +impl ::pilota::thrift::Message for TestTest123ArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsRecv", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsSend.rs new file mode 100644 index 00000000..f64a8bd6 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/message_TestTest123ArgsSend.rs @@ -0,0 +1,122 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct TestTest123ArgsSend {} +impl ::pilota::thrift::Message for TestTest123ArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestTest123ArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestTest123ArgsSend", + }) + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/void/void/src/service_Test.rs b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/service_Test.rs new file mode 100644 index 00000000..0d0c0588 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/void/void/src/service_Test.rs @@ -0,0 +1,2 @@ + +pub trait Test {} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift new file mode 100644 index 00000000..6bb95526 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc.thrift @@ -0,0 +1,13 @@ +struct A { + +} + +struct TEST { + 1: required string ID, + 2: required list> Name2(pilota.rust_wrapper_arc="true"), + 3: required map> Name3(pilota.rust_wrapper_arc="true"), +} + +service TestService { + TEST(pilota.rust_wrapper_arc="true") test(1: TEST req(pilota.rust_wrapper_arc="true")); +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/Cargo.toml new file mode 100644 index 00000000..bc9f3b17 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +members = ["wrapper_arc"] + +[workspace.dependencies] +anyhow = "1" +pilota = "*" +volo = "*" +volo-thrift = "*" diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/Cargo.toml b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/Cargo.toml new file mode 100644 index 00000000..c5cd0d42 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/Cargo.toml @@ -0,0 +1,16 @@ +[dependencies.anyhow] +workspace = true + +[dependencies.pilota] +workspace = true + +[dependencies.volo] +workspace = true + +[dependencies.volo-thrift] +workspace = true + +[package] +edition = "2021" +name = "wrapper_arc" +version = "0.1.0" diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultRecv.rs new file mode 100644 index 00000000..eb02d1a1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultRecv.rs @@ -0,0 +1,140 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestServiceTestResultRecv { + #[derivative(Default)] + Ok(Test), +} + +impl ::pilota::thrift::Message for TestServiceTestResultRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + })?; + match self { + TestServiceTestResultRecv::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::pilota::thrift::Message::decode(__protocol)?; + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::decode_async(__protocol) + .await?; + + ret = Some(TestServiceTestResultRecv::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultRecv", + }) + match self { + TestServiceTestResultRecv::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultSend.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultSend.rs new file mode 100644 index 00000000..97b0f8b5 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/enum_TestServiceTestResultSend.rs @@ -0,0 +1,142 @@ +#[derive(Debug, ::pilota::derivative::Derivative)] +#[derivative(Default)] +#[derive(Clone, PartialEq)] +pub enum TestServiceTestResultSend { + #[derivative(Default)] + Ok(::std::sync::Arc), +} + +impl ::pilota::thrift::Message for TestServiceTestResultSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + })?; + match self { + TestServiceTestResultSend::Ok(ref value) => { + __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + } + } + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + let mut ret = None; + __protocol.read_struct_begin()?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = + ::std::sync::Arc::new(::pilota::thrift::Message::decode(__protocol)?); + __protocol.struct_len(&field_ident); + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + } + __protocol.read_field_end()?; + __protocol.read_struct_end()?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut ret = None; + __protocol.read_struct_begin().await?; + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + match field_ident.id { + Some(0) => { + if ret.is_none() { + let field_ident = ::std::sync::Arc::new( + ::decode_async(__protocol) + .await?, + ); + + ret = Some(TestServiceTestResultSend::Ok(field_ident)); + } else { + return ::std::result::Result::Err( + ::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received multiple fields for union from remote Message", + ), + ); + } + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + } + __protocol.read_field_end().await?; + __protocol.read_struct_end().await?; + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestResultSend", + }) + match self { + TestServiceTestResultSend::Ok(ref value) => __protocol.struct_field_len(Some(0), value), + } + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/gen.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/gen.rs new file mode 100644 index 00000000..6304dae4 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/gen.rs @@ -0,0 +1,14 @@ +pub mod gen { + #![allow(warnings, clippy::all)] + + pub mod wrapper_arc { + include!("src/message_A.rs"); + include!("src/service_TestService.rs"); + include!("src/enum_TestServiceTestResultRecv.rs"); + include!("src/message_TestServiceTestArgsRecv.rs"); + include!("src/enum_TestServiceTestResultSend.rs"); + include!("src/message_TEST.rs"); + include!("src/message_TestServiceTestArgsSend.rs"); + } + pub use wrapper_arc::*; +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/lib.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/lib.rs new file mode 100644 index 00000000..3a85e855 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/lib.rs @@ -0,0 +1,2 @@ +include!("gen.rs"); +pub use gen::*; diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_A.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_A.rs new file mode 100644 index 00000000..b0c48761 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_A.rs @@ -0,0 +1,119 @@ +#[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] +pub struct A {} +impl ::pilota::thrift::Message for A { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "A" }; + + __protocol.write_struct_begin(&struct_ident)?; + + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let data = Self {}; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `A` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let data = Self {}; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "A" }) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TEST.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TEST.rs new file mode 100644 index 00000000..766478cd --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TEST.rs @@ -0,0 +1,345 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct Test { + pub id: ::pilota::FastStr, + + pub name2: ::std::vec::Vec<::std::vec::Vec<::std::sync::Arc>>, + + pub name3: ::pilota::AHashMap>>, +} +impl ::pilota::thrift::Message for Test { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_faststr_field(1, (&self.id).clone())?; + __protocol.write_list_field( + 2, + ::pilota::thrift::TType::List, + &&self.name2, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_map_field( + 3, + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::List, + &&self.name3, + |__protocol, key| { + __protocol.write_i32(*key)?; + ::std::result::Result::Ok(()) + }, + |__protocol, val| { + __protocol.write_list( + ::pilota::thrift::TType::Struct, + &val, + |__protocol, val| { + __protocol.write_struct(val)?; + ::std::result::Result::Ok(()) + }, + )?; + ::std::result::Result::Ok(()) + }, + )?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr()?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::vec::Vec<::std::sync::Arc>> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write(unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::sync::Arc> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::std::sync::Arc::new( + ::pilota::thrift::Message::decode(__protocol)?, + ), + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_3 = Some({ + let map_ident = __protocol.read_map_begin()?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32()?, unsafe { + let list_ident = __protocol.read_list_begin()?; + let mut val: Vec<::std::sync::Arc> = + Vec::with_capacity(list_ident.size); + for i in 0..list_ident.size { + val.as_mut_ptr().offset(i as isize).write( + ::std::sync::Arc::new( + ::pilota::thrift::Message::decode(__protocol)?, + ), + ); + } + val.set_len(list_ident.size); + __protocol.read_list_end()?; + val + }); + } + __protocol.read_map_end()?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name2 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name3 is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + name2: var_2, + name3: var_3, + }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + let mut var_2 = None; + let mut var_3 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Binary => { + var_1 = Some(__protocol.read_faststr().await?); + } + Some(2) if field_ident.field_type == ::pilota::thrift::TType::List => { + var_2 = Some({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push({ + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::std::sync::Arc::new( + ::decode_async( + __protocol, + ) + .await?, + )); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_list_end().await?; + val + }); + } + Some(3) if field_ident.field_type == ::pilota::thrift::TType::Map => { + var_3 = Some({ + let map_ident = __protocol.read_map_begin().await?; + let mut val = ::pilota::AHashMap::with_capacity(map_ident.size); + for _ in 0..map_ident.size { + val.insert(__protocol.read_i32().await?, { + let list_ident = __protocol.read_list_begin().await?; + let mut val = Vec::with_capacity(list_ident.size); + for _ in 0..list_ident.size { + val.push(::std::sync::Arc::new( + ::decode_async( + __protocol, + ) + .await?, + )); + } + __protocol.read_list_end().await?; + val + }); + } + __protocol.read_map_end().await?; + val + }); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `Test` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field id is required".to_string(), + )); + }; + let Some(var_2) = var_2 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name2 is required".to_string(), + )); + }; + let Some(var_3) = var_3 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field name3 is required".to_string(), + )); + }; + + let data = Self { + id: var_1, + name2: var_2, + name3: var_3, + }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + + __protocol.faststr_field_len(Some(1), &self.id) + + __protocol.list_field_len( + Some(2), + ::pilota::thrift::TType::List, + &self.name2, + |__protocol, el| { + __protocol.list_len(::pilota::thrift::TType::Struct, el, |__protocol, el| { + __protocol.struct_len(el) + }) + }, + ) + + __protocol.map_field_len( + Some(3), + ::pilota::thrift::TType::I32, + ::pilota::thrift::TType::List, + &self.name3, + |__protocol, key| __protocol.i32_len(*key), + |__protocol, val| { + __protocol.list_len(::pilota::thrift::TType::Struct, val, |__protocol, el| { + __protocol.struct_len(el) + }) + }, + ) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsRecv.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsRecv.rs new file mode 100644 index 00000000..71a1d9b1 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsRecv.rs @@ -0,0 +1,152 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct TestServiceTestArgsRecv { + pub req: Test, +} +impl ::pilota::thrift::Message for TestServiceTestArgsRecv { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some( + ::decode_async(__protocol) + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsSend.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsSend.rs new file mode 100644 index 00000000..12e37b2a --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/message_TestServiceTestArgsSend.rs @@ -0,0 +1,154 @@ +#[derive(Debug, Default, Clone, PartialEq)] +pub struct TestServiceTestArgsSend { + pub req: ::std::sync::Arc, +} +impl ::pilota::thrift::Message for TestServiceTestArgsSend { + fn encode( + &self, + __protocol: &mut T, + ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { + #[allow(unused_imports)] + use ::pilota::thrift::TOutputProtocolExt; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }; + + __protocol.write_struct_begin(&struct_ident)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_field_stop()?; + __protocol.write_struct_end()?; + ::std::result::Result::Ok(()) + } + + fn decode( + __protocol: &mut T, + ) -> ::std::result::Result { + #[allow(unused_imports)] + use ::pilota::{thrift::TLengthProtocolExt, Buf}; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin()?; + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::sync::Arc::new(::pilota::thrift::Message::decode( + __protocol, + )?)); + } + _ => { + __protocol.skip(field_ident.field_type)?; + } + } + + __protocol.read_field_end()?; + __protocol.field_end_len(); + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + })() { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end()?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + } + + fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( + __protocol: &'a mut T, + ) -> ::std::pin::Pin< + ::std::boxed::Box< + dyn ::std::future::Future< + Output = ::std::result::Result, + > + Send + + 'a, + >, + > { + ::std::boxed::Box::pin(async move { + let mut var_1 = None; + + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { + } + __pilota_decoding_field_id = field_ident.id; + match field_ident.id { + Some(1) if field_ident.field_type == ::pilota::thrift::TType::Struct => { + var_1 = Some(::std::sync::Arc::new( + ::decode_async(__protocol) + .await?, + )); + } + _ => { + __protocol.skip(field_ident.field_type).await?; + } + } + + __protocol.read_field_end().await?; + } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) + } + .await + { + if let Some(field_id) = __pilota_decoding_field_id { + err.prepend_msg(&format!( + "decode struct `TestServiceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); + } + return ::std::result::Result::Err(err); + }; + __protocol.read_struct_end().await?; + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "field req is required".to_string(), + )); + }; + + let data = Self { req: var_1 }; + ::std::result::Result::Ok(data) + }) + } + + fn size(&self, __protocol: &mut T) -> usize { + #[allow(unused_imports)] + use ::pilota::thrift::TLengthProtocolExt; + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "TestServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + + __protocol.struct_end_len() + } +} diff --git a/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/service_TestService.rs b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/service_TestService.rs new file mode 100644 index 00000000..bcfc2708 --- /dev/null +++ b/pilota-build/test_data/thrift_workspace_with_split/wrapper_arc/wrapper_arc/src/service_TestService.rs @@ -0,0 +1,2 @@ + +pub trait TestService {}