diff --git a/Cargo.lock b/Cargo.lock index 5cc557a0..38c33a99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,7 +805,7 @@ dependencies = [ [[package]] name = "pilota-build" -version = "0.11.19" +version = "0.11.20" dependencies = [ "ahash", "anyhow", diff --git a/pilota-build/Cargo.toml b/pilota-build/Cargo.toml index e5a8f9bd..6545c8c1 100644 --- a/pilota-build/Cargo.toml +++ b/pilota-build/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pilota-build" -version = "0.11.19" +version = "0.11.20" edition = "2021" description = "Compile thrift and protobuf idl into rust code at compile-time." documentation = "https://docs.rs/pilota-build" diff --git a/pilota-build/src/codegen/thrift/mod.rs b/pilota-build/src/codegen/thrift/mod.rs index 954454db..fbf9a5b0 100644 --- a/pilota-build/src/codegen/thrift/mod.rs +++ b/pilota-build/src/codegen/thrift/mod.rs @@ -183,6 +183,7 @@ impl ThriftBackend { &self, helper: &DecodeHelper, s: &rir::Message, + name: Symbol, keep: bool, is_arg: bool, ) -> String { @@ -291,7 +292,7 @@ impl ThriftBackend { } }; - let format_msg = format!("decode struct `{}` field(#{{}}) failed", s.name); + let format_msg = format!("decode struct `{}` field(#{{}}) failed", name); let mut fields = s .fields @@ -459,7 +460,6 @@ impl CodegenBackend for ThriftBackend { fn codegen_struct_impl(&self, def_id: DefId, stream: &mut String, s: &Message) { let keep = self.keep_unknown_fields.contains(&def_id); let name = self.cx.rust_name(def_id); - let name_str = &**s.name; let mut encode_fields = self.codegen_encode_fields(&s.fields).join(""); if keep { encode_fields.push_str( @@ -477,10 +477,10 @@ impl CodegenBackend for ThriftBackend { } stream.push_str(&self.codegen_impl_message_with_helper( def_id, - name, + name.clone(), format! { r#"let struct_ident =::pilota::thrift::TStructIdentifier {{ - name: "{name_str}", + name: "{name}", }}; __protocol.write_struct_begin(&struct_ident)?; @@ -492,10 +492,10 @@ impl CodegenBackend for ThriftBackend { }, format! { r#"__protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier {{ - name: "{name_str}", + name: "{name}", }}) + {encode_fields_size} __protocol.field_stop_len() + __protocol.struct_end_len()"# }, - |helper| self.codegen_decode(helper, s, keep, self.is_arg(def_id)), + |helper| self.codegen_decode(helper, s, name.clone(), keep, self.is_arg(def_id)), )); } @@ -536,7 +536,6 @@ impl CodegenBackend for ThriftBackend { None if is_entry_message => self.codegen_entry_enum(def_id, stream, e), None => { let name = self.rust_name(def_id); - let name_str = &**e.name; let mut encode_variants = e .variants .iter() @@ -603,7 +602,7 @@ impl CodegenBackend for ThriftBackend { name.clone(), format! { r#"__protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier {{ - name: "{name_str}", + name: "{name}", }})?; match self {{ {encode_variants} @@ -614,7 +613,7 @@ impl CodegenBackend for ThriftBackend { }, format! { r#"__protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier {{ - name: "{name_str}", + name: "{name}", }}) + match self {{ {variants_size} }} + __protocol.field_stop_len() + __protocol.struct_end_len()"# diff --git a/pilota-build/src/middle/context.rs b/pilota-build/src/middle/context.rs index 69019884..d1649e1c 100644 --- a/pilota-build/src/middle/context.rs +++ b/pilota-build/src/middle/context.rs @@ -791,7 +791,7 @@ impl Context { } if !self.change_case || self.names.contains(&def_id) { - return node.name().0.into(); + return node.name(); } match self.node(def_id).unwrap().kind { diff --git a/pilota-build/src/parser/thrift/mod.rs b/pilota-build/src/parser/thrift/mod.rs index 8deadd9d..a8e73ab5 100644 --- a/pilota-build/src/parser/thrift/mod.rs +++ b/pilota-build/src/parser/thrift/mod.rs @@ -72,6 +72,7 @@ pub struct ThriftLower { file_ids_map: FxHashMap, FileId>, include_dirs: Vec, packages: FxHashMap>>, + service_name_duplicates: FxHashSet, } impl ThriftLower { @@ -84,6 +85,7 @@ impl ThriftLower { file_ids_map: FxHashMap::default(), include_dirs, packages: Default::default(), + service_name_duplicates: Default::default(), } } @@ -115,6 +117,33 @@ impl ThriftLower { } fn lower_service(&self, service: &thrift_parser::Service) -> Vec { + let service_name = if self + .service_name_duplicates + .contains(&service.name.to_upper_camel_case()) + { + service.name.to_string() + } else { + service.name.to_upper_camel_case() + }; + + let mut function_names: FxHashMap> = FxHashMap::default(); + service.functions.iter().for_each(|func| { + let name = self + .extract_tags(&func.annotations) + .get::() + .map(|name| name.0.to_string()) + .unwrap_or_else(|| func.name.to_string()); + function_names + .entry(name.to_upper_camel_case()) + .or_default() + .push(name); + }); + let function_name_duplicates = function_names + .iter() + .filter(|(_, v)| v.len() > 1) + .map(|(k, _)| k) + .collect::>(); + let kind = ir::ItemKind::Service(ir::Service { name: self.lower_ident(&service.name), extend: service @@ -126,7 +155,7 @@ impl ThriftLower { methods: service .functions .iter() - .map(|f| self.lower_method(service, f)) + .map(|f| self.lower_method(&service_name, f, &function_name_duplicates)) .collect(), }); let mut service_item = self.mk_item(kind, Default::default()); @@ -134,20 +163,6 @@ impl ThriftLower { let mut related_items = Vec::default(); - let mut seen = FxHashSet::default(); - let mut duplicate_function_names = FxHashSet::default(); - for name in service.functions.iter().map(|f| { - self.extract_tags(&f.annotations) - .get::() - .map(|name| &*name.0) - .unwrap_or_else(|| &*f.name) - .to_upper_camel_case() - }) { - if !seen.insert(name.clone()) { - duplicate_function_names.insert(name); - } - } - service.functions.iter().for_each(|f| { let exception = f .throws @@ -171,21 +186,17 @@ impl ThriftLower { .collect::>(); let tags = self.extract_tags(&f.annotations); - - let method_name = tags + let name = tags .get::() - .map(|name| name.0.to_upper_camel_case()) - .unwrap_or_else(|| { - let method_name = f.name.to_upper_camel_case(); - if duplicate_function_names.contains(&method_name) { - f.name.to_string() - } else { - method_name - } - }); - - let name: Ident = format!("{}{}ResultRecv", service.name.as_str(), method_name).into(); + .map(|name| name.0.to_string()) + .unwrap_or_else(|| f.name.to_string()); + let method_name = if function_name_duplicates.contains(&name.to_upper_camel_case()) { + name + } else { + name.to_upper_camel_case() + }; + let name: Ident = format!("{}{}ResultRecv", service_name, method_name).into(); let mut tags = self.extract_tags(&f.result_type.1); tags.remove::(); let kind = ir::ItemKind::Enum(ir::Enum { @@ -201,12 +212,13 @@ impl ThriftLower { .collect(), repr: None, }); - related_items.push(name); + related_items.push(name.clone()); let mut tags = Tags::default(); tags.insert(crate::tags::KeepUnknownFields(false)); + tags.insert(crate::tags::PilotaName(name.sym.0)); result.push(self.mk_item(kind, tags.into())); - let name: Ident = format!("{}{}ResultSend", service.name.as_str(), method_name).into(); + let name: Ident = format!("{}{}ResultSend", service_name, method_name).into(); let kind = ir::ItemKind::Enum(ir::Enum { name: name.clone(), variants: std::iter::once(ir::EnumVariant { @@ -220,36 +232,38 @@ impl ThriftLower { .collect(), repr: None, }); - related_items.push(name); + related_items.push(name.clone()); let mut tags = Tags::default(); tags.insert(crate::tags::KeepUnknownFields(false)); + tags.insert(crate::tags::PilotaName(name.sym.0)); result.push(self.mk_item(kind, tags.into())); if !exception.is_empty() { - let name: Ident = - format!("{}{}Exception", service.name.as_str(), method_name).into(); + let name: Ident = format!("{}{}Exception", service_name, method_name).into(); let kind = ir::ItemKind::Enum(ir::Enum { name: name.clone(), variants: exception, repr: None, }); - related_items.push(name); + related_items.push(name.clone()); let mut tags = Tags::default(); tags.insert(crate::tags::KeepUnknownFields(false)); + tags.insert(crate::tags::PilotaName(name.sym.0)); result.push(self.mk_item(kind, tags.into())); } - let name: Ident = format!("{}{}ArgsSend", service.name.as_str(), method_name).into(); + let name: Ident = format!("{}{}ArgsSend", service_name, method_name).into(); let kind = ir::ItemKind::Message(ir::Message { name: name.clone(), fields: f.arguments.iter().map(|a| self.lower_field(a)).collect(), }); - related_items.push(name); + related_items.push(name.clone()); let mut tags = Tags::default(); tags.insert(crate::tags::KeepUnknownFields(false)); + tags.insert(crate::tags::PilotaName(name.sym.0)); result.push(self.mk_item(kind, tags.into())); - let name: Ident = format!("{}{}ArgsRecv", service.name.as_str(), method_name).into(); + let name: Ident = format!("{}{}ArgsRecv", service_name, method_name).into(); let kind = ir::ItemKind::Message(ir::Message { name: name.clone(), fields: f @@ -262,9 +276,10 @@ impl ThriftLower { }) .collect(), }); - related_items.push(name); + related_items.push(name.clone()); let mut tags: Tags = Tags::default(); tags.insert(crate::tags::KeepUnknownFields(false)); + tags.insert(crate::tags::PilotaName(name.sym.0)); result.push(self.mk_item(kind, tags.into())); }); @@ -275,9 +290,21 @@ impl ThriftLower { fn lower_method( &self, - service: &thrift_parser::Service, + service_name: &String, method: &thrift_parser::Function, + function_name_duplicates: &FxHashSet<&String>, ) -> ir::Method { + let tags = self.extract_tags(&method.annotations); + let name = tags + .get::() + .map(|name| name.0.to_string()) + .unwrap_or_else(|| method.name.to_string()); + let method_name = if function_name_duplicates.contains(&name.to_upper_camel_case()) { + name + } else { + name.to_upper_camel_case() + }; + ir::Method { name: self.lower_ident(&method.name), args: method @@ -292,15 +319,14 @@ impl ThriftLower { .collect(), ret: self.lower_ty(&method.result_type), oneway: method.oneway, - tags: self.extract_tags(&method.annotations).into(), + tags: tags.into(), exceptions: if method.throws.is_empty() { None } else { Some(Path { segments: Arc::from([Ident::from(format!( "{}{}Exception", - service.name.to_upper_camel_case().as_str(), - method.name.to_upper_camel_case(), + service_name, method_name, ))]), }) }, @@ -596,7 +622,23 @@ impl Lower> for ThriftLower { .or_default() .push(f.path.clone()); - ir::File { + let mut service_names: FxHashMap> = FxHashMap::default(); + f.items.iter().for_each(|item| { + if let thrift_parser::Item::Service(service) = item { + service_names + .entry(service.name.to_upper_camel_case()) + .or_default() + .push(service.name.to_string()); + } + }); + this.service_name_duplicates.extend( + service_names + .into_iter() + .filter(|(_, v)| v.len() > 1) + .map(|(k, _)| k), + ); + + let ret = ir::File { package: file_package, items: f .items @@ -607,7 +649,10 @@ impl Lower> for ThriftLower { .collect(), id: file_id, uses, - } + }; + + this.service_name_duplicates.clear(); + ret }); file.id diff --git a/pilota-build/test_data/thrift/auto_name.rs b/pilota-build/test_data/thrift/auto_name.rs index 960648fa..461e1a95 100644 --- a/pilota-build/test_data/thrift/auto_name.rs +++ b/pilota-build/test_data/thrift/auto_name.rs @@ -155,11 +155,154 @@ pub mod auto_name { + __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 testServiceTest2ArgsRecv { - pub self_: TEST, + pub struct servicetestArgsSend { + pub req: TEST, } - impl ::pilota::thrift::Message for testServiceTest2ArgsRecv { + impl ::pilota::thrift::Message for servicetestArgsSend { fn encode( &self, __protocol: &mut T, @@ -167,11 +310,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ArgsRecv", + name: "servicetestArgsSend", }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_struct_field(1, &self.self_, ::pilota::thrift::TType::Struct)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; __protocol.write_field_stop()?; __protocol.write_struct_end()?; ::std::result::Result::Ok(()) @@ -215,7 +358,10 @@ pub mod auto_name { ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) })() { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServiceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!( + "decode struct `servicetestArgsSend` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -224,11 +370,11 @@ pub mod auto_name { 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(), + "field req is required".to_string(), )); }; - let data = Self { self_: var_1 }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) } @@ -280,7 +426,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServiceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `servicetestArgsSend` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -290,12 +436,12 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field self_ is required".to_string(), + "field req is required".to_string(), ), ); }; - let data = Self { self_: var_1 }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) }) } @@ -304,17 +450,15 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ArgsRecv", - }) + __protocol.struct_field_len(Some(1), &self.self_) + 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 testServiceTestArgsRecv { - pub req: TEST, - } - impl ::pilota::thrift::Message for testServiceTestArgsRecv { + pub struct TestException {} + impl ::pilota::thrift::Message for TestException { fn encode( &self, __protocol: &mut T, @@ -322,11 +466,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "testServiceTestArgsRecv", + name: "TestException", }; __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(()) @@ -338,8 +482,6 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - let mut var_1 = None; - let mut __pilota_decoding_field_id = None; __protocol.read_struct_begin()?; @@ -354,11 +496,6 @@ pub mod auto_name { } __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)?; } @@ -370,20 +507,16 @@ pub mod auto_name { ::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)); + err.prepend_msg(&format!( + "decode struct `TestException` 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 }; + let data = Self {}; ::std::result::Result::Ok(data) } @@ -398,8 +531,6 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut var_1 = None; - let mut __pilota_decoding_field_id = None; __protocol.read_struct_begin().await?; @@ -412,17 +543,6 @@ pub mod auto_name { } __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?; } @@ -435,22 +555,16 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServiceTestArgsRecv` field(#{}) failed, caused by: ", 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 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 }; + let data = Self {}; ::std::result::Result::Ok(data) }) } @@ -459,17 +573,17 @@ pub mod auto_name { #[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() + name: "TestException", + }) + __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 testServicetestArgsRecv { + pub struct servicetestArgsRecv { pub req: TEST, } - impl ::pilota::thrift::Message for testServicetestArgsRecv { + impl ::pilota::thrift::Message for servicetestArgsRecv { fn encode( &self, __protocol: &mut T, @@ -477,7 +591,7 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "testServicetestArgsRecv", + name: "servicetestArgsRecv", }; __protocol.write_struct_begin(&struct_ident)?; @@ -525,7 +639,10 @@ pub mod auto_name { ::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)); + err.prepend_msg(&format!( + "decode struct `servicetestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -590,7 +707,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `servicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -614,22 +731,23 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServicetestArgsRecv", + name: "servicetestArgsRecv", }) + __protocol.struct_field_len(Some(1), &self.req) + __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 TestServiceTest2ResultRecv { + pub enum servicetestResultSend { #[derivative(Default)] Ok(Test), + + E(TestException), } - impl ::pilota::thrift::Message for TestServiceTest2ResultRecv { + impl ::pilota::thrift::Message for servicetestResultSend { fn encode( &self, __protocol: &mut T, @@ -637,12 +755,15 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ResultRecv", + name: "servicetestResultSend", })?; match self { - TestServiceTest2ResultRecv::Ok(ref value) => { + 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()?; @@ -669,7 +790,21 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(TestServiceTest2ResultRecv::Ok(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( @@ -724,7 +859,23 @@ pub mod auto_name { ) .await?; - ret = Some(TestServiceTest2ResultRecv::Ok(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 = + ::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, @@ -754,38 +905,35 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ResultRecv", + name: "servicetestResultSend", }) + match self { - TestServiceTest2ResultRecv::Ok(ref value) => { + 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 TestServiceTestResultRecv { - #[derivative(Default)] - Ok(Test), + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTest2ArgsSend { + pub r#type: TEST, } - - impl ::pilota::thrift::Message for TestServiceTestResultRecv { + 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; - __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)?; - } - } + 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(()) @@ -796,46 +944,57 @@ pub mod auto_name { ) -> ::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", - ), - ); - } + + 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); } - _ => { - __protocol.skip(field_ident.field_type)?; + __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(); } - } - __protocol.read_field_end()?; + ::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()?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + "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>( @@ -849,46 +1008,60 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut ret = None; + let mut var_1 = None; + + let mut __pilota_decoding_field_id = 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( + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_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?; - - 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" - )); + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; } } - _ => { - __protocol.skip(field_ident.field_type).await?; - } + + __protocol.read_field_end().await?; } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) } - __protocol.read_field_end().await?; + .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?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( - ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + + 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) }) } @@ -896,38 +1069,29 @@ pub mod auto_name { #[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() + 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, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] - pub enum TestServicetestResultRecv { - #[derivative(Default)] - Ok(Test), + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTestArgsSend { + pub req: TEST, } - - impl ::pilota::thrift::Message for TestServicetestResultRecv { + 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; - __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)?; - } - } + 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(()) @@ -938,46 +1102,57 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - let mut ret = None; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = 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", - ), - ); - } + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); } - _ => { - __protocol.skip(field_ident.field_type)?; + __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(); } - } - __protocol.read_field_end()?; + ::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()?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + "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>( @@ -991,46 +1166,60 @@ pub mod auto_name { >, > { ::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( + 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?; - - 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" - )); + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; } } - _ => { - __protocol.skip(field_ident.field_type).await?; - } + + __protocol.read_field_end().await?; } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) } - __protocol.read_field_end().await?; + .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?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( - ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + + 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) }) } @@ -1038,26 +1227,21 @@ pub mod auto_name { #[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() + name: "ServiceTestArgsSend", + }) + __protocol.struct_field_len(Some(1), &self.req) + + __protocol.field_stop_len() + __protocol.struct_end_len() } } - pub const ip: &'static str = "ip"; - pub trait testService {} #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum testServiceTest2ResultRecv { + pub enum ServicetestException { #[derivative(Default)] - Ok(Test), + E(TestException), } - impl ::pilota::thrift::Message for testServiceTest2ResultRecv { + impl ::pilota::thrift::Message for ServicetestException { fn encode( &self, __protocol: &mut T, @@ -1065,11 +1249,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ResultRecv", + name: "ServicetestException", })?; match self { - testServiceTest2ResultRecv::Ok(ref value) => { - __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + ServicetestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; } } __protocol.write_field_stop()?; @@ -1093,11 +1277,11 @@ pub mod auto_name { __protocol.field_begin_len(field_ident.field_type, field_ident.id); } match field_ident.id { - Some(0) => { + Some(1) => { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(testServiceTest2ResultRecv::Ok(field_ident)); + ret = Some(ServicetestException::E(field_ident)); } else { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( @@ -1144,15 +1328,15 @@ pub mod auto_name { } else { } match field_ident.id { - Some(0) => { + Some(1) => { if ret.is_none() { let field_ident = - ::decode_async( + ::decode_async( __protocol, ) .await?; - ret = Some(testServiceTest2ResultRecv::Ok(field_ident)); + ret = Some(ServicetestException::E(field_ident)); } else { return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, @@ -1182,10 +1366,10 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ResultRecv", + name: "ServicetestException", }) + match self { - testServiceTest2ResultRecv::Ok(ref value) => { - __protocol.struct_field_len(Some(0), value) + ServicetestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) } } + __protocol.field_stop_len() + __protocol.struct_end_len() @@ -1194,12 +1378,14 @@ pub mod auto_name { #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum testServiceTestResultRecv { + pub enum ServicetestResultRecv { #[derivative(Default)] Ok(Test), + + E(TestException), } - impl ::pilota::thrift::Message for testServiceTestResultRecv { + impl ::pilota::thrift::Message for ServicetestResultRecv { fn encode( &self, __protocol: &mut T, @@ -1207,12 +1393,15 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "testServiceTestResultRecv", + name: "ServicetestResultRecv", })?; match self { - testServiceTestResultRecv::Ok(ref value) => { + 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()?; @@ -1239,7 +1428,21 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(testServiceTestResultRecv::Ok(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( @@ -1294,7 +1497,23 @@ pub mod auto_name { ) .await?; - ret = Some(testServiceTestResultRecv::Ok(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 = + ::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, @@ -1324,24 +1543,28 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServiceTestResultRecv", + name: "ServicetestResultRecv", }) + match self { - testServiceTestResultRecv::Ok(ref value) => { + 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, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum testServicetestResultRecv { + pub enum serviceTest2ResultSend { #[derivative(Default)] Ok(Test), } - impl ::pilota::thrift::Message for testServicetestResultRecv { + impl ::pilota::thrift::Message for serviceTest2ResultSend { fn encode( &self, __protocol: &mut T, @@ -1349,10 +1572,10 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "testServicetestResultRecv", + name: "serviceTest2ResultSend", })?; match self { - testServicetestResultRecv::Ok(ref value) => { + serviceTest2ResultSend::Ok(ref value) => { __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; } } @@ -1381,7 +1604,7 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(testServicetestResultRecv::Ok(field_ident)); + ret = Some(serviceTest2ResultSend::Ok(field_ident)); } else { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( @@ -1436,7 +1659,7 @@ pub mod auto_name { ) .await?; - ret = Some(testServicetestResultRecv::Ok(field_ident)); + ret = Some(serviceTest2ResultSend::Ok(field_ident)); } else { return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, @@ -1466,25 +1689,24 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServicetestResultRecv", + name: "serviceTest2ResultSend", }) + match self { - testServicetestResultRecv::Ok(ref value) => { + serviceTest2ResultSend::Ok(ref value) => { __protocol.struct_field_len(Some(0), value) } } + __protocol.field_stop_len() + __protocol.struct_end_len() } } - pub const IP: &'static str = "IP"; #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum TestServiceTest2ResultSend { + pub enum serviceTestException { #[derivative(Default)] - Ok(Test), + E(TestException), } - impl ::pilota::thrift::Message for TestServiceTest2ResultSend { + impl ::pilota::thrift::Message for serviceTestException { fn encode( &self, __protocol: &mut T, @@ -1492,11 +1714,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ResultSend", + name: "serviceTestException", })?; match self { - TestServiceTest2ResultSend::Ok(ref value) => { - __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; + serviceTestException::E(ref value) => { + __protocol.write_struct_field(1, value, ::pilota::thrift::TType::Struct)?; } } __protocol.write_field_stop()?; @@ -1520,11 +1742,11 @@ pub mod auto_name { __protocol.field_begin_len(field_ident.field_type, field_ident.id); } match field_ident.id { - Some(0) => { + Some(1) => { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(TestServiceTest2ResultSend::Ok(field_ident)); + ret = Some(serviceTestException::E(field_ident)); } else { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( @@ -1571,15 +1793,15 @@ pub mod auto_name { } else { } match field_ident.id { - Some(0) => { + Some(1) => { if ret.is_none() { let field_ident = - ::decode_async( + ::decode_async( __protocol, ) .await?; - ret = Some(TestServiceTest2ResultSend::Ok(field_ident)); + ret = Some(serviceTestException::E(field_ident)); } else { return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, @@ -1609,10 +1831,10 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ResultSend", + name: "serviceTestException", }) + match self { - TestServiceTest2ResultSend::Ok(ref value) => { - __protocol.struct_field_len(Some(0), value) + serviceTestException::E(ref value) => { + __protocol.struct_field_len(Some(1), value) } } + __protocol.field_stop_len() + __protocol.struct_end_len() @@ -1621,12 +1843,14 @@ pub mod auto_name { #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum TestServiceTestResultSend { + pub enum serviceTestResultRecv { #[derivative(Default)] Ok(Test), + + E(TestException), } - impl ::pilota::thrift::Message for TestServiceTestResultSend { + impl ::pilota::thrift::Message for serviceTestResultRecv { fn encode( &self, __protocol: &mut T, @@ -1634,12 +1858,15 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTestResultSend", + name: "serviceTestResultRecv", })?; match self { - TestServiceTestResultSend::Ok(ref value) => { + 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()?; @@ -1666,7 +1893,21 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(TestServiceTestResultSend::Ok(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( @@ -1721,7 +1962,23 @@ pub mod auto_name { ) .await?; - ret = Some(TestServiceTestResultSend::Ok(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 = + ::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, @@ -1751,38 +2008,35 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTestResultSend", + name: "serviceTestResultRecv", }) + match self { - TestServiceTestResultSend::Ok(ref value) => { + 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, ::pilota::derivative::Derivative)] - #[derivative(Default)] - #[derive(Clone, PartialEq)] - pub enum TestServicetestResultSend { - #[derivative(Default)] - Ok(Test), + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct ServiceTest2ArgsRecv { + pub r#type: TEST, } - - impl ::pilota::thrift::Message for TestServicetestResultSend { + 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; - __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)?; - } - } + 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(()) @@ -1793,46 +2047,57 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - let mut ret = None; + + let mut var_1 = None; + + let mut __pilota_decoding_field_id = 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", - ), - ); - } + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); } - _ => { - __protocol.skip(field_ident.field_type)?; + __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(); } - } - __protocol.read_field_end()?; + ::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()?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + "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>( @@ -1846,46 +2111,60 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut ret = None; + let mut var_1 = None; + + let mut __pilota_decoding_field_id = 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( + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_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?; - - 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" - )); + .await?, + ); + } + _ => { + __protocol.skip(field_ident.field_type).await?; } } - _ => { - __protocol.skip(field_ident.field_type).await?; - } + + __protocol.read_field_end().await?; } + ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) } - __protocol.read_field_end().await?; + .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?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( - ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + + 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) }) } @@ -1893,33 +2172,29 @@ pub mod auto_name { #[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() + 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, Default, Clone, PartialEq)] - pub struct Test { - pub ID: ::pilota::FastStr, - - pub Id: ::pilota::FastStr, + pub struct ServiceTestArgsRecv { + pub req: TEST, } - impl ::pilota::thrift::Message for 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: "Test" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_faststr_field(1, (&self.ID).clone())?; - __protocol.write_faststr_field(2, (&self.Id).clone())?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; __protocol.write_field_stop()?; __protocol.write_struct_end()?; ::std::result::Result::Ok(()) @@ -1932,7 +2207,6 @@ pub mod auto_name { use ::pilota::{thrift::TLengthProtocolExt, Buf}; let mut var_1 = None; - let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -1949,14 +2223,9 @@ pub mod auto_name { __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 => + if field_ident.field_type == ::pilota::thrift::TType::Struct => { - var_2 = Some(__protocol.read_faststr()?); + var_1 = Some(::pilota::thrift::Message::decode(__protocol)?); } _ => { __protocol.skip(field_ident.field_type)?; @@ -1970,7 +2239,7 @@ pub mod auto_name { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `Test` field(#{}) failed, caused by: ", + "decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id )); } @@ -1981,20 +2250,11 @@ pub mod auto_name { 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(), + "field req is required".to_string(), )); }; - let data = Self { - ID: var_1, - Id: var_2, - }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) } @@ -2010,7 +2270,6 @@ pub mod auto_name { > { ::std::boxed::Box::pin(async move { let mut var_1 = None; - let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -2026,15 +2285,14 @@ pub mod auto_name { 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 => + == ::pilota::thrift::TType::Struct => { - var_2 = Some(__protocol.read_faststr().await?); + var_1 = Some( + ::decode_async( + __protocol, + ) + .await?, + ); } _ => { __protocol.skip(field_ident.field_type).await?; @@ -2048,10 +2306,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!( - "decode struct `Test` field(#{}) failed, caused by: ", - field_id - )); + err.prepend_msg(&format!("decode struct `ServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -2061,23 +2316,12 @@ pub mod auto_name { 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(), + "field req is required".to_string(), ), ); }; - let data = Self { - ID: var_1, - Id: var_2, - }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) }) } @@ -2085,9 +2329,9 @@ pub mod auto_name { 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.struct_begin_len(&::pilota::thrift::TStructIdentifier { + name: "ServiceTestArgsRecv", + }) + __protocol.struct_field_len(Some(1), &self.req) + __protocol.field_stop_len() + __protocol.struct_end_len() } @@ -2095,12 +2339,14 @@ pub mod auto_name { #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum testServiceTest2ResultSend { + pub enum ServiceTestResultSend { #[derivative(Default)] Ok(Test), + + E(TestException), } - impl ::pilota::thrift::Message for testServiceTest2ResultSend { + impl ::pilota::thrift::Message for ServiceTestResultSend { fn encode( &self, __protocol: &mut T, @@ -2108,12 +2354,15 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ResultSend", + name: "ServiceTestResultSend", })?; match self { - testServiceTest2ResultSend::Ok(ref value) => { + 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()?; @@ -2140,7 +2389,21 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(testServiceTest2ResultSend::Ok(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( @@ -2195,7 +2458,23 @@ pub mod auto_name { ) .await?; - ret = Some(testServiceTest2ResultSend::Ok(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 = + ::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, @@ -2225,38 +2504,36 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ResultSend", + name: "ServiceTestResultSend", }) + match self { - testServiceTest2ResultSend::Ok(ref value) => { + 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 testServiceTestResultSend { - #[derivative(Default)] - Ok(Test), - } + #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] + pub struct Test { + pub ID: ::pilota::FastStr, - impl ::pilota::thrift::Message for testServiceTestResultSend { + 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; - __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)?; - } - } + 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(()) @@ -2267,46 +2544,72 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - let mut ret = None; + + let mut var_1 = None; + let mut var_2 = None; + + let mut __pilota_decoding_field_id = 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", - ), - ); - } + if let ::std::result::Result::Err(mut err) = (|| { + loop { + let field_ident = __protocol.read_field_begin()?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + __protocol.field_stop_len(); + break; + } else { + __protocol.field_begin_len(field_ident.field_type, field_ident.id); } - _ => { - __protocol.skip(field_ident.field_type)?; + __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.read_field_end()?; + __protocol.field_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()?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + + let Some(var_1) = var_1 else { + return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + "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>( @@ -2320,71 +2623,99 @@ pub mod auto_name { >, > { ::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?; + let mut var_1 = None; + let mut var_2 = None; - 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" - )); - } + let mut __pilota_decoding_field_id = None; + + __protocol.read_struct_begin().await?; + if let ::std::result::Result::Err(mut err) = async { + loop { + let field_ident = __protocol.read_field_begin().await?; + if field_ident.field_type == ::pilota::thrift::TType::Stop { + break; + } else { } - _ => { - __protocol.skip(field_ident.field_type).await?; + __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>(()) } - __protocol.read_field_end().await?; + .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?; - if let Some(ret) = ret { - ::std::result::Result::Ok(ret) - } else { - ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( - ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "received empty union from remote Message", - )) - } + + 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: "testServiceTestResultSend", - }) + match self { - testServiceTestResultSend::Ok(ref value) => { - __protocol.struct_field_len(Some(0), value) - } - } + __protocol.field_stop_len() + __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 trait Service {} #[derive(PartialOrd, Hash, Eq, Ord, Debug, ::pilota::derivative::Derivative)] #[derivative(Default)] #[derive(Clone, PartialEq)] - pub enum testServicetestResultSend { + pub enum ServiceTest2ResultRecv { #[derivative(Default)] Ok(Test), } - impl ::pilota::thrift::Message for testServicetestResultSend { + impl ::pilota::thrift::Message for ServiceTest2ResultRecv { fn encode( &self, __protocol: &mut T, @@ -2392,10 +2723,10 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; __protocol.write_struct_begin(&::pilota::thrift::TStructIdentifier { - name: "testServicetestResultSend", + name: "ServiceTest2ResultRecv", })?; match self { - testServicetestResultSend::Ok(ref value) => { + ServiceTest2ResultRecv::Ok(ref value) => { __protocol.write_struct_field(0, value, ::pilota::thrift::TType::Struct)?; } } @@ -2424,7 +2755,7 @@ pub mod auto_name { if ret.is_none() { let field_ident = ::pilota::thrift::Message::decode(__protocol)?; __protocol.struct_len(&field_ident); - ret = Some(testServicetestResultSend::Ok(field_ident)); + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); } else { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( @@ -2479,7 +2810,7 @@ pub mod auto_name { ) .await?; - ret = Some(testServicetestResultSend::Ok(field_ident)); + ret = Some(ServiceTest2ResultRecv::Ok(field_ident)); } else { return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, @@ -2509,111 +2840,22 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServicetestResultSend", + name: "ServiceTest2ResultRecv", }) + match self { - testServicetestResultSend::Ok(ref value) => { + 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, ::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()) - } - } #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] - pub struct TestServiceTest2ArgsSend { - pub r#type: TEST, + pub struct ServicetestArgsSend { + pub req: TEST, + + pub Req: TEST, } - impl ::pilota::thrift::Message for TestServiceTest2ArgsSend { + impl ::pilota::thrift::Message for ServicetestArgsSend { fn encode( &self, __protocol: &mut T, @@ -2621,11 +2863,12 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ArgsSend", + name: "ServicetestArgsSend", }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __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(()) @@ -2638,6 +2881,7 @@ pub mod auto_name { use ::pilota::{thrift::TLengthProtocolExt, Buf}; let mut var_1 = None; + let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -2658,6 +2902,11 @@ pub mod auto_name { { 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)?; } @@ -2669,7 +2918,10 @@ pub mod auto_name { ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) })() { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServiceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!( + "decode struct `ServicetestArgsSend` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -2678,13 +2930,22 @@ pub mod auto_name { 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(), + "field req is required".to_string(), )); }; - - let data = Self { r#type: var_1 }; - ::std::result::Result::Ok(data) - } + 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, @@ -2698,6 +2959,7 @@ pub mod auto_name { > { ::std::boxed::Box::pin(async move { let mut var_1 = None; + let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -2722,6 +2984,17 @@ pub mod auto_name { .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?; } @@ -2734,7 +3007,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServiceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `ServicetestArgsSend` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -2744,12 +3017,23 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field r#type is required".to_string(), + "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 { r#type: var_1 }; + let data = Self { + req: var_1, + Req: var_2, + }; ::std::result::Result::Ok(data) }) } @@ -2758,31 +3042,56 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ArgsSend", - }) + __protocol.struct_field_len(Some(1), &self.r#type) + 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 TestServiceTestArgsSend { - pub req: TEST, + #[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 ::pilota::thrift::Message for TestServiceTestArgsSend { + + 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; - 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()?; + __protocol.write_i32(self.inner())?; ::std::result::Result::Ok(()) } @@ -2791,54 +3100,15 @@ pub mod auto_name { ) -> ::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) + 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>( @@ -2852,78 +3122,29 @@ pub mod auto_name { >, > { ::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( + 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, - "field req is required".to_string(), - ), - ); - }; - - let data = Self { req: var_1 }; - ::std::result::Result::Ok(data) + format!("invalid enum value for Index, value: {}", value), + ) + }, + )?) }) } 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() + __protocol.i32_len(self.inner()) } } #[derive(PartialOrd, Hash, Eq, Ord, Debug, Default, Clone, PartialEq)] - pub struct TestServicetestArgsSend { - pub req: TEST, + pub struct serviceTest2ArgsSend { + pub self_: TEST, } - impl ::pilota::thrift::Message for TestServicetestArgsSend { + impl ::pilota::thrift::Message for serviceTest2ArgsSend { fn encode( &self, __protocol: &mut T, @@ -2931,11 +3152,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "TestServicetestArgsSend", + name: "serviceTest2ArgsSend", }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; + __protocol.write_struct_field(1, &self.self_, ::pilota::thrift::TType::Struct)?; __protocol.write_field_stop()?; __protocol.write_struct_end()?; ::std::result::Result::Ok(()) @@ -2979,7 +3200,10 @@ pub mod auto_name { ::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)); + err.prepend_msg(&format!( + "decode struct `serviceTest2ArgsSend` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -2988,11 +3212,11 @@ pub mod auto_name { 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(), + "field self_ is required".to_string(), )); }; - let data = Self { req: var_1 }; + let data = Self { self_: var_1 }; ::std::result::Result::Ok(data) } @@ -3044,7 +3268,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServicetestArgsSend` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `serviceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -3054,12 +3278,12 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field req is required".to_string(), + "field self_ is required".to_string(), ), ); }; - let data = Self { req: var_1 }; + let data = Self { self_: var_1 }; ::std::result::Result::Ok(data) }) } @@ -3068,17 +3292,17 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServicetestArgsSend", - }) + __protocol.struct_field_len(Some(1), &self.req) + 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 testServiceTest2ArgsSend { - pub self_: TEST, + pub struct serviceTestArgsSend { + pub req: TEST, } - impl ::pilota::thrift::Message for testServiceTest2ArgsSend { + impl ::pilota::thrift::Message for serviceTestArgsSend { fn encode( &self, __protocol: &mut T, @@ -3086,11 +3310,11 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ArgsSend", + name: "serviceTestArgsSend", }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_struct_field(1, &self.self_, ::pilota::thrift::TType::Struct)?; + __protocol.write_struct_field(1, &self.req, ::pilota::thrift::TType::Struct)?; __protocol.write_field_stop()?; __protocol.write_struct_end()?; ::std::result::Result::Ok(()) @@ -3134,7 +3358,10 @@ pub mod auto_name { ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) })() { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServiceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!( + "decode struct `serviceTestArgsSend` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -3143,11 +3370,11 @@ pub mod auto_name { 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(), + "field req is required".to_string(), )); }; - let data = Self { self_: var_1 }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) } @@ -3199,7 +3426,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `testServiceTest2ArgsSend` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `serviceTestArgsSend` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -3209,12 +3436,12 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field self_ is required".to_string(), + "field req is required".to_string(), ), ); }; - let data = Self { self_: var_1 }; + let data = Self { req: var_1 }; ::std::result::Result::Ok(data) }) } @@ -3223,29 +3450,35 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "testServiceTest2ArgsSend", - }) + __protocol.struct_field_len(Some(1), &self.self_) + 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 testServiceTestArgsSend { - pub req: TEST, + #[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 testServiceTestArgsSend { + + 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; - 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_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(()) @@ -3256,54 +3489,46 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin()?; - if let ::std::result::Result::Err(mut err) = (|| { - loop { - let field_ident = __protocol.read_field_begin()?; - if field_ident.field_type == ::pilota::thrift::TType::Stop { - __protocol.field_stop_len(); - 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)?; + loop { + let field_ident = __protocol.read_field_begin()?; + if field_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.read_field_end()?; - __protocol.field_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)); + _ => { + __protocol.skip(field_ident.field_type)?; + } } - return ::std::result::Result::Err(err); - }; + } + __protocol.read_field_end()?; __protocol.read_struct_end()?; - - let Some(var_1) = var_1 else { - return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::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) + "received empty union from remote Message", + )) + } } fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( @@ -3317,60 +3542,46 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin().await?; - if let ::std::result::Result::Err(mut err) = async { - loop { - let field_ident = __protocol.read_field_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( + 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?, - ); - } - _ => { - __protocol.skip(field_ident.field_type).await?; + .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.read_field_end().await?; + _ => { + __protocol.skip(field_ident.field_type).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_field_end().await?; __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) + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } }) } @@ -3378,29 +3589,43 @@ pub mod auto_name { #[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() + 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, Default, Clone, PartialEq)] - pub struct testServicetestArgsSend { - pub req: TEST, + #[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 testServicetestArgsSend { + + 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; - 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_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(()) @@ -3411,54 +3636,60 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin()?; - if let ::std::result::Result::Err(mut err) = (|| { - loop { - let field_ident = __protocol.read_field_begin()?; - if field_ident.field_type == ::pilota::thrift::TType::Stop { - __protocol.field_stop_len(); - 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)?); + loop { + let field_ident = __protocol.read_field_begin()?; + if field_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", + ), + ); } - _ => { - __protocol.skip(field_ident.field_type)?; + } + 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.read_field_end()?; - __protocol.field_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)); + _ => { + __protocol.skip(field_ident.field_type)?; + } } - return ::std::result::Result::Err(err); - }; + } + __protocol.read_field_end()?; __protocol.read_struct_end()?; - - let Some(var_1) = var_1 else { - return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::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) + "received empty union from remote Message", + )) + } } fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( @@ -3472,60 +3703,62 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin().await?; - if let ::std::result::Result::Err(mut err) = async { - loop { - let field_ident = __protocol.read_field_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( + 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?, - ); - } - _ => { - __protocol.skip(field_ident.field_type).await?; + .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?; - __protocol.read_field_end().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?; + } } - ::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_field_end().await?; __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) + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + ::pilota::thrift::ProtocolExceptionKind::InvalidData, + "received empty union from remote Message", + )) + } }) } @@ -3533,17 +3766,25 @@ pub mod auto_name { #[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() + 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 TestServiceTest2ArgsRecv { - pub r#type: TEST, + pub struct ServicetestArgsRecv { + pub req: TEST, + + pub Req: TEST, } - impl ::pilota::thrift::Message for TestServiceTest2ArgsRecv { + impl ::pilota::thrift::Message for ServicetestArgsRecv { fn encode( &self, __protocol: &mut T, @@ -3551,11 +3792,12 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ArgsRecv", + name: "ServicetestArgsRecv", }; __protocol.write_struct_begin(&struct_ident)?; - __protocol.write_struct_field(1, &self.r#type, ::pilota::thrift::TType::Struct)?; + __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(()) @@ -3568,6 +3810,7 @@ pub mod auto_name { use ::pilota::{thrift::TLengthProtocolExt, Buf}; let mut var_1 = None; + let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -3588,6 +3831,11 @@ pub mod auto_name { { 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)?; } @@ -3599,7 +3847,10 @@ pub mod auto_name { ::std::result::Result::Ok::<_, ::pilota::thrift::ThriftException>(()) })() { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServiceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!( + "decode struct `ServicetestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -3608,11 +3859,20 @@ pub mod auto_name { 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(), + "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 { r#type: var_1 }; + let data = Self { + req: var_1, + Req: var_2, + }; ::std::result::Result::Ok(data) } @@ -3628,6 +3888,7 @@ pub mod auto_name { > { ::std::boxed::Box::pin(async move { let mut var_1 = None; + let mut var_2 = None; let mut __pilota_decoding_field_id = None; @@ -3652,6 +3913,17 @@ pub mod auto_name { .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?; } @@ -3664,7 +3936,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServiceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `ServicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -3674,12 +3946,23 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field r#type is required".to_string(), + "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 { r#type: var_1 }; + let data = Self { + req: var_1, + Req: var_2, + }; ::std::result::Result::Ok(data) }) } @@ -3688,29 +3971,41 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTest2ArgsRecv", - }) + __protocol.struct_field_len(Some(1), &self.r#type) + 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, Default, Clone, PartialEq)] - pub struct TestServiceTestArgsRecv { - pub req: TEST, + #[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 TestServiceTestArgsRecv { + + 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; - 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_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(()) @@ -3721,54 +4016,60 @@ pub mod auto_name { ) -> ::std::result::Result { #[allow(unused_imports)] use ::pilota::{thrift::TLengthProtocolExt, Buf}; - - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin()?; - if let ::std::result::Result::Err(mut err) = (|| { - loop { - let field_ident = __protocol.read_field_begin()?; - if field_ident.field_type == ::pilota::thrift::TType::Stop { - __protocol.field_stop_len(); - 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)?); + loop { + let field_ident = __protocol.read_field_begin()?; + if field_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", + ), + ); } - _ => { - __protocol.skip(field_ident.field_type)?; + } + 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.read_field_end()?; - __protocol.field_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)); + _ => { + __protocol.skip(field_ident.field_type)?; + } } - return ::std::result::Result::Err(err); - }; + } + __protocol.read_field_end()?; __protocol.read_struct_end()?; - - let Some(var_1) = var_1 else { - return ::std::result::Result::Err(::pilota::thrift::new_protocol_exception( + if let Some(ret) = ret { + ::std::result::Result::Ok(ret) + } else { + ::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) + "received empty union from remote Message", + )) + } } fn decode_async<'a, T: ::pilota::thrift::TAsyncInputProtocol>( @@ -3782,20 +4083,186 @@ pub mod auto_name { >, > { ::std::boxed::Box::pin(async move { - let mut var_1 = None; - - let mut __pilota_decoding_field_id = None; - + let mut ret = None; __protocol.read_struct_begin().await?; - if let ::std::result::Result::Err(mut err) = async { - loop { - let field_ident = __protocol.read_field_begin().await?; - if field_ident.field_type == ::pilota::thrift::TType::Stop { - break; - } else { - } - __pilota_decoding_field_id = field_ident.id; - match field_ident.id { + 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, 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 => @@ -3819,7 +4286,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServiceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `serviceTest2ArgsRecv` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -3829,12 +4296,12 @@ pub mod auto_name { return ::std::result::Result::Err( ::pilota::thrift::new_protocol_exception( ::pilota::thrift::ProtocolExceptionKind::InvalidData, - "field req is required".to_string(), + "field self_ is required".to_string(), ), ); }; - let data = Self { req: var_1 }; + let data = Self { self_: var_1 }; ::std::result::Result::Ok(data) }) } @@ -3843,17 +4310,17 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServiceTestArgsRecv", - }) + __protocol.struct_field_len(Some(1), &self.req) + name: "serviceTest2ArgsRecv", + }) + __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 TestServicetestArgsRecv { + pub struct serviceTestArgsRecv { pub req: TEST, } - impl ::pilota::thrift::Message for TestServicetestArgsRecv { + impl ::pilota::thrift::Message for serviceTestArgsRecv { fn encode( &self, __protocol: &mut T, @@ -3861,7 +4328,7 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "TestServicetestArgsRecv", + name: "serviceTestArgsRecv", }; __protocol.write_struct_begin(&struct_ident)?; @@ -3909,7 +4376,10 @@ pub mod auto_name { ::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)); + err.prepend_msg(&format!( + "decode struct `serviceTestArgsRecv` field(#{}) failed, caused by: ", + field_id + )); } return ::std::result::Result::Err(err); }; @@ -3974,7 +4444,7 @@ pub mod auto_name { .await { if let Some(field_id) = __pilota_decoding_field_id { - err.prepend_msg(&format!("decode struct `TestServicetestArgsRecv` field(#{}) failed, caused by: ", field_id)); + err.prepend_msg(&format!("decode struct `serviceTestArgsRecv` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -3998,11 +4468,655 @@ pub mod auto_name { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "TestServicetestArgsRecv", + 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 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 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, ::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 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/auto_name.thrift b/pilota-build/test_data/thrift/auto_name.thrift index 9461df78..badc2e0c 100644 --- a/pilota-build/test_data/thrift/auto_name.thrift +++ b/pilota-build/test_data/thrift/auto_name.thrift @@ -16,14 +16,18 @@ enum Index { a, } -service TestService { - Test test(1: TEST req); - Test Test(1: TEST Req); +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 testService { - Test test(1: TEST req); - Test Test(1: TEST Req); +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/normal.rs b/pilota-build/test_data/thrift/normal.rs index 465a08f4..cc75ee1f 100644 --- a/pilota-build/test_data/thrift/normal.rs +++ b/pilota-build/test_data/thrift/normal.rs @@ -654,7 +654,7 @@ pub mod normal { ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; - let struct_ident = ::pilota::thrift::TStructIdentifier { name: "b" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; __protocol.write_struct_begin(&struct_ident)?; if let Some(value) = self.a.as_ref() { @@ -704,7 +704,7 @@ pub mod normal { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `b` field(#{}) failed, caused by: ", + "decode struct `B` field(#{}) failed, caused by: ", field_id )); } @@ -763,7 +763,7 @@ pub mod normal { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `b` field(#{}) failed, caused by: ", + "decode struct `B` field(#{}) failed, caused by: ", field_id )); } @@ -779,7 +779,7 @@ pub mod normal { 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_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + self .a .as_ref() @@ -1176,7 +1176,7 @@ pub mod normal { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "STException", + name: "StException", }; __protocol.write_struct_begin(&struct_ident)?; @@ -1227,7 +1227,7 @@ pub mod normal { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `STException` field(#{}) failed, caused by: ", + "decode struct `StException` field(#{}) failed, caused by: ", field_id )); } @@ -1283,7 +1283,7 @@ pub mod normal { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `STException` field(#{}) failed, caused by: ", + "decode struct `StException` field(#{}) failed, caused by: ", field_id )); } @@ -1300,7 +1300,7 @@ pub mod normal { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "STException", + name: "StException", }) + self .message .as_ref() diff --git a/pilota-build/test_data/thrift/pilota_name.rs b/pilota-build/test_data/thrift/pilota_name.rs index 37d14231..c21849f1 100644 --- a/pilota-build/test_data/thrift/pilota_name.rs +++ b/pilota-build/test_data/thrift/pilota_name.rs @@ -13,7 +13,7 @@ pub mod pilota_name { ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; - let struct_ident = ::pilota::thrift::TStructIdentifier { name: "TEST" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test2" }; __protocol.write_struct_begin(&struct_ident)?; __protocol.write_faststr_field(1, (&self.id).clone())?; @@ -61,7 +61,7 @@ pub mod pilota_name { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `TEST` field(#{}) failed, caused by: ", + "decode struct `Test2` field(#{}) failed, caused by: ", field_id )); } @@ -124,7 +124,7 @@ pub mod pilota_name { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `TEST` field(#{}) failed, caused by: ", + "decode struct `Test2` field(#{}) failed, caused by: ", field_id )); } @@ -149,7 +149,7 @@ pub mod pilota_name { fn size(&self, __protocol: &mut T) -> usize { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; - __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "TEST" }) + __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() @@ -465,7 +465,7 @@ pub mod pilota_name { ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; - let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test1" }; __protocol.write_struct_begin(&struct_ident)?; __protocol.write_faststr_field(1, (&self.id).clone())?; @@ -520,7 +520,7 @@ pub mod pilota_name { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `Test` field(#{}) failed, caused by: ", + "decode struct `Test1` field(#{}) failed, caused by: ", field_id )); } @@ -599,7 +599,7 @@ pub mod pilota_name { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `Test` field(#{}) failed, caused by: ", + "decode struct `Test1` field(#{}) failed, caused by: ", field_id )); } @@ -635,7 +635,7 @@ pub mod pilota_name { fn size(&self, __protocol: &mut T) -> usize { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; - __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + __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() diff --git a/pilota-build/test_data/thrift/wrapper_arc.rs b/pilota-build/test_data/thrift/wrapper_arc.rs index 46e11d5a..6134c29e 100644 --- a/pilota-build/test_data/thrift/wrapper_arc.rs +++ b/pilota-build/test_data/thrift/wrapper_arc.rs @@ -579,7 +579,7 @@ pub mod wrapper_arc { ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; - let struct_ident = ::pilota::thrift::TStructIdentifier { name: "TEST" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "Test" }; __protocol.write_struct_begin(&struct_ident)?; __protocol.write_faststr_field(1, (&self.id).clone())?; @@ -722,7 +722,7 @@ pub mod wrapper_arc { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `TEST` field(#{}) failed, caused by: ", + "decode struct `Test` field(#{}) failed, caused by: ", field_id )); } @@ -843,7 +843,7 @@ pub mod wrapper_arc { ::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)); + err.prepend_msg(&format!("decode struct `Test` field(#{}) failed, caused by: ", field_id)); } return ::std::result::Result::Err(err); }; @@ -886,7 +886,7 @@ pub mod wrapper_arc { fn size(&self, __protocol: &mut T) -> usize { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; - __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "TEST" }) + __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { name: "Test" }) + __protocol.faststr_field_len(Some(1), &self.id) + __protocol.list_field_len( Some(2), diff --git a/pilota-build/test_data/unknown_fields.rs b/pilota-build/test_data/unknown_fields.rs index 38089f6c..beddca82 100644 --- a/pilota-build/test_data/unknown_fields.rs +++ b/pilota-build/test_data/unknown_fields.rs @@ -194,7 +194,7 @@ pub mod unknown_fields { ) -> ::std::result::Result<(), ::pilota::thrift::ThriftException> { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; - let struct_ident = ::pilota::thrift::TStructIdentifier { name: "b" }; + let struct_ident = ::pilota::thrift::TStructIdentifier { name: "B" }; __protocol.write_struct_begin(&struct_ident)?; if let Some(value) = self.a.as_ref() { @@ -255,7 +255,7 @@ pub mod unknown_fields { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `b` field(#{}) failed, caused by: ", + "decode struct `B` field(#{}) failed, caused by: ", field_id )); } @@ -317,7 +317,7 @@ pub mod unknown_fields { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `b` field(#{}) failed, caused by: ", + "decode struct `B` field(#{}) failed, caused by: ", field_id )); } @@ -336,7 +336,7 @@ pub mod unknown_fields { 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_begin_len(&::pilota::thrift::TStructIdentifier { name: "B" }) + self .a .as_ref() @@ -1362,7 +1362,7 @@ pub mod unknown_fields { #[allow(unused_imports)] use ::pilota::thrift::TOutputProtocolExt; let struct_ident = ::pilota::thrift::TStructIdentifier { - name: "STException", + name: "StException", }; __protocol.write_struct_begin(&struct_ident)?; @@ -1424,7 +1424,7 @@ pub mod unknown_fields { })() { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `STException` field(#{}) failed, caused by: ", + "decode struct `StException` field(#{}) failed, caused by: ", field_id )); } @@ -1483,7 +1483,7 @@ pub mod unknown_fields { { if let Some(field_id) = __pilota_decoding_field_id { err.prepend_msg(&format!( - "decode struct `STException` field(#{}) failed, caused by: ", + "decode struct `StException` field(#{}) failed, caused by: ", field_id )); } @@ -1503,7 +1503,7 @@ pub mod unknown_fields { #[allow(unused_imports)] use ::pilota::thrift::TLengthProtocolExt; __protocol.struct_begin_len(&::pilota::thrift::TStructIdentifier { - name: "STException", + name: "StException", }) + self .message .as_ref()