// @generated by Thrift for thrift/compiler/test/fixtures/doctext/src/module.thrift // This file is probably not the place you want to edit! //! Client implementation for each service in `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 ::::errors::c; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use ::::errors::c::*; } pub(crate) use crate as client; pub(crate) use ::::services; // Used by Thrift-generated code to implement service inheritance. #[doc(hidden)] #[deprecated] pub mod dependencies { } /// Client definitions for `C`. pub struct CImpl
{
transport: T,
_phantom: ::std::marker::PhantomData CImpl
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing : ::fbthrift::BufMutExt ("f", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call = transport
.call(SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call", method = "C.f"));
async move {
let reply_env = call.await?;
let de = P::deserializer(reply_env);
let res = ::fbthrift::help::async_deserialize_response_envelope:: (de).await?;
let res = match res {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(aexn) => {
::std::result::Result::Err(crate::errors::c::FError::ApplicationException(aexn))
}
};
res
}
.instrument(::tracing::info_span!("stream", method = "C.f"))
.boxed()
}
fn _numbers_impl(
&self,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::futures::stream::BoxStream<'static, ::std::result::Result ("numbers", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call_stream = transport
.call_stream(SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call_stream", method = "C.numbers"));
async move {
let (initial, stream) = call_stream.await?;
let new_stream = stream.then(|item_res| {
async move {
match item_res {
::std::result::Result::Err(err) =>
::std::result::Result::Err(crate::errors::c::NumbersStreamError::from(err)),
::std::result::Result::Ok(item_enc) => {
S::spawn(move || {
match item_enc {
::fbthrift::ClientStreamElement::Reply(payload) => {
let mut de = P::deserializer(payload);
(de)
.await??
.map(move |_| new_stream);
res
}
.instrument(::tracing::info_span!("stream", method = "C.numbers"))
.boxed()
}
fn _thing_impl(
&self,
arg_a: ::std::primitive::i32,
arg_b: &::std::primitive::str,
arg_c: &::std::collections::BTreeSet<::std::primitive::i32>,
rpc_options: T::RpcOptions,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::std::string::String, crate::errors::c::ThingError>> {
use ::const_cstr::const_cstr;
use ::tracing::Instrument as _;
use ::futures::FutureExt as _;
const_cstr! {
SERVICE_NAME = "C";
SERVICE_METHOD_NAME = "C.thing";
}
let args = self::Args_C_thing {
a: arg_a,
b: arg_b,
c: arg_c,
_phantom: ::std::marker::PhantomData,
};
let transport = self.transport();
// need to do call setup outside of async block because T: Transport isn't Send
let request_env = match ::fbthrift::help::serialize_request_envelope:: ("thing", &args) {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
};
let call = transport
.call(SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), request_env, rpc_options)
.instrument(::tracing::trace_span!("call", method = "C.thing"));
async move {
let reply_env = call.await?;
let de = P::deserializer(reply_env);
let res = ::fbthrift::help::async_deserialize_response_envelope:: (de).await?;
let res = match res {
::std::result::Result::Ok(res) => res,
::std::result::Result::Err(aexn) => {
::std::result::Result::Err(crate::errors::c::ThingError::ApplicationException(aexn))
}
};
res
}
.instrument(::tracing::info_span!("stream", method = "C.thing"))
.boxed()
}
}
#[doc = "Detailed overview of service"]
pub trait C: ::std::marker::Send {
#[doc = "Function doctext."]
fn f(
&self,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<(), crate::errors::c::FError>>;
#[doc = "Streaming function"]
fn numbers(
&self,
) -> ::futures::future::BoxFuture<'static, ::std::result::Result<::futures::stream::BoxStream<'static, ::std::result::Result for self::Args_C_f<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "C.f"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_stop();
p.write_struct_end();
}
}
struct Args_C_numbers<'a> {
_phantom: ::std::marker::PhantomData<&'a ()>,
}
impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize for self::Args_C_numbers<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "C.numbers"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_stop();
p.write_struct_end();
}
}
struct Args_C_thing<'a> {
a: ::std::primitive::i32,
b: &'a ::std::primitive::str,
c: &'a ::std::collections::BTreeSet<::std::primitive::i32>,
_phantom: ::std::marker::PhantomData<&'a ()>,
}
impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize for self::Args_C_thing<'a> {
#[inline]
#[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "C.thing"))]
fn write(&self, p: &mut P) {
p.write_struct_begin("args");
p.write_field_begin("a", ::fbthrift::TType::I32, 1i16);
::fbthrift::Serialize::write(&self.a, p);
p.write_field_end();
p.write_field_begin("b", ::fbthrift::TType::String, 2i16);
::fbthrift::Serialize::write(&self.b, p);
p.write_field_end();
p.write_field_begin("c", ::fbthrift::TType::Set, 3i16);
::fbthrift::Serialize::write(&self.c, p);
p.write_field_end();
p.write_field_stop();
p.write_struct_end();
}
}
impl C for CImpl
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing : ::fbthrift::BufMutExt CExt
where
P: ::fbthrift::Protocol,
T: ::fbthrift::Transport,
P::Frame: ::fbthrift::Framing : ::fbthrift::BufMutExt (
protocol: P,
transport: T,
) -> ::std::sync::Arc (
protocol: P,
transport: T,
spawner: S,
) -> ::std::sync::Arc ::new(transport))
}
}
impl (
protocol: P,
transport: T,
) -> ::std::sync::Arc (
protocol: P,
transport: T,
spawner: S,
) -> ::std::sync::Arc ::new(transport))
}
}
pub type CDynClient = (protocol: P, transport: T, spawner: S) -> ::std::sync::Arc CExt