// @generated by Thrift for thrift/compiler/test/fixtures/rust-annotations/src/module.thrift // This file is probably not the place you want to edit! //! Thrift service definitions for `module`. /// Service definitions for `Service1`. pub mod service1 { #[derive(Clone, Debug)] pub enum RExn { #[doc(hidden)] Success(crate::types::T6), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for RExn { fn from(err: crate::errors::service1::RError) -> Self { match err { crate::errors::service1::RError::ApplicationException(aexn) => RExn::ApplicationException(aexn), crate::errors::service1::RError::ThriftError(err) => RExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for RExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for RExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for RExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for RExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for RExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("R"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::Struct, 0i16, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for RExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::Struct, 0i32), false) => { once = true; alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?)); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "RExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "RExn"), ) .into(), ) } } } /// Service definitions for `S2`. pub mod s2 { #[derive(Clone, Debug)] pub enum RExn { #[doc(hidden)] Success(crate::types::T6), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for RExn { fn from(err: crate::errors::s2::RError) -> Self { match err { crate::errors::s2::RError::ApplicationException(aexn) => RExn::ApplicationException(aexn), crate::errors::s2::RError::ThriftError(err) => RExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for RExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for RExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for RExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for RExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for RExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("R"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::Struct, 0i16, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for RExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::Struct, 0i32), false) => { once = true; alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?)); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "RExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "RExn"), ) .into(), ) } } } /// Service definitions for `AllMethods`. pub mod all_methods { #[derive(Clone, Debug)] pub enum FooExn { #[doc(hidden)] Success(()), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From<::anyhow::Error> for FooExn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } impl ::std::convert::From for FooExn { fn from(err: crate::errors::all_methods::FooError) -> Self { match err { crate::errors::all_methods::FooError::ApplicationException(aexn) => FooExn::ApplicationException(aexn), crate::errors::all_methods::FooError::ThriftError(err) => FooExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for FooExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for FooExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for FooExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Foo"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::Void, 0i16, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for FooExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Void, 0), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = Self::Success(()); loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::Void, 0i32), false) => { once = true; alt = Self::Success(::fbthrift::Deserialize::read(p)?); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "FooExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt) } } #[derive(Clone, Debug)] pub enum BarExn { #[doc(hidden)] Success(::std::string::String), se(crate::types::SomeError), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for BarExn { fn from(exn: crate::types::SomeError) -> Self { Self::se(exn) } } impl ::std::convert::From<::anyhow::Error> for BarExn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } impl ::std::convert::From for BarExn { fn from(err: crate::errors::all_methods::BarError) -> Self { match err { crate::errors::all_methods::BarError::se(err) => BarExn::se(err), crate::errors::all_methods::BarError::ApplicationException(aexn) => BarExn::ApplicationException(aexn), crate::errors::all_methods::BarError::ThriftError(err) => BarExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for BarExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for BarExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), Self::se(exn) => exn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for BarExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl ::fbthrift::GetTType for BarExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Bar"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::String, 0i16, ); inner.write(p); p.write_field_end(); } Self::se(inner) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for BarExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::String, 0), ::fbthrift::Field::new("se", ::fbthrift::TType::Struct, 1), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::String, 0i32), false) => { once = true; alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?)); } ((::fbthrift::TType::Struct, 1), false) => { once = true; alt = ::std::option::Option::Some(Self::se(::fbthrift::Deserialize::read(p)?)); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "BarExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "BarExn"), ) .into(), ) } } } /// Service definitions for `OneMethod`. pub mod one_method { #[derive(Clone, Debug)] pub enum FooExn { #[doc(hidden)] Success(()), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From<::anyhow::Error> for FooExn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } impl ::std::convert::From for FooExn { fn from(err: crate::errors::one_method::FooError) -> Self { match err { crate::errors::one_method::FooError::ApplicationException(aexn) => FooExn::ApplicationException(aexn), crate::errors::one_method::FooError::ThriftError(err) => FooExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for FooExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for FooExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for FooExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Foo"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::Void, 0i16, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for FooExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Void, 0), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = Self::Success(()); loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::Void, 0i32), false) => { once = true; alt = Self::Success(::fbthrift::Deserialize::read(p)?); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "FooExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt) } } #[derive(Clone, Debug)] pub enum BarExn { #[doc(hidden)] Success(::std::string::String), se(crate::types::SomeError), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for BarExn { fn from(exn: crate::types::SomeError) -> Self { Self::se(exn) } } impl ::std::convert::From for BarExn { fn from(err: crate::errors::one_method::BarError) -> Self { match err { crate::errors::one_method::BarError::se(err) => BarExn::se(err), crate::errors::one_method::BarError::ApplicationException(aexn) => BarExn::ApplicationException(aexn), crate::errors::one_method::BarError::ThriftError(err) => BarExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for BarExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for BarExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), Self::se(exn) => exn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for BarExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl ::fbthrift::GetTType for BarExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Bar"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::String, 0i16, ); inner.write(p); p.write_field_end(); } Self::se(inner) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for BarExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::String, 0), ::fbthrift::Field::new("se", ::fbthrift::TType::Struct, 1), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::String, 0i32), false) => { once = true; alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?)); } ((::fbthrift::TType::Struct, 1), false) => { once = true; alt = ::std::option::Option::Some(Self::se(::fbthrift::Deserialize::read(p)?)); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "BarExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "BarExn"), ) .into(), ) } } } /// Service definitions for `OneMethodOptOut`. pub mod one_method_opt_out { #[derive(Clone, Debug)] pub enum FooExn { #[doc(hidden)] Success(()), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From<::anyhow::Error> for FooExn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } impl ::std::convert::From for FooExn { fn from(err: crate::errors::one_method_opt_out::FooError) -> Self { match err { crate::errors::one_method_opt_out::FooError::ApplicationException(aexn) => FooExn::ApplicationException(aexn), crate::errors::one_method_opt_out::FooError::ThriftError(err) => FooExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for FooExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for FooExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for FooExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Foo"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::Void, 0i16, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for FooExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Void, 0), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = Self::Success(()); loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::Void, 0i32), false) => { once = true; alt = Self::Success(::fbthrift::Deserialize::read(p)?); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "FooExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt) } } #[derive(Clone, Debug)] pub enum BarExn { #[doc(hidden)] Success(::std::string::String), se(crate::types::SomeError), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for BarExn { fn from(exn: crate::types::SomeError) -> Self { Self::se(exn) } } impl ::std::convert::From for BarExn { fn from(err: crate::errors::one_method_opt_out::BarError) -> Self { match err { crate::errors::one_method_opt_out::BarError::se(err) => BarExn::se(err), crate::errors::one_method_opt_out::BarError::ApplicationException(aexn) => BarExn::ApplicationException(aexn), crate::errors::one_method_opt_out::BarError::ThriftError(err) => BarExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for BarExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for BarExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"), Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"), Self::ApplicationException(aexn) => aexn.exn_is_declared(), Self::se(exn) => exn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for BarExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl ::fbthrift::GetTType for BarExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Bar"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::String, 0i16, ); inner.write(p); p.write_field_end(); } Self::se(inner) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); inner.write(p); p.write_field_end(); } Self::ApplicationException(_aexn) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for BarExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::String, 0), ::fbthrift::Field::new("se", ::fbthrift::TType::Struct, 1), ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } ((::fbthrift::TType::String, 0i32), false) => { once = true; alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?)); } ((::fbthrift::TType::Struct, 1), false) => { once = true; alt = ::std::option::Option::Some(Self::se(::fbthrift::Deserialize::read(p)?)); } ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "BarExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "BarExn"), ) .into(), ) } } }