// @generated by Thrift for thrift/compiler/test/fixtures/interactions/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::my_service; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_service::*; #[doc(inline)] pub use ::::services::my_interaction; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_interaction::*; #[doc(inline)] pub use ::::services::my_interaction_fast; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_interaction_fast::*; #[doc(inline)] pub use ::::services::serial_interaction; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::serial_interaction::*; } pub(crate) use crate as server; pub(crate) use ::::services; #[::async_trait::async_trait] pub trait MyInteraction: ::std::marker::Send + ::std::marker::Sync + 'static { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction::FrobnicateExn> { ::std::result::Result::Err(crate::services::my_interaction::FrobnicateExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteraction", "frobnicate", ), )) } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction::PingExn> { ::std::result::Result::Err(crate::services::my_interaction::PingExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteraction", "ping", ), )) } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction::TruthifyStreamExn>> , crate::services::my_interaction::TruthifyExn> { ::std::result::Result::Err(crate::services::my_interaction::TruthifyExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteraction", "truthify", ), )) } async fn on_termination(&self) {} } #[::async_trait::async_trait] impl MyInteraction for ::std::boxed::Box where T: MyInteraction + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction::FrobnicateExn> { (**self).frobnicate( ).await } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction::PingExn> { (**self).ping( ).await } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction::TruthifyStreamExn>> , crate::services::my_interaction::TruthifyExn> { (**self).truthify( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } #[::async_trait::async_trait] impl MyInteraction for ::std::sync::Arc where T: MyInteraction + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction::FrobnicateExn> { (**self).frobnicate( ).await } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction::PingExn> { (**self).ping( ).await } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction::TruthifyStreamExn>> , crate::services::my_interaction::TruthifyExn> { (**self).truthify( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } /// Processor for MyInteraction's methods. #[derive(Clone, Debug)] pub struct MyInteractionProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyInteraction_frobnicate { } impl ::fbthrift::Deserialize

for self::Args_MyInteraction_frobnicate { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteraction.frobnicate"))] 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_MyInteraction_ping { } impl ::fbthrift::Deserialize

for self::Args_MyInteraction_ping { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteraction.ping"))] 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_MyInteraction_truthify { } impl ::fbthrift::Deserialize

for self::Args_MyInteraction_truthify { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteraction.truthify"))] 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 MyInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyInteraction, 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 = "MyInteraction.frobnicate"))] async fn handle_frobnicate<'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 = "MyService"; METHOD_NAME = "MyInteraction.frobnicate"; SERVICE_METHOD_NAME = "MyService.MyInteraction.frobnicate"; } 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_MyInteraction_frobnicate = ::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.frobnicate( ) ) .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 = "MyInteraction.frobnicate", "success"); crate::services::my_interaction::FrobnicateExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction::FrobnicateExn::Success(_))) => { panic!( "{} attempted to return success via error", "frobnicate", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyInteraction.frobnicate", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteraction.frobnicate", exn); ::tracing::error!(method = "MyInteraction.frobnicate", panic = ?aexn); crate::services::my_interaction::FrobnicateExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "frobnicate", 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 = "MyInteraction.ping"))] async fn handle_ping<'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 = "MyService"; METHOD_NAME = "MyInteraction.ping"; SERVICE_METHOD_NAME = "MyService.MyInteraction.ping"; } 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_MyInteraction_ping = ::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.ping( ) ) .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 = "MyInteraction.ping", "success"); crate::services::my_interaction::PingExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction::PingExn::Success(_))) => { panic!( "{} attempted to return success via error", "ping", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyInteraction.ping", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteraction.ping", exn); ::tracing::error!(method = "MyInteraction.ping", panic = ?aexn); crate::services::my_interaction::PingExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "ping", 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 = "MyInteraction.truthify"))] async fn handle_truthify<'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 = "MyService"; METHOD_NAME = "MyInteraction.truthify"; SERVICE_METHOD_NAME = "MyService.MyInteraction.truthify"; } 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_MyInteraction_truthify = ::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.truthify( ) ) .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 = "MyInteraction.truthify", "success"); crate::services::my_interaction::TruthifyExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction::TruthifyExn::Success(_))) => { panic!( "{} attempted to return success via error", "truthify", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteraction.truthify", exn); ::tracing::error!(method = "MyInteraction.truthify", panic = ?aexn); crate::services::my_interaction::TruthifyExn::ApplicationException(aexn) } }; use ::futures::StreamExt as _; let (response, stream) = match res { crate::services::my_interaction::TruthifyExn::Success(res) => { let response = crate::services::my_interaction::TruthifyResponseExn::Success(()); let stream = res; let stream = ::std::panic::AssertUnwindSafe(stream) .catch_unwind() .map(|item| { match item { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { let item = crate::services::my_interaction::TruthifyStreamExn::Success(res); match ::fbthrift::help::serialize_stream_item::(item) { Ok(payload) => ::fbthrift::SerializedStreamElement::Success(payload), Err(err) => { tracing::error!(?err, method="MyInteraction.truthify", "Failed to serialize success response"); ::fbthrift::SerializedStreamElement::SerializationError(err) }, } } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction::TruthifyStreamExn::Success(_))) => { panic!("{} attempted to return success via error", "truthify"); } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction::TruthifyStreamExn::ApplicationException(aexn))) => { tracing::info!(?aexn, method="MyInteraction.truthify", "Streaming ApplicationException"); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } ::std::result::Result::Err(exn) => { tracing::error!(?exn, method="MyInteraction.truthify", "Streaming unwind"); let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteraction.truthify", exn); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } } }) .boxed(); (response, Some(stream)) }, crate::services::my_interaction::TruthifyExn::ApplicationException(aexn)=> { let response = crate::services::my_interaction::TruthifyResponseExn::ApplicationException(aexn); (response, None) }, }; let response = ::fbthrift::help::serialize_result_envelope::( "truthify", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, response )?; let _ = reply_state.send_stream_reply(response, stream, P::PROTOCOL_ID); Ok(()) } } #[::async_trait::async_trait] impl ::fbthrift::ServiceProcessor

for MyInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyInteraction, 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"MyInteraction.frobnicate" => ::std::result::Result::Ok(0usize), b"MyInteraction.ping" => ::std::result::Result::Ok(1usize), b"MyInteraction.truthify" => ::std::result::Result::Ok(2usize), _ => ::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_frobnicate(_p, _req, _req_ctxt, _reply_state, _seqid).await } 1usize => { self.handle_ping(_p, _req, _req_ctxt, _reply_state, _seqid).await } 2usize => { self.handle_truthify(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyInteractionProcessor", 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 {}", "MyInteractionProcessor", bad ), } } async fn handle_on_termination(&self) { self.service.on_termination().await } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyInteraction, 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, { // Interactions have () as their handler associated type // to make `create_interaction` have a common return type. type Handler = (); type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "MyInteraction"))] 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] { &[ // interaction's method names are never queried directly. // they are always queried from the "main" processor. ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } #[::async_trait::async_trait] pub trait MyInteractionFast: ::std::marker::Send + ::std::marker::Sync + 'static { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction_fast::FrobnicateExn> { ::std::result::Result::Err(crate::services::my_interaction_fast::FrobnicateExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteractionFast", "frobnicate", ), )) } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction_fast::PingExn> { ::std::result::Result::Err(crate::services::my_interaction_fast::PingExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteractionFast", "ping", ), )) } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction_fast::TruthifyStreamExn>> , crate::services::my_interaction_fast::TruthifyExn> { ::std::result::Result::Err(crate::services::my_interaction_fast::TruthifyExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyInteractionFast", "truthify", ), )) } async fn on_termination(&self) {} } #[::async_trait::async_trait] impl MyInteractionFast for ::std::boxed::Box where T: MyInteractionFast + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction_fast::FrobnicateExn> { (**self).frobnicate( ).await } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction_fast::PingExn> { (**self).ping( ).await } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction_fast::TruthifyStreamExn>> , crate::services::my_interaction_fast::TruthifyExn> { (**self).truthify( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } #[::async_trait::async_trait] impl MyInteractionFast for ::std::sync::Arc where T: MyInteractionFast + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<::std::primitive::i32, crate::services::my_interaction_fast::FrobnicateExn> { (**self).frobnicate( ).await } async fn ping( &self, ) -> ::std::result::Result<(), crate::services::my_interaction_fast::PingExn> { (**self).ping( ).await } async fn truthify( &self, ) -> ::std::result::Result< ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::bool, crate::services::my_interaction_fast::TruthifyStreamExn>> , crate::services::my_interaction_fast::TruthifyExn> { (**self).truthify( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } /// Processor for MyInteractionFast's methods. #[derive(Clone, Debug)] pub struct MyInteractionFastProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyInteractionFast_frobnicate { } impl ::fbthrift::Deserialize

for self::Args_MyInteractionFast_frobnicate { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteractionFast.frobnicate"))] 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_MyInteractionFast_ping { } impl ::fbthrift::Deserialize

for self::Args_MyInteractionFast_ping { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteractionFast.ping"))] 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_MyInteractionFast_truthify { } impl ::fbthrift::Deserialize

for self::Args_MyInteractionFast_truthify { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyInteractionFast.truthify"))] 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 MyInteractionFastProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyInteractionFast, 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 = "MyInteractionFast.frobnicate"))] async fn handle_frobnicate<'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 = "MyService"; METHOD_NAME = "MyInteractionFast.frobnicate"; SERVICE_METHOD_NAME = "MyService.MyInteractionFast.frobnicate"; } 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_MyInteractionFast_frobnicate = ::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.frobnicate( ) ) .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 = "MyInteractionFast.frobnicate", "success"); crate::services::my_interaction_fast::FrobnicateExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction_fast::FrobnicateExn::Success(_))) => { panic!( "{} attempted to return success via error", "frobnicate", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyInteractionFast.frobnicate", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteractionFast.frobnicate", exn); ::tracing::error!(method = "MyInteractionFast.frobnicate", panic = ?aexn); crate::services::my_interaction_fast::FrobnicateExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "frobnicate", 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 = "MyInteractionFast.ping"))] async fn handle_ping<'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 = "MyService"; METHOD_NAME = "MyInteractionFast.ping"; SERVICE_METHOD_NAME = "MyService.MyInteractionFast.ping"; } 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_MyInteractionFast_ping = ::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.ping( ) ) .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 = "MyInteractionFast.ping", "success"); crate::services::my_interaction_fast::PingExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction_fast::PingExn::Success(_))) => { panic!( "{} attempted to return success via error", "ping", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyInteractionFast.ping", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteractionFast.ping", exn); ::tracing::error!(method = "MyInteractionFast.ping", panic = ?aexn); crate::services::my_interaction_fast::PingExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "ping", 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 = "MyInteractionFast.truthify"))] async fn handle_truthify<'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 = "MyService"; METHOD_NAME = "MyInteractionFast.truthify"; SERVICE_METHOD_NAME = "MyService.MyInteractionFast.truthify"; } 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_MyInteractionFast_truthify = ::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.truthify( ) ) .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 = "MyInteractionFast.truthify", "success"); crate::services::my_interaction_fast::TruthifyExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction_fast::TruthifyExn::Success(_))) => { panic!( "{} attempted to return success via error", "truthify", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteractionFast.truthify", exn); ::tracing::error!(method = "MyInteractionFast.truthify", panic = ?aexn); crate::services::my_interaction_fast::TruthifyExn::ApplicationException(aexn) } }; use ::futures::StreamExt as _; let (response, stream) = match res { crate::services::my_interaction_fast::TruthifyExn::Success(res) => { let response = crate::services::my_interaction_fast::TruthifyResponseExn::Success(()); let stream = res; let stream = ::std::panic::AssertUnwindSafe(stream) .catch_unwind() .map(|item| { match item { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { let item = crate::services::my_interaction_fast::TruthifyStreamExn::Success(res); match ::fbthrift::help::serialize_stream_item::(item) { Ok(payload) => ::fbthrift::SerializedStreamElement::Success(payload), Err(err) => { tracing::error!(?err, method="MyInteractionFast.truthify", "Failed to serialize success response"); ::fbthrift::SerializedStreamElement::SerializationError(err) }, } } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction_fast::TruthifyStreamExn::Success(_))) => { panic!("{} attempted to return success via error", "truthify"); } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_interaction_fast::TruthifyStreamExn::ApplicationException(aexn))) => { tracing::info!(?aexn, method="MyInteractionFast.truthify", "Streaming ApplicationException"); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } ::std::result::Result::Err(exn) => { tracing::error!(?exn, method="MyInteractionFast.truthify", "Streaming unwind"); let aexn = ::fbthrift::ApplicationException::handler_panic("MyInteractionFast.truthify", exn); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } } }) .boxed(); (response, Some(stream)) }, crate::services::my_interaction_fast::TruthifyExn::ApplicationException(aexn)=> { let response = crate::services::my_interaction_fast::TruthifyResponseExn::ApplicationException(aexn); (response, None) }, }; let response = ::fbthrift::help::serialize_result_envelope::( "truthify", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, response )?; let _ = reply_state.send_stream_reply(response, stream, P::PROTOCOL_ID); Ok(()) } } #[::async_trait::async_trait] impl ::fbthrift::ServiceProcessor

for MyInteractionFastProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyInteractionFast, 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"MyInteractionFast.frobnicate" => ::std::result::Result::Ok(0usize), b"MyInteractionFast.ping" => ::std::result::Result::Ok(1usize), b"MyInteractionFast.truthify" => ::std::result::Result::Ok(2usize), _ => ::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_frobnicate(_p, _req, _req_ctxt, _reply_state, _seqid).await } 1usize => { self.handle_ping(_p, _req, _req_ctxt, _reply_state, _seqid).await } 2usize => { self.handle_truthify(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyInteractionFastProcessor", 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 {}", "MyInteractionFastProcessor", bad ), } } async fn handle_on_termination(&self) { self.service.on_termination().await } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyInteractionFastProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyInteractionFast, 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, { // Interactions have () as their handler associated type // to make `create_interaction` have a common return type. type Handler = (); type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "MyInteractionFast"))] 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] { &[ // interaction's method names are never queried directly. // they are always queried from the "main" processor. ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } #[::async_trait::async_trait] pub trait SerialInteraction: ::std::marker::Send + ::std::marker::Sync + 'static { async fn frobnicate( &self, ) -> ::std::result::Result<(), crate::services::serial_interaction::FrobnicateExn> { ::std::result::Result::Err(crate::services::serial_interaction::FrobnicateExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "SerialInteraction", "frobnicate", ), )) } async fn on_termination(&self) {} } #[::async_trait::async_trait] impl SerialInteraction for ::std::boxed::Box where T: SerialInteraction + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<(), crate::services::serial_interaction::FrobnicateExn> { (**self).frobnicate( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } #[::async_trait::async_trait] impl SerialInteraction for ::std::sync::Arc where T: SerialInteraction + Send + Sync + ?Sized, { async fn frobnicate( &self, ) -> ::std::result::Result<(), crate::services::serial_interaction::FrobnicateExn> { (**self).frobnicate( ).await } async fn on_termination(&self) { (**self).on_termination().await; } } /// Processor for SerialInteraction's methods. #[derive(Clone, Debug)] pub struct SerialInteractionProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_SerialInteraction_frobnicate { } impl ::fbthrift::Deserialize

for self::Args_SerialInteraction_frobnicate { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "SerialInteraction.frobnicate"))] 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 SerialInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: SerialInteraction, 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 = "SerialInteraction.frobnicate"))] async fn handle_frobnicate<'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 = "MyService"; METHOD_NAME = "SerialInteraction.frobnicate"; SERVICE_METHOD_NAME = "MyService.SerialInteraction.frobnicate"; } 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_SerialInteraction_frobnicate = ::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.frobnicate( ) ) .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 = "SerialInteraction.frobnicate", "success"); crate::services::serial_interaction::FrobnicateExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::serial_interaction::FrobnicateExn::Success(_))) => { panic!( "{} attempted to return success via error", "frobnicate", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "SerialInteraction.frobnicate", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("SerialInteraction.frobnicate", exn); ::tracing::error!(method = "SerialInteraction.frobnicate", panic = ?aexn); crate::services::serial_interaction::FrobnicateExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "frobnicate", 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 SerialInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: SerialInteraction, 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"SerialInteraction.frobnicate" => ::std::result::Result::Ok(0usize), _ => ::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_frobnicate(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "SerialInteractionProcessor", 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 {}", "SerialInteractionProcessor", bad ), } } async fn handle_on_termination(&self) { self.service.on_termination().await } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for SerialInteractionProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: SerialInteraction, 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, { // Interactions have () as their handler associated type // to make `create_interaction` have a common return type. type Handler = (); type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "SerialInteraction"))] 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] { &[ // interaction's method names are never queried directly. // they are always queried from the "main" processor. ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } #[::async_trait::async_trait] pub trait MyService: ::std::marker::Send + ::std::marker::Sync + 'static { fn createMyInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { ::anyhow::bail!("MyService.createMyInteraction not implemented"); } fn createMyInteractionFast( &self, ) -> ::anyhow::Result<::std::boxed::Box> { ::anyhow::bail!("MyService.createMyInteractionFast not implemented"); } fn createSerialInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { ::anyhow::bail!("MyService.createSerialInteraction not implemented"); } async fn foo( &self, ) -> ::std::result::Result<(), crate::services::my_service::FooExn> { ::std::result::Result::Err(crate::services::my_service::FooExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyService", "foo", ), )) } async fn interact( &self, _arg: ::std::primitive::i32, ) -> ::std::result::Result<::std::boxed::Box, crate::services::my_service::InteractExn> { ::std::result::Result::Err(crate::services::my_service::InteractExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyService", "interact", ), )) } async fn interactFast( &self, ) -> ::std::result::Result<(::std::boxed::Box, ::std::primitive::i32), crate::services::my_service::InteractFastExn> { ::std::result::Result::Err(crate::services::my_service::InteractFastExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyService", "interactFast", ), )) } async fn serialize( &self, ) -> ::std::result::Result<(::std::boxed::Box, ( ::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::services::my_service::SerializeStreamExn>> ) ), crate::services::my_service::SerializeExn> { ::std::result::Result::Err(crate::services::my_service::SerializeExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyService", "serialize", ), )) } } #[::async_trait::async_trait] impl MyService for ::std::boxed::Box where T: MyService + Send + Sync + ?Sized, { fn createMyInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createMyInteraction() } fn createMyInteractionFast( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createMyInteractionFast() } fn createSerialInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createSerialInteraction() } async fn foo( &self, ) -> ::std::result::Result<(), crate::services::my_service::FooExn> { (**self).foo( ).await } async fn interact( &self, arg: ::std::primitive::i32, ) -> ::std::result::Result<::std::boxed::Box, crate::services::my_service::InteractExn> { (**self).interact( arg, ).await } async fn interactFast( &self, ) -> ::std::result::Result<(::std::boxed::Box, ::std::primitive::i32), crate::services::my_service::InteractFastExn> { (**self).interactFast( ).await } async fn serialize( &self, ) -> ::std::result::Result<(::std::boxed::Box, ( ::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::services::my_service::SerializeStreamExn>> ) ), crate::services::my_service::SerializeExn> { (**self).serialize( ).await } } #[::async_trait::async_trait] impl MyService for ::std::sync::Arc where T: MyService + Send + Sync + ?Sized, { fn createMyInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createMyInteraction() } fn createMyInteractionFast( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createMyInteractionFast() } fn createSerialInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).createSerialInteraction() } async fn foo( &self, ) -> ::std::result::Result<(), crate::services::my_service::FooExn> { (**self).foo( ).await } async fn interact( &self, arg: ::std::primitive::i32, ) -> ::std::result::Result<::std::boxed::Box, crate::services::my_service::InteractExn> { (**self).interact( arg, ).await } async fn interactFast( &self, ) -> ::std::result::Result<(::std::boxed::Box, ::std::primitive::i32), crate::services::my_service::InteractFastExn> { (**self).interactFast( ).await } async fn serialize( &self, ) -> ::std::result::Result<(::std::boxed::Box, ( ::std::primitive::i32, ::futures::stream::BoxStream<'static, ::std::result::Result<::std::primitive::i32, crate::services::my_service::SerializeStreamExn>> ) ), crate::services::my_service::SerializeExn> { (**self).serialize( ).await } } /// Processor for MyService's methods. #[derive(Clone, Debug)] pub struct MyServiceProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyService_foo { } impl ::fbthrift::Deserialize

for self::Args_MyService_foo { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyService.foo"))] 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_MyService_interact { arg: ::std::primitive::i32, } impl ::fbthrift::Deserialize

for self::Args_MyService_interact { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyService.interact"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ ::fbthrift::Field::new("arg", ::fbthrift::TType::I32, 1), ]; let mut field_arg = ::std::option::Option::None; 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, (::fbthrift::TType::I32, 1) => field_arg = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?), (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self { arg: field_arg.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "MyService.interact", "arg"))?, }) } } struct Args_MyService_interactFast { } impl ::fbthrift::Deserialize

for self::Args_MyService_interactFast { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyService.interactFast"))] 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_MyService_serialize { } impl ::fbthrift::Deserialize

for self::Args_MyService_serialize { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyService.serialize"))] 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 MyServiceProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyService, 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 } fn handle_createMyInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { self.service.createMyInteraction() } fn handle_createMyInteractionFast( &self, ) -> ::anyhow::Result<::std::boxed::Box> { self.service.createMyInteractionFast() } fn handle_createSerialInteraction( &self, ) -> ::anyhow::Result<::std::boxed::Box> { self.service.createSerialInteraction() } #[::tracing::instrument(skip_all, name = "handler", fields(method = "MyService.foo"))] async fn handle_foo<'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 = "MyService"; METHOD_NAME = "foo"; SERVICE_METHOD_NAME = "MyService.foo"; } 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_MyService_foo = ::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.foo( ) ) .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 = "MyService.foo", "success"); crate::services::my_service::FooExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::FooExn::Success(_))) => { panic!( "{} attempted to return success via error", "foo", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyService.foo", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyService.foo", exn); ::tracing::error!(method = "MyService.foo", panic = ?aexn); crate::services::my_service::FooExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "foo", 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 = "MyService.interact"))] async fn handle_interact<'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 = "MyService"; METHOD_NAME = "interact"; SERVICE_METHOD_NAME = "MyService.interact"; } 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_MyService_interact = ::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.interact( _args.arg, ) ) .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 = "MyService.interact", "success"); let (interaction_handler, res) = (res, ()); let interaction_processor = ::std::sync::Arc::new(MyInteractionProcessor::, R, RS>::new(interaction_handler)); reply_state.set_interaction_processor(interaction_processor)?; crate::services::my_service::InteractExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::InteractExn::Success(_))) => { panic!( "{} attempted to return success via error", "interact", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyService.interact", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyService.interact", exn); ::tracing::error!(method = "MyService.interact", panic = ?aexn); crate::services::my_service::InteractExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "interact", 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 = "MyService.interactFast"))] async fn handle_interactFast<'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 = "MyService"; METHOD_NAME = "interactFast"; SERVICE_METHOD_NAME = "MyService.interactFast"; } 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_MyService_interactFast = ::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.interactFast( ) ) .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 = "MyService.interactFast", "success"); let (interaction_handler, res) = res; let interaction_processor = ::std::sync::Arc::new(MyInteractionFastProcessor::, R, RS>::new(interaction_handler)); reply_state.set_interaction_processor(interaction_processor)?; crate::services::my_service::InteractFastExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::InteractFastExn::Success(_))) => { panic!( "{} attempted to return success via error", "interactFast", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyService.interactFast", exception = ?exn); exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyService.interactFast", exn); ::tracing::error!(method = "MyService.interactFast", panic = ?aexn); crate::services::my_service::InteractFastExn::ApplicationException(aexn) } }; let env = ::fbthrift::help::serialize_result_envelope::( "interactFast", 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 = "MyService.serialize"))] async fn handle_serialize<'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 = "MyService"; METHOD_NAME = "serialize"; SERVICE_METHOD_NAME = "MyService.serialize"; } 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_MyService_serialize = ::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.serialize( ) ) .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 = "MyService.serialize", "success"); let (interaction_handler, res) = res; let interaction_processor = ::std::sync::Arc::new(SerialInteractionProcessor::, R, RS>::new(interaction_handler)); reply_state.set_interaction_processor(interaction_processor)?; crate::services::my_service::SerializeExn::Success(res) } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::SerializeExn::Success(_))) => { panic!( "{} attempted to return success via error", "serialize", ) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { exn } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyService.serialize", exn); ::tracing::error!(method = "MyService.serialize", panic = ?aexn); crate::services::my_service::SerializeExn::ApplicationException(aexn) } }; use ::futures::StreamExt as _; let (response, stream) = match res { crate::services::my_service::SerializeExn::Success(res) => { let (response, stream) = res; let response = crate::services::my_service::SerializeResponseExn::Success(response); let stream = ::std::panic::AssertUnwindSafe(stream) .catch_unwind() .map(|item| { match item { ::std::result::Result::Ok(::std::result::Result::Ok(res)) => { let item = crate::services::my_service::SerializeStreamExn::Success(res); match ::fbthrift::help::serialize_stream_item::(item) { Ok(payload) => ::fbthrift::SerializedStreamElement::Success(payload), Err(err) => { tracing::error!(?err, method="MyService.serialize", "Failed to serialize success response"); ::fbthrift::SerializedStreamElement::SerializationError(err) }, } } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::SerializeStreamExn::Success(_))) => { panic!("{} attempted to return success via error", "serialize"); } ::std::result::Result::Ok(::std::result::Result::Err(crate::services::my_service::SerializeStreamExn::ApplicationException(aexn))) => { tracing::info!(?aexn, method="MyService.serialize", "Streaming ApplicationException"); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } ::std::result::Result::Err(exn) => { tracing::error!(?exn, method="MyService.serialize", "Streaming unwind"); let aexn = ::fbthrift::ApplicationException::handler_panic("MyService.serialize", exn); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } } }) .boxed(); (response, Some(stream)) }, crate::services::my_service::SerializeExn::ApplicationException(aexn)=> { let response = crate::services::my_service::SerializeResponseExn::ApplicationException(aexn); (response, None) }, }; let response = ::fbthrift::help::serialize_result_envelope::( "serialize", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, response )?; let _ = reply_state.send_stream_reply(response, stream, P::PROTOCOL_ID); Ok(()) } } #[::async_trait::async_trait] impl ::fbthrift::ServiceProcessor

for MyServiceProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyService, 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"foo" => ::std::result::Result::Ok(3usize), b"interact" => ::std::result::Result::Ok(4usize), b"interactFast" => ::std::result::Result::Ok(5usize), b"serialize" => ::std::result::Result::Ok(6usize), _ => ::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 { 3usize => { self.handle_foo(_p, _req, _req_ctxt, _reply_state, _seqid).await } 4usize => { self.handle_interact(_p, _req, _req_ctxt, _reply_state, _seqid).await } 5usize => { self.handle_interactFast(_p, _req, _req_ctxt, _reply_state, _seqid).await } 6usize => { self.handle_serialize(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyServiceProcessor", bad ), } } #[allow(clippy::match_single_binding)] #[inline] fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> { match name { "MyInteraction" => ::std::result::Result::Ok(0usize), "MyInteractionFast" => ::std::result::Result::Ok(1usize), "SerialInteraction" => ::std::result::Result::Ok(2usize), _ => ::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 { 0usize => { let handler = self.handle_createMyInteraction()?; let server = ::std::sync::Arc::new(MyInteractionProcessor::, R, RS>::new(handler)); Ok(server) } 1usize => { let handler = self.handle_createMyInteractionFast()?; let server = ::std::sync::Arc::new(MyInteractionFastProcessor::, R, RS>::new(handler)); Ok(server) } 2usize => { let handler = self.handle_createSerialInteraction()?; let server = ::std::sync::Arc::new(SerialInteractionProcessor::, R, RS>::new(handler)); Ok(server) } bad => panic!( "{}: unexpected method idx {}", "MyServiceProcessor", bad ), } } async fn handle_on_termination(&self) { } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyServiceProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyService, 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 = "MyService"))] 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 MyService "foo", "interact", "interactFast", "serialize", "MyInteraction.frobnicate", "MyInteraction.ping", "MyInteraction.truthify", "MyInteraction.encode", "MyInteractionFast.frobnicate", "MyInteractionFast.ping", "MyInteractionFast.truthify", "MyInteractionFast.encode", "SerialInteraction.frobnicate", ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } /// Construct a new instance of a MyService 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_MyService_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: MyService, 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(MyServiceProcessor::<::fbthrift::BinaryProtocol, H, R, RS>::new(handler))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(MyServiceProcessor::<::fbthrift::CompactProtocol, H, R, RS>::new(handler))) } bad => { ::tracing::error!(method = "MyService.", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } }