// @generated by Thrift for thrift/compiler/test/fixtures/exceptions/src/module.thrift // This file is probably not the place you want to edit! //! Server definitions for `module`. #![recursion_limit = "100000000"] #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, unused_imports, clippy::all)] #[doc(inline)] pub use :: as types; pub mod errors { #[doc(inline)] pub use ::::services::raiser; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::raiser::*; } pub(crate) use crate as server; pub(crate) use ::::services; #[::async_trait::async_trait] pub trait Raiser: ::std::marker::Send + ::std::marker::Sync + 'static { async fn doBland( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoBlandExn> { ::std::result::Result::Err(crate::services::raiser::DoBlandExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "Raiser", "doBland", ), )) } async fn doRaise( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoRaiseExn> { ::std::result::Result::Err(crate::services::raiser::DoRaiseExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "Raiser", "doRaise", ), )) } async fn get200( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get200Exn> { ::std::result::Result::Err(crate::services::raiser::Get200Exn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "Raiser", "get200", ), )) } async fn get500( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get500Exn> { ::std::result::Result::Err(crate::services::raiser::Get500Exn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "Raiser", "get500", ), )) } } #[::async_trait::async_trait] impl Raiser for ::std::boxed::Box where T: Raiser + Send + Sync + ?Sized, { async fn doBland( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoBlandExn> { (**self).doBland( ).await } async fn doRaise( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoRaiseExn> { (**self).doRaise( ).await } async fn get200( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get200Exn> { (**self).get200( ).await } async fn get500( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get500Exn> { (**self).get500( ).await } } #[::async_trait::async_trait] impl Raiser for ::std::sync::Arc where T: Raiser + Send + Sync + ?Sized, { async fn doBland( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoBlandExn> { (**self).doBland( ).await } async fn doRaise( &self, ) -> ::std::result::Result<(), crate::services::raiser::DoRaiseExn> { (**self).doRaise( ).await } async fn get200( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get200Exn> { (**self).get200( ).await } async fn get500( &self, ) -> ::std::result::Result<::std::string::String, crate::services::raiser::Get500Exn> { (**self).get500( ).await } } /// Processor for Raiser's methods. #[derive(Clone, Debug)] pub struct RaiserProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_Raiser_doBland { } impl ::fbthrift::Deserialize

for self::Args_Raiser_doBland { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "Raiser.doBland"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ ]; let _ = p.read_struct_begin(|_| ())?; loop { let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?; match (fty, fid as ::std::primitive::i32) { (::fbthrift::TType::Stop, _) => break, (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self { }) } } struct Args_Raiser_doRaise { } impl ::fbthrift::Deserialize

for self::Args_Raiser_doRaise { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "Raiser.doRaise"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ ]; let _ = p.read_struct_begin(|_| ())?; loop { let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?; match (fty, fid as ::std::primitive::i32) { (::fbthrift::TType::Stop, _) => break, (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self { }) } } struct Args_Raiser_get200 { } impl ::fbthrift::Deserialize

for self::Args_Raiser_get200 { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "Raiser.get200"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ ]; let _ = p.read_struct_begin(|_| ())?; loop { let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?; match (fty, fid as ::std::primitive::i32) { (::fbthrift::TType::Stop, _) => break, (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self { }) } } struct Args_Raiser_get500 { } impl ::fbthrift::Deserialize

for self::Args_Raiser_get500 { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "Raiser.get500"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ ]; let _ = p.read_struct_begin(|_| ())?; loop { let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?; match (fty, fid as ::std::primitive::i32) { (::fbthrift::TType::Stop, _) => break, (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self { }) } } impl RaiserProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: Raiser, R: ::fbthrift::RequestContext + ::std::marker::Send + ::std::marker::Sync + 'static, RS: ::fbthrift::ReplyState + ::std::marker::Send + ::std::marker::Sync + 'static, ::ContextStack: ::fbthrift::ContextStack::Frame> + ::std::marker::Send + ::std::marker::Sync, ::fbthrift::ProtocolDecoded

: ::std::clone::Clone, ::fbthrift::ProtocolEncodedFinal

: ::std::clone::Clone + ::fbthrift::BufExt, { pub fn new(service: H) -> Self { Self { service, supa: ::fbthrift::NullServiceProcessor::new(), _phantom: ::std::marker::PhantomData, } } pub fn into_inner(self) -> H { self.service } #[::tracing::instrument(skip_all, name = "handler", fields(method = "Raiser.doBland"))] async fn handle_doBland<'a>( &'a self, p: &'a mut P::Deserializer, req: ::fbthrift::ProtocolDecoded

, req_ctxt: &R, reply_state: ::std::sync::Arc, _seqid: ::std::primitive::u32, ) -> ::anyhow::Result<()> { use ::const_cstr::const_cstr; use ::futures::FutureExt as _; const_cstr! { SERVICE_NAME = "Raiser"; METHOD_NAME = "doBland"; SERVICE_METHOD_NAME = "Raiser.doBland"; } let mut ctx_stack = req_ctxt.get_context_stack( SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), )?; ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?; let _args: self::Args_Raiser_doBland = ::fbthrift::Deserialize::read(p)?; let bytes_read = ::fbthrift::help::buf_len(&req)?; ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, ::fbthrift::SerializedMessage { protocol: P::PROTOCOL_ID, method_name: METHOD_NAME.as_cstr(), buffer: req, })?; ::fbthrift::ContextStack::post_read(&mut ctx_stack, bytes_read)?; let res = ::std::panic::AssertUnwindSafe( self.service.doBland( ) ) .catch_unwind() .await; // nested results - panic catch on the outside, method on the inside let res = match res { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { ::tracing::trace!(method = "Raiser.doBland", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "Raiser.doBland", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("Raiser.doBland", exn); ::tracing::error!(method = "Raiser.doBland", panic = ?aexn); ::std::result::Result::Err(crate::services::raiser::DoBlandExn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "doBland", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, res, )?; reply_state.send_reply(env); Ok(()) } #[::tracing::instrument(skip_all, name = "handler", fields(method = "Raiser.doRaise"))] async fn handle_doRaise<'a>( &'a self, p: &'a mut P::Deserializer, req: ::fbthrift::ProtocolDecoded

, req_ctxt: &R, reply_state: ::std::sync::Arc, _seqid: ::std::primitive::u32, ) -> ::anyhow::Result<()> { use ::const_cstr::const_cstr; use ::futures::FutureExt as _; const_cstr! { SERVICE_NAME = "Raiser"; METHOD_NAME = "doRaise"; SERVICE_METHOD_NAME = "Raiser.doRaise"; } let mut ctx_stack = req_ctxt.get_context_stack( SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), )?; ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?; let _args: self::Args_Raiser_doRaise = ::fbthrift::Deserialize::read(p)?; let bytes_read = ::fbthrift::help::buf_len(&req)?; ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, ::fbthrift::SerializedMessage { protocol: P::PROTOCOL_ID, method_name: METHOD_NAME.as_cstr(), buffer: req, })?; ::fbthrift::ContextStack::post_read(&mut ctx_stack, bytes_read)?; let res = ::std::panic::AssertUnwindSafe( self.service.doRaise( ) ) .catch_unwind() .await; // nested results - panic catch on the outside, method on the inside let res = match res { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { ::tracing::trace!(method = "Raiser.doRaise", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "Raiser.doRaise", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("Raiser.doRaise", exn); ::tracing::error!(method = "Raiser.doRaise", panic = ?aexn); ::std::result::Result::Err(crate::services::raiser::DoRaiseExn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "doRaise", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, res, )?; reply_state.send_reply(env); Ok(()) } #[::tracing::instrument(skip_all, name = "handler", fields(method = "Raiser.get200"))] async fn handle_get200<'a>( &'a self, p: &'a mut P::Deserializer, req: ::fbthrift::ProtocolDecoded

, req_ctxt: &R, reply_state: ::std::sync::Arc, _seqid: ::std::primitive::u32, ) -> ::anyhow::Result<()> { use ::const_cstr::const_cstr; use ::futures::FutureExt as _; const_cstr! { SERVICE_NAME = "Raiser"; METHOD_NAME = "get200"; SERVICE_METHOD_NAME = "Raiser.get200"; } let mut ctx_stack = req_ctxt.get_context_stack( SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), )?; ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?; let _args: self::Args_Raiser_get200 = ::fbthrift::Deserialize::read(p)?; let bytes_read = ::fbthrift::help::buf_len(&req)?; ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, ::fbthrift::SerializedMessage { protocol: P::PROTOCOL_ID, method_name: METHOD_NAME.as_cstr(), buffer: req, })?; ::fbthrift::ContextStack::post_read(&mut ctx_stack, bytes_read)?; let res = ::std::panic::AssertUnwindSafe( self.service.get200( ) ) .catch_unwind() .await; // nested results - panic catch on the outside, method on the inside let res = match res { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { ::tracing::trace!(method = "Raiser.get200", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "Raiser.get200", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("Raiser.get200", exn); ::tracing::error!(method = "Raiser.get200", panic = ?aexn); ::std::result::Result::Err(crate::services::raiser::Get200Exn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "get200", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, res, )?; reply_state.send_reply(env); Ok(()) } #[::tracing::instrument(skip_all, name = "handler", fields(method = "Raiser.get500"))] async fn handle_get500<'a>( &'a self, p: &'a mut P::Deserializer, req: ::fbthrift::ProtocolDecoded

, req_ctxt: &R, reply_state: ::std::sync::Arc, _seqid: ::std::primitive::u32, ) -> ::anyhow::Result<()> { use ::const_cstr::const_cstr; use ::futures::FutureExt as _; const_cstr! { SERVICE_NAME = "Raiser"; METHOD_NAME = "get500"; SERVICE_METHOD_NAME = "Raiser.get500"; } let mut ctx_stack = req_ctxt.get_context_stack( SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), )?; ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?; let _args: self::Args_Raiser_get500 = ::fbthrift::Deserialize::read(p)?; let bytes_read = ::fbthrift::help::buf_len(&req)?; ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, ::fbthrift::SerializedMessage { protocol: P::PROTOCOL_ID, method_name: METHOD_NAME.as_cstr(), buffer: req, })?; ::fbthrift::ContextStack::post_read(&mut ctx_stack, bytes_read)?; let res = ::std::panic::AssertUnwindSafe( self.service.get500( ) ) .catch_unwind() .await; // nested results - panic catch on the outside, method on the inside let res = match res { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { ::tracing::trace!(method = "Raiser.get500", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "Raiser.get500", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("Raiser.get500", exn); ::tracing::error!(method = "Raiser.get500", panic = ?aexn); ::std::result::Result::Err(crate::services::raiser::Get500Exn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "get500", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, res, )?; reply_state.send_reply(env); Ok(()) } } #[::async_trait::async_trait] impl ::fbthrift::ServiceProcessor

for RaiserProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: Raiser, P::Frame: ::std::marker::Send + 'static, R: ::fbthrift::RequestContext + ::std::marker::Send + ::std::marker::Sync + 'static, ::ContextStack: ::fbthrift::ContextStack::Frame> + ::std::marker::Send + ::std::marker::Sync + 'static, RS: ::fbthrift::ReplyState + ::std::marker::Send + ::std::marker::Sync + 'static, ::fbthrift::ProtocolDecoded

: ::std::clone::Clone, ::fbthrift::ProtocolEncodedFinal

: ::std::clone::Clone + ::fbthrift::BufExt, { type RequestContext = R; type ReplyState = RS; #[inline] fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> { match name { b"doBland" => ::std::result::Result::Ok(0usize), b"doRaise" => ::std::result::Result::Ok(1usize), b"get200" => ::std::result::Result::Ok(2usize), b"get500" => ::std::result::Result::Ok(3usize), _ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()), } } #[allow(clippy::match_single_binding)] async fn handle_method( &self, idx: ::std::primitive::usize, _p: &mut P::Deserializer, _req: ::fbthrift::ProtocolDecoded

, _req_ctxt: &R, _reply_state: ::std::sync::Arc, _seqid: ::std::primitive::u32, ) -> ::anyhow::Result<()> { match idx { 0usize => { self.handle_doBland(_p, _req, _req_ctxt, _reply_state, _seqid).await } 1usize => { self.handle_doRaise(_p, _req, _req_ctxt, _reply_state, _seqid).await } 2usize => { self.handle_get200(_p, _req, _req_ctxt, _reply_state, _seqid).await } 3usize => { self.handle_get500(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "RaiserProcessor", bad ), } } #[allow(clippy::match_single_binding)] #[inline] fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> { match name { _ => ::anyhow::bail!("Unknown interaction"), } } #[allow(clippy::match_single_binding)] fn handle_create_interaction( &self, idx: ::std::primitive::usize, ) -> ::anyhow::Result< ::std::sync::Arc + ::std::marker::Send + 'static> > { match idx { bad => panic!( "{}: unexpected method idx {}", "RaiserProcessor", bad ), } } async fn handle_on_termination(&self) { } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for RaiserProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: Raiser, R: ::fbthrift::RequestContext + ::std::marker::Send + ::std::marker::Sync + 'static, ::ContextStack: ::fbthrift::ContextStack::Frame> + ::std::marker::Send + ::std::marker::Sync + 'static, RS: ::fbthrift::ReplyState + ::std::marker::Send + ::std::marker::Sync + 'static, ::fbthrift::ProtocolDecoded

: ::std::clone::Clone, ::fbthrift::ProtocolEncodedFinal

: ::std::clone::Clone + ::fbthrift::BufExt, { type Handler = H; type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "Raiser"))] async fn call( &self, req: ::fbthrift::ProtocolDecoded

, req_ctxt: &R, reply_state: ::std::sync::Arc, ) -> ::anyhow::Result<()> { use ::fbthrift::{ProtocolReader as _, ServiceProcessor as _}; let mut p = P::deserializer(req.clone()); let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?; if mty != ::fbthrift::MessageType::Call { return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType, format!("message type {:?} not handled", mty) ))); } let idx = match idx { ::std::result::Result::Ok(idx) => idx, ::std::result::Result::Err(_) => { return self.supa.call(req, req_ctxt, reply_state).await; } }; self.handle_method(idx, &mut p, req, req_ctxt, reply_state, seqid).await?; p.read_message_end()?; Ok(()) } fn create_interaction( &self, name: &str, ) -> ::anyhow::Result< ::std::sync::Arc + ::std::marker::Send + 'static> > { use ::fbthrift::{ServiceProcessor as _}; let idx = self.create_interaction_idx(name); let idx = match idx { ::anyhow::Result::Ok(idx) => idx, ::anyhow::Result::Err(_) => { return self.supa.create_interaction(name); } }; self.handle_create_interaction(idx) } fn get_method_names(&self) -> &'static [&'static str] { &[ // from Raiser "doBland", "doRaise", "get200", "get500", ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } /// Construct a new instance of a Raiser service. /// /// This is called when a new instance of a Thrift service Processor /// is needed for a particular Thrift protocol. #[::tracing::instrument(level="debug", skip_all, fields(proto = ?proto))] pub fn make_Raiser_server( proto: ::fbthrift::ProtocolID, handler: H, ) -> ::std::result::Result<::std::boxed::Box + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException> where F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static, H: Raiser, R: ::fbthrift::RequestContext + ::std::marker::Send + ::std::marker::Sync + 'static, ::ContextStack: ::fbthrift::ContextStack + ::std::marker::Send + ::std::marker::Sync + 'static, RS: ::fbthrift::ReplyState + ::std::marker::Send + ::std::marker::Sync + 'static, ::fbthrift::FramingDecoded: ::std::clone::Clone, ::fbthrift::FramingEncodedFinal: ::std::clone::Clone + ::fbthrift::BufExt, { match proto { ::fbthrift::ProtocolID::BinaryProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(RaiserProcessor::<::fbthrift::BinaryProtocol, H, R, RS>::new(handler))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(RaiserProcessor::<::fbthrift::CompactProtocol, H, R, RS>::new(handler))) } bad => { ::tracing::error!(method = "Raiser.", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } }