/**
 * Autogenerated by Thrift for thrift/compiler/test/fixtures/adapter/src/module.thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

#include <thrift/compiler/test/fixtures/adapter/gen-py3/module/clients_wrapper.h>

namespace facebook {
namespace thrift {
namespace test {


folly::Future<int32_t>
ServiceClientWrapper::func(
    apache::thrift::RpcOptions& rpcOptions,
    std::string arg_arg1,
    std::string arg_arg2,
    ::facebook::thrift::test::Foo arg_arg3) {
  auto* client = static_cast<::facebook::thrift::test::ServiceAsyncClient*>(async_client_.get());
  using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<int32_t>;
  folly::Promise<CallbackHelper::PromiseResult> _promise;
  auto _future = _promise.getFuture();
  auto callback = std::make_unique<::thrift::py3::FutureCallback<int32_t>>(
    std::move(_promise), rpcOptions, client->recv_wrapped_func, channel_);
  try {
    client->func(
      rpcOptions,
      std::move(callback),
      arg_arg1,
      arg_arg2,
      arg_arg3
    );
  } catch (...) {
    return folly::makeFuture<int32_t>(folly::exception_wrapper(
      std::current_exception()
    ));
  }
  return std::move(_future).thenValue(CallbackHelper::extractResult);
}

folly::Future<::facebook::thrift::test::CountingStruct>
AdapterServiceClientWrapper::count(
    apache::thrift::RpcOptions& rpcOptions) {
  auto* client = static_cast<::facebook::thrift::test::AdapterServiceAsyncClient*>(async_client_.get());
  using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<::facebook::thrift::test::CountingStruct>;
  folly::Promise<CallbackHelper::PromiseResult> _promise;
  auto _future = _promise.getFuture();
  auto callback = std::make_unique<::thrift::py3::FutureCallback<::facebook::thrift::test::CountingStruct>>(
    std::move(_promise), rpcOptions, client->recv_wrapped_count, channel_);
  try {
    client->count(
      rpcOptions,
      std::move(callback)
    );
  } catch (...) {
    return folly::makeFuture<::facebook::thrift::test::CountingStruct>(folly::exception_wrapper(
      std::current_exception()
    ));
  }
  return std::move(_future).thenValue(CallbackHelper::extractResult);
}

folly::Future<::facebook::thrift::test::HeapAllocated>
AdapterServiceClientWrapper::adaptedTypes(
    apache::thrift::RpcOptions& rpcOptions,
    ::facebook::thrift::test::HeapAllocated arg_arg) {
  auto* client = static_cast<::facebook::thrift::test::AdapterServiceAsyncClient*>(async_client_.get());
  using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<::facebook::thrift::test::HeapAllocated>;
  folly::Promise<CallbackHelper::PromiseResult> _promise;
  auto _future = _promise.getFuture();
  auto callback = std::make_unique<::thrift::py3::FutureCallback<::facebook::thrift::test::HeapAllocated>>(
    std::move(_promise), rpcOptions, client->recv_wrapped_adaptedTypes, channel_);
  try {
    client->adaptedTypes(
      rpcOptions,
      std::move(callback),
      arg_arg
    );
  } catch (...) {
    return folly::makeFuture<::facebook::thrift::test::HeapAllocated>(folly::exception_wrapper(
      std::current_exception()
    ));
  }
  return std::move(_future).thenValue(CallbackHelper::extractResult);
}

} // namespace facebook
} // namespace thrift
} // namespace test
