// @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 { 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::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for RExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl

::fbthrift::Serialize

for RExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for RExn { type Success = crate::types::T6; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("R"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::Struct, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } } /// Service definitions for `S2`. pub mod s2 { #[derive(Clone, Debug)] pub enum RExn { 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::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for RExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl

::fbthrift::Serialize

for RExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for RExn { type Success = crate::types::T6; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("R"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::Struct, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } } /// Service definitions for `AllMethods`. pub mod all_methods { #[derive(Clone, Debug)] pub enum FooExn { 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::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for FooExn { type Success = (); fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Foo"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::Void, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } #[derive(Clone, Debug)] pub enum BarExn { 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::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { 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::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for BarExn { type Success = ::std::string::String; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Bar"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::String, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::se(inner)) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); ::fbthrift::Serialize::write(inner, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } } /// Service definitions for `OneMethod`. pub mod one_method { #[derive(Clone, Debug)] pub enum FooExn { 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::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for FooExn { type Success = (); fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Foo"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::Void, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } #[derive(Clone, Debug)] pub enum BarExn { 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::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { 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::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for BarExn { type Success = ::std::string::String; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Bar"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::String, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::se(inner)) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); ::fbthrift::Serialize::write(inner, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } } /// Service definitions for `OneMethodOptOut`. pub mod one_method_opt_out { #[derive(Clone, Debug)] pub enum FooExn { 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::ApplicationException(aexn) => aexn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for FooExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl

::fbthrift::Serialize

for FooExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for FooExn { type Success = (); fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Foo"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::Void, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } #[derive(Clone, Debug)] pub enum BarExn { 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::ApplicationException(aexn) => aexn.exn_name(), Self::se(exn) => exn.exn_name(), } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), Self::se(exn) => exn.exn_value(), } } fn exn_is_declared(&self) -> bool { match self { 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::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::se(_exn) => fbthrift::ResultType::Error, } } } impl

::fbthrift::Serialize

for BarExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for BarExn { type Success = ::std::string::String; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("Bar"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", ::fbthrift::TType::String, 0i16); ::fbthrift::Serialize::write(_success, p); p.write_field_end(); } ::std::result::Result::Err(Self::se(inner)) => { p.write_field_begin( "se", ::fbthrift::TType::Struct, 1, ); ::fbthrift::Serialize::write(inner, p); p.write_field_end(); } ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } }