// @generated by Thrift for thrift/compiler/test/fixtures/doctext/src/module.thrift // This file is probably not the place you want to edit! //! Thrift service definitions for `module`. /// Service definitions for `C`. pub mod c { #![doc = "Detailed overview of service"] #[derive(Clone, Debug)] pub enum FExn { #[doc(hidden)] Success(()), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for FExn { fn from(err: crate::errors::c::FError) -> Self { match err { crate::errors::c::FError::ApplicationException(aexn) => FExn::ApplicationException(aexn), crate::errors::c::FError::ThriftError(err) => FExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for FExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for FExn { 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 FExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for FExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for FExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("F"); 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 FExn 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 {}", "FExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt) } } #[derive(Clone, Debug)] pub enum NumbersStreamExn { #[doc(hidden)] Success(crate::types::number), ApplicationException(::fbthrift::ApplicationException), } impl ::fbthrift::ExceptionInfo for NumbersStreamExn { 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 NumbersStreamExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::std::convert::From<::fbthrift::ApplicationException> for NumbersStreamExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::GetTType for NumbersStreamExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

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

::fbthrift::Deserialize

for NumbersStreamExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Stream, 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::I32, 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 {}", "NumbersStreamExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "NumbersStreamExn"), ) .into(), ) } } #[derive(Clone, Debug)] pub enum NumbersResponseExn { #[doc(hidden)] Success(()), ApplicationException(::fbthrift::ApplicationException), } impl ::fbthrift::ExceptionInfo for NumbersResponseExn { 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 NumbersResponseExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::std::convert::From<::fbthrift::ApplicationException> for NumbersResponseExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::GetTType for NumbersResponseExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Void; } impl

::fbthrift::Serialize

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

::fbthrift::Deserialize

for NumbersResponseExn where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static RETURNS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("Success", ::fbthrift::TType::Stream, 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 {}", "NumbersResponseExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt) } } pub enum NumbersExn { #[doc(hidden)] Success( ::futures::stream::BoxStream<'static, ::std::result::Result> ), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for NumbersExn { fn from(err: crate::errors::c::NumbersError) -> Self { match err { crate::errors::c::NumbersError::ApplicationException(aexn) => NumbersExn::ApplicationException(aexn), crate::errors::c::NumbersError::ThriftError(err) => NumbersExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for NumbersExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for NumbersExn { 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 NumbersExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, } } } impl ::fbthrift::GetTType for NumbersExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } #[derive(Clone, Debug)] pub enum ThingExn { #[doc(hidden)] Success(::std::string::String), bang(crate::types::Bang), ApplicationException(::fbthrift::ApplicationException), } impl ::std::convert::From for ThingExn { fn from(exn: crate::types::Bang) -> Self { Self::bang(exn) } } impl ::std::convert::From for ThingExn { fn from(err: crate::errors::c::ThingError) -> Self { match err { crate::errors::c::ThingError::bang(err) => ThingExn::bang(err), crate::errors::c::ThingError::ApplicationException(aexn) => ThingExn::ApplicationException(aexn), crate::errors::c::ThingError::ThriftError(err) => ThingExn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for ThingExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for ThingExn { fn exn_name(&self) -> &'static str { match self { Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"), Self::ApplicationException(aexn) => aexn.exn_name(), Self::bang(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::bang(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::bang(exn) => exn.exn_is_declared(), } } } impl ::fbthrift::ResultInfo for ThingExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::Success(_) => ::fbthrift::ResultType::Return, Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, Self::bang(_exn) => fbthrift::ResultType::Error, } } } impl ::fbthrift::GetTType for ThingExn { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } impl

::fbthrift::Serialize

for ThingExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { if let Self::ApplicationException(aexn) = self { return aexn.write(p); } p.write_struct_begin("Thing"); match self { Self::Success(inner) => { p.write_field_begin( "Success", ::fbthrift::TType::String, 0i16, ); inner.write(p); p.write_field_end(); } Self::bang(inner) => { p.write_field_begin( "bang", ::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 ThingExn 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("bang", ::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::bang(::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 {}", "ThingExn", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "ThingExn"), ) .into(), ) } } }