// @generated by Thrift for thrift/compiler/test/fixtures/inheritance/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_root; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_root::*; #[doc(inline)] pub use ::::services::my_node; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_node::*; #[doc(inline)] pub use ::::services::my_leaf; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::services::my_leaf::*; } pub(crate) use crate as server; pub(crate) use ::::services; #[::async_trait::async_trait] pub trait MyRoot: ::std::marker::Send + ::std::marker::Sync + 'static { async fn do_root( &self, ) -> ::std::result::Result<(), crate::services::my_root::DoRootExn> { ::std::result::Result::Err(crate::services::my_root::DoRootExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyRoot", "do_root", ), )) } } #[::async_trait::async_trait] impl MyRoot for ::std::boxed::Box where T: MyRoot + Send + Sync + ?Sized, { async fn do_root( &self, ) -> ::std::result::Result<(), crate::services::my_root::DoRootExn> { (**self).do_root( ).await } } #[::async_trait::async_trait] impl MyRoot for ::std::sync::Arc where T: MyRoot + Send + Sync + ?Sized, { async fn do_root( &self, ) -> ::std::result::Result<(), crate::services::my_root::DoRootExn> { (**self).do_root( ).await } } /// Processor for MyRoot's methods. #[derive(Clone, Debug)] pub struct MyRootProcessor { service: H, supa: ::fbthrift::NullServiceProcessor, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyRoot_do_root { } impl ::fbthrift::Deserialize

for self::Args_MyRoot_do_root { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyRoot.do_root"))] 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 MyRootProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyRoot, 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 = "MyRoot.do_root"))] async fn handle_do_root<'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 = "MyRoot"; METHOD_NAME = "do_root"; SERVICE_METHOD_NAME = "MyRoot.do_root"; } 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_MyRoot_do_root = ::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.do_root( ) ) .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 = "MyRoot.do_root", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyRoot.do_root", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyRoot.do_root", exn); ::tracing::error!(method = "MyRoot.do_root", panic = ?aexn); ::std::result::Result::Err(crate::services::my_root::DoRootExn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "do_root", 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 MyRootProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyRoot, 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"do_root" => ::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_do_root(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyRootProcessor", 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 {}", "MyRootProcessor", bad ), } } async fn handle_on_termination(&self) { } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyRootProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyRoot, 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 = "MyRoot"))] 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 MyRoot "do_root", ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } /// Construct a new instance of a MyRoot 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_MyRoot_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: MyRoot, 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(MyRootProcessor::<::fbthrift::BinaryProtocol, H, R, RS>::new(handler))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(MyRootProcessor::<::fbthrift::CompactProtocol, H, R, RS>::new(handler))) } bad => { ::tracing::error!(method = "MyRoot.", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } } #[::async_trait::async_trait] pub trait MyNode: ::std::marker::Send + ::std::marker::Sync + 'static { async fn do_mid( &self, ) -> ::std::result::Result<(), crate::services::my_node::DoMidExn> { ::std::result::Result::Err(crate::services::my_node::DoMidExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyNode", "do_mid", ), )) } } #[::async_trait::async_trait] impl MyNode for ::std::boxed::Box where T: MyNode + Send + Sync + ?Sized, { async fn do_mid( &self, ) -> ::std::result::Result<(), crate::services::my_node::DoMidExn> { (**self).do_mid( ).await } } #[::async_trait::async_trait] impl MyNode for ::std::sync::Arc where T: MyNode + Send + Sync + ?Sized, { async fn do_mid( &self, ) -> ::std::result::Result<(), crate::services::my_node::DoMidExn> { (**self).do_mid( ).await } } /// Processor for MyNode's methods. #[derive(Clone, Debug)] pub struct MyNodeProcessor { service: H, supa: SS, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyNode_do_mid { } impl ::fbthrift::Deserialize

for self::Args_MyNode_do_mid { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyNode.do_mid"))] 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 MyNodeProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyNode, 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, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyRoot { pub fn new(service: H, supa: SS) -> Self { Self { service, supa, _phantom: ::std::marker::PhantomData, } } pub fn into_inner(self) -> H { self.service } #[::tracing::instrument(skip_all, name = "handler", fields(method = "MyNode.do_mid"))] async fn handle_do_mid<'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 = "MyNode"; METHOD_NAME = "do_mid"; SERVICE_METHOD_NAME = "MyNode.do_mid"; } 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_MyNode_do_mid = ::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.do_mid( ) ) .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 = "MyNode.do_mid", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyNode.do_mid", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyNode.do_mid", exn); ::tracing::error!(method = "MyNode.do_mid", panic = ?aexn); ::std::result::Result::Err(crate::services::my_node::DoMidExn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "do_mid", 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 MyNodeProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyNode, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyRoot, 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"do_mid" => ::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_do_mid(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyNodeProcessor", 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 {}", "MyNodeProcessor", bad ), } } async fn handle_on_termination(&self) { } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyNodeProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyNode, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyRoot, 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 Handler = H; type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "MyNode"))] 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 MyRoot "do_root", // from MyNode "do_mid", ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } /// Construct a new instance of a MyNode 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_MyNode_server( proto: ::fbthrift::ProtocolID, handler: H, supa: SMAKE, ) -> ::std::result::Result<::std::boxed::Box + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException> where F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static, H: MyNode, SMAKE: ::std::ops::FnOnce(::fbthrift::ProtocolID) -> ::std::result::Result, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyRoot, 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(MyNodeProcessor::<::fbthrift::BinaryProtocol, H, R, RS, SS>::new(handler, supa(proto)?))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(MyNodeProcessor::<::fbthrift::CompactProtocol, H, R, RS, SS>::new(handler, supa(proto)?))) } bad => { ::tracing::error!(method = "MyNode.", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } } #[::async_trait::async_trait] pub trait MyLeaf: ::std::marker::Send + ::std::marker::Sync + 'static { async fn do_leaf( &self, ) -> ::std::result::Result<(), crate::services::my_leaf::DoLeafExn> { ::std::result::Result::Err(crate::services::my_leaf::DoLeafExn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "MyLeaf", "do_leaf", ), )) } } #[::async_trait::async_trait] impl MyLeaf for ::std::boxed::Box where T: MyLeaf + Send + Sync + ?Sized, { async fn do_leaf( &self, ) -> ::std::result::Result<(), crate::services::my_leaf::DoLeafExn> { (**self).do_leaf( ).await } } #[::async_trait::async_trait] impl MyLeaf for ::std::sync::Arc where T: MyLeaf + Send + Sync + ?Sized, { async fn do_leaf( &self, ) -> ::std::result::Result<(), crate::services::my_leaf::DoLeafExn> { (**self).do_leaf( ).await } } /// Processor for MyLeaf's methods. #[derive(Clone, Debug)] pub struct MyLeafProcessor { service: H, supa: SS, _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } struct Args_MyLeaf_do_leaf { } impl ::fbthrift::Deserialize

for self::Args_MyLeaf_do_leaf { #[inline] #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "MyLeaf.do_leaf"))] 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 MyLeafProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: MyLeaf, 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, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyNode { pub fn new(service: H, supa: SS) -> Self { Self { service, supa, _phantom: ::std::marker::PhantomData, } } pub fn into_inner(self) -> H { self.service } #[::tracing::instrument(skip_all, name = "handler", fields(method = "MyLeaf.do_leaf"))] async fn handle_do_leaf<'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 = "MyLeaf"; METHOD_NAME = "do_leaf"; SERVICE_METHOD_NAME = "MyLeaf.do_leaf"; } 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_MyLeaf_do_leaf = ::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.do_leaf( ) ) .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 = "MyLeaf.do_leaf", "success"); ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { ::tracing::info!(method = "MyLeaf.do_leaf", exception = ?exn); ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("MyLeaf.do_leaf", exn); ::tracing::error!(method = "MyLeaf.do_leaf", panic = ?aexn); ::std::result::Result::Err(crate::services::my_leaf::DoLeafExn::ApplicationException(aexn)) } }; let env = ::fbthrift::help::serialize_result_envelope::( "do_leaf", 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 MyLeafProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: MyLeaf, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyNode, 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"do_leaf" => ::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_do_leaf(_p, _req, _req_ctxt, _reply_state, _seqid).await } bad => panic!( "{}: unexpected method idx {}", "MyLeafProcessor", 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 {}", "MyLeafProcessor", bad ), } } async fn handle_on_termination(&self) { } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for MyLeafProcessor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: MyLeaf, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyNode, 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 Handler = H; type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "MyLeaf"))] 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 MyRoot "do_root", // from MyNode "do_mid", // from MyRoot "do_root", // from MyLeaf "do_leaf", ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } /// Construct a new instance of a MyLeaf 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_MyLeaf_server( proto: ::fbthrift::ProtocolID, handler: H, supa: SMAKE, ) -> ::std::result::Result<::std::boxed::Box + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException> where F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static, H: MyLeaf, SMAKE: ::std::ops::FnOnce(::fbthrift::ProtocolID) -> ::std::result::Result, SS: ::fbthrift::ThriftService, SS::Handler: crate::MyNode, 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(MyLeafProcessor::<::fbthrift::BinaryProtocol, H, R, RS, SS>::new(handler, supa(proto)?))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new(MyLeafProcessor::<::fbthrift::CompactProtocol, H, R, RS, SS>::new(handler, supa(proto)?))) } bad => { ::tracing::error!(method = "MyLeaf.", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } }