// @generated #include namespace apache { namespace thrift { namespace compiler { std::size_t const templates_size = 612; std::size_t const templates_name_sizes[] = { // cpp2/Autogen.mustache 21, // cpp2/ServiceAsyncClient.cpp.mustache 36, // cpp2/ServiceAsyncClient.h.mustache 34, // cpp2/common/colon_newline.mustache 34, // cpp2/common/comma_newline.mustache 34, // cpp2/common/const_type_recursive.mustache 41, // cpp2/common/const_value.mustache 32, // cpp2/common/field_suffix.mustache 33, // cpp2/common/field_value.mustache 32, // cpp2/common/frozen2_union_field_suffix.mustache 47, // cpp2/common/fun_docblock.mustache 33, // cpp2/common/function_name.mustache 34, // cpp2/common/iterate_const_values.mustache 41, // cpp2/common/iterate_const_values_adapted.mustache 49, // cpp2/common/iterate_const_values_non_referenceable.mustache 59, // cpp2/common/namespace_cpp2.mustache 35, // cpp2/common/namespace_cpp2_begin.mustache 41, // cpp2/common/namespace_cpp2_end.mustache 39, // cpp2/common/service_namespace_cpp2.mustache 43, // cpp2/common/service_namespace_cpp2_begin.mustache 49, // cpp2/common/service_namespace_cpp2_end.mustache 47, // cpp2/common/type_namespace_cpp2.mustache 40, // cpp2/fatal/fatal_using_string_declaration.mustache 50, // cpp2/field/default.mustache 27, // cpp2/field/intrinsic_default.mustache 37, // cpp2/field/member.mustache 26, // cpp2/field/tag.mustache 23, // cpp2/metadata/const_struct.mustache 35, // cpp2/metadata/const_value.mustache 34, // cpp2/metadata/field_gen.mustache 32, // cpp2/metadata/func_field_gen.mustache 37, // cpp2/metadata/func_field_name.mustache 38, // cpp2/metadata/return_type_gen.mustache 38, // cpp2/metadata/type_gen.mustache 31, // cpp2/metadata/unstructured_field_gen.mustache 45, // cpp2/module_clients.cpp.mustache 32, // cpp2/module_clients.h.mustache 30, // cpp2/module_clients_out_of_line.h.mustache 42, // cpp2/module_constants.cpp.mustache 34, // cpp2/module_constants.h.mustache 32, // cpp2/module_data.cpp.mustache 29, // cpp2/module_data.h.mustache 27, // cpp2/module_fatal.h.mustache 28, // cpp2/module_fatal_all.h.mustache 32, // cpp2/module_fatal_constant.h.mustache 37, // cpp2/module_fatal_enum.h.mustache 33, // cpp2/module_fatal_service.h.mustache 36, // cpp2/module_fatal_struct.h.mustache 35, // cpp2/module_fatal_types.h.mustache 34, // cpp2/module_fatal_union.h.mustache 34, // cpp2/module_for_each_field.h.mustache 37, // cpp2/module_handlers-inl.h.mustache 35, // cpp2/module_handlers.cpp.mustache 33, // cpp2/module_handlers.h.mustache 31, // cpp2/module_handlers_out_of_line.h.mustache 43, // cpp2/module_layouts.cpp.mustache 32, // cpp2/module_layouts.h.mustache 30, // cpp2/module_layouts_cpp/frozen_freeze_union.mustache 52, // cpp2/module_layouts_cpp/frozen_layout_union.mustache 52, // cpp2/module_layouts_cpp/frozen_thaw_union.mustache 50, // cpp2/module_layouts_h/frozen_view_union.mustache 48, // cpp2/module_metadata.cpp.mustache 33, // cpp2/module_metadata.h.mustache 31, // cpp2/module_sinit.cpp.mustache 30, // cpp2/module_types.cpp.mustache 30, // cpp2/module_types.h.mustache 28, // cpp2/module_types.tcc.mustache 30, // cpp2/module_types_cpp/assign_overload.mustache 46, // cpp2/module_types_cpp/clear_fields.mustache 43, // cpp2/module_types_cpp/clear_terse_fields.mustache 49, // cpp2/module_types_cpp/copy_ctor.mustache 40, // cpp2/module_types_cpp/declare_enums.mustache 44, // cpp2/module_types_cpp/declare_members.mustache 46, // cpp2/module_types_cpp/declare_union_types.mustache 50, // cpp2/module_types_cpp/eq_overload.mustache 42, // cpp2/module_types_cpp/field_value_ref.mustache 46, // cpp2/module_types_cpp/fragile_ctor.mustache 43, // cpp2/module_types_cpp/frozen.mustache 37, // cpp2/module_types_cpp/getters_setters.mustache 46, // cpp2/module_types_cpp/lazy_deserialization.mustache 51, // cpp2/module_types_cpp/move_ctor.mustache 40, // cpp2/module_types_cpp/struct_operator_less.mustache 51, // cpp2/module_types_cpp/swap.mustache 35, // cpp2/module_types_cpp/tcc_struct_traits.mustache 48, // cpp2/module_types_cpp/union_copy_ctor.mustache 46, // cpp2/module_types_cpp/union_declare_members.mustache 52, // cpp2/module_types_cpp/union_eq_overload.mustache 48, // cpp2/module_types_cpp/union_operator_less.mustache 50, // cpp2/module_types_cpp/union_setters.mustache 44, // cpp2/module_types_cpp/union_swap.mustache 41, // cpp2/module_types_custom_protocol.h.mustache 44, // cpp2/module_types_fwd.h.mustache 32, // cpp2/module_types_h/alloc_extended_ctors.mustache 49, // cpp2/module_types_h/base_ctor.mustache 38, // cpp2/module_types_h/base_ctor_no_alloc_init_list.mustache 57, // cpp2/module_types_h/base_ctor_with_alloc_init_list.mustache 59, // cpp2/module_types_h/declare_enums.mustache 42, // cpp2/module_types_h/declare_members.mustache 44, // cpp2/module_types_h/declare_union_types.mustache 48, // cpp2/module_types_h/enum_bitwise_ops.mustache 45, // cpp2/module_types_h/field_interceptor.mustache 46, // cpp2/module_types_h/field_ref.mustache 38, // cpp2/module_types_h/field_ref_args.mustache 43, // cpp2/module_types_h/forward_declare.mustache 44, // cpp2/module_types_h/fragile_ctor_param_list.mustache 52, // cpp2/module_types_h/frozen.mustache 35, // cpp2/module_types_h/getters_setters.mustache 44, // cpp2/module_types_h/hash_and_equal_to.mustache 46, // cpp2/module_types_h/lazy_deserialization.mustache 49, // cpp2/module_types_h/reflection.mustache 39, // cpp2/module_types_h/smart_ptr_constructor.mustache 50, // cpp2/module_types_h/union_assign_overload.mustache 50, // cpp2/module_types_h/union_copy_ctor.mustache 44, // cpp2/module_types_h/union_enum.mustache 39, // cpp2/module_types_h/union_field_ref.mustache 44, // cpp2/module_types_h/union_getters.mustache 42, // cpp2/module_types_h/union_moves.mustache 40, // cpp2/module_types_h/union_mutables.mustache 43, // cpp2/module_types_h/union_setters.mustache 42, // cpp2/module_types_h/union_storage.mustache 42, // cpp2/module_types_tcc/container_struct_type.mustache 52, // cpp2/module_types_tcc/deprecated_terse_has_value.mustache 57, // cpp2/module_types_tcc/deserialize_field.mustache 48, // cpp2/module_types_tcc/deserialize_struct.mustache 49, // cpp2/module_types_tcc/deserialize_union.mustache 48, // cpp2/module_types_tcc/field_ref.mustache 40, // cpp2/module_types_tcc/if_should_write.mustache 46, // cpp2/module_types_tcc/if_should_write_end.mustache 50, // cpp2/module_types_tcc/member_or_ptr.mustache 44, // cpp2/module_types_tcc/optional_has_value.mustache 49, // cpp2/module_types_tcc/pm.mustache 33, // cpp2/module_types_tcc/pm_value.mustache 39, // cpp2/module_types_tcc/serialize_field.mustache 46, // cpp2/module_types_tcc/serialize_field_size.mustache 51, // cpp2/module_types_tcc/serialize_field_size_zc.mustache 54, // cpp2/module_types_tcc/serialize_struct.mustache 47, // cpp2/module_types_tcc/serialize_union.mustache 46, // cpp2/module_types_tcc/struct_field_type.mustache 48, // cpp2/module_types_tcc/struct_type.mustache 42, // cpp2/module_types_tcc/tcc_struct_traits.mustache 48, // cpp2/module_types_tcc/terse_has_no_value.mustache 49, // cpp2/module_types_tcc/terse_has_value.mustache 46, // cpp2/module_types_tcc/union_setters.mustache 44, // cpp2/module_types_tcc/variable_name.mustache 44, // cpp2/module_visit_by_thrift_field_metadata.h.mustache 53, // cpp2/module_visit_union.h.mustache 34, // cpp2/module_visitation.h.mustache 33, // cpp2/service.cpp.mustache 25, // cpp2/service.h.mustache 23, // cpp2/service.tcc.mustache 25, // cpp2/service_async_client_cpp/coroutine_functions.mustache 58, // cpp2/service_async_client_cpp/function_implementation.mustache 62, // cpp2/service_async_client_cpp/future_functions.mustache 55, // cpp2/service_async_client_cpp/received.mustache 47, // cpp2/service_async_client_cpp/received_instance.mustache 56, // cpp2/service_async_client_cpp/received_wrapped.mustache 55, // cpp2/service_async_client_cpp/sync_functions.mustache 53, // cpp2/service_async_client_cpp/templated_received.mustache 57, // cpp2/service_common/client_class_name.mustache 46, // cpp2/service_common/function_param_list_client.mustache 55, // cpp2/service_common/function_param_list_interceptor.mustache 60, // cpp2/service_common/function_param_list_server.mustache 55, // cpp2/service_common/function_param_list_server_commented_out.mustache 69, // cpp2/service_common/param_list.mustache 39, // cpp2/service_common/param_list_move.mustache 44, // cpp2/service_common/service_class_name.mustache 47, // cpp2/service_common/sync_function_return_param_server.mustache 62, // cpp2/service_common/sync_function_return_type_server.mustache 61, // cpp2/service_common/typedefs.mustache 37, // cpp2/service_cpp/async_client_cpp.mustache 42, // cpp2/service_cpp/handlers_cpp.mustache 38, // cpp2/service_cpp/interaction_constructor_map.mustache 53, // cpp2/service_cpp/processmap.mustache 36, // cpp2/service_cpp/service_inl.mustache 37, // cpp2/service_cpp/service_interface_impl.mustache 48, // cpp2/service_cpp/service_null_impl.mustache 43, // cpp2/service_h/async_client.mustache 36, // cpp2/service_h/async_client_functions.mustache 46, // cpp2/service_h/async_processor.mustache 39, // cpp2/service_h/async_processor_per_function.mustache 52, // cpp2/service_h/handlers_h.mustache 34, // cpp2/service_h/interaction_async_client.mustache 48, // cpp2/service_h/interaction_service_interface.mustache 53, // cpp2/service_h/service_info_holder.mustache 43, // cpp2/service_h/service_interface.mustache 41, // cpp2/service_h/service_interface_functions.mustache 51, // cpp2/service_h/service_null.mustache 36, // cpp2/service_processmap_protocol.cpp.mustache 45, // cpp2/service_tcc/field_data_params.mustache 43, // cpp2/service_tcc/field_data_return.mustache 43, // cpp2/service_tcc/field_data_throws.mustache 43, // cpp2/service_tcc/get_args_ref.mustache 38, // cpp2/service_tcc/process_and_return.mustache 44, // cpp2/service_tcc/typedef_params.mustache 40, // cpp2/service_tcc/typedef_result.mustache 40, // cpp2/types/adapter_post.mustache 32, // cpp2/types/adapter_pre.mustache 31, // cpp2/types/apply_indirection_post.mustache 42, // cpp2/types/apply_indirection_pre.mustache 41, // cpp2/types/callback_type.mustache 33, // cpp2/types/const_value_type.mustache 36, // cpp2/types/function_kind.mustache 33, // cpp2/types/indirected_string_type.mustache 42, // cpp2/types/param_type_client.mustache 37, // cpp2/types/param_type_server.mustache 37, // cpp2/types/return_type_client.mustache 38, // cpp2/types/return_type_client_lift_unit.mustache 48, // cpp2/types/return_type_client_no_handle.mustache 48, // cpp2/types/return_type_server.mustache 38, // cpp2/types/return_type_server_lift_unit.mustache 48, // cpp2/types_custom_protocol.h.mustache 37, // go/codec/decode.mustache 24, // go/codec/decode_base.mustache 29, // go/codec/decode_enum.mustache 29, // go/codec/decode_list.mustache 29, // go/codec/decode_map.mustache 28, // go/codec/decode_set.mustache 28, // go/codec/decode_struct.mustache 31, // go/codec/decode_typedef.mustache 32, // go/codec/encode.mustache 24, // go/codec/encode_base.mustache 29, // go/codec/encode_enum.mustache 29, // go/codec/encode_list.mustache 29, // go/codec/encode_map.mustache 28, // go/codec/encode_set.mustache 28, // go/codec/encode_struct.mustache 31, // go/codec/encode_typedef.mustache 32, // go/common/go_zero_value.mustache 32, // go/common/header.mustache 25, // go/common/natural_default_value.mustache 40, // go/common/pointerize_func.mustache 34, // go/common/primitive_decode_func.mustache 40, // go/common/primitive_encode_func.mustache 40, // go/common/registry.mustache 27, // go/common/ttype.mustache 24, // go/common/type.mustache 23, // go/common/unused_imports_protection.mustache 44, // go/const.go.mustache 20, // go/const/struct_value.mustache 30, // go/const/value.mustache 23, // go/doc.go.mustache 18, // go/metadata.go.mustache 23, // go/metadata/thrift_metadata_enum.mustache 41, // go/metadata/thrift_metadata_exception.mustache 46, // go/metadata/thrift_metadata_field.mustache 42, // go/metadata/thrift_metadata_function.mustache 45, // go/metadata/thrift_metadata_service.mustache 44, // go/metadata/thrift_metadata_struct.mustache 43, // go/metadata/thrift_primitive_type.mustache 42, // go/metadata/thrift_type_instance.mustache 41, // go/metadata/thrift_type_setter.mustache 39, // go/svc/client.mustache 22, // go/svc/func_signature.mustache 30, // go/svc/func_signature_no_ctx.mustache 37, // go/svc/func_signature_with_ctx.mustache 39, // go/svc/interface.mustache 25, // go/svc/proc_func_name.mustache 30, // go/svc/processor.mustache 25, // go/svcs.go.mustache 19, // go/types.go.mustache 20, // go/types/enum.mustache 22, // go/types/field.mustache 23, // go/types/field_default_value.mustache 37, // go/types/field_method_default_get.mustache 42, // go/types/field_method_get.mustache 34, // go/types/field_method_is_set.mustache 37, // go/types/field_method_read.mustache 35, // go/types/field_method_set.mustache 34, // go/types/field_method_to_string.mustache 40, // go/types/field_method_write.mustache 36, // go/types/field_type.mustache 28, // go/types/struct.mustache 24, // go/types/struct_builder.mustache 32, // go/types/struct_definition.mustache 35, // go/types/struct_method_error.mustache 37, // go/types/struct_method_exception.mustache 41, // go/types/struct_method_new.mustache 35, // go/types/struct_method_read.mustache 36, // go/types/struct_method_string.mustache 38, // go/types/struct_method_write.mustache 37, // go/types/struct_methods.mustache 32, // go/types/typedef.mustache 25, // go/types/typedef_enum.mustache 30, // go/types/typedef_enum_go_qualified_name.mustache 48, // go/types/typedef_method_new.mustache 36, // go/types/typedef_method_read.mustache 37, // go/types/typedef_method_write.mustache 38, // html/index.html.mustache 24, // java/AdaptedBoxedType.mustache 30, // java/AdaptedType.mustache 25, // java/AsyncReactiveWrapper.mustache 34, // java/AutoGenerated.mustache 27, // java/BlockingReactiveWrapper.mustache 37, // java/BoxedType.mustache 23, // java/ConstantStruct.mustache 28, // java/ConstantUnion.mustache 27, // java/Constants.mustache 23, // java/Default.mustache 21, // java/DefaultValue.mustache 26, // java/DefaultValueContainer.mustache 35, // java/Enum.mustache 18, // java/Exception.mustache 23, // java/ExceptionMessage.mustache 30, // java/FieldType.mustache 23, // java/FieldTypeNoWrapper.mustache 32, // java/FromThriftEnd.mustache 27, // java/FromThriftStart.mustache 29, // java/GetterName.mustache 24, // java/KeyValue.mustache 22, // java/Object.mustache 20, // java/ReactiveAsyncWrapper.mustache 34, // java/ReactiveBlockingWrapper.mustache 37, // java/ReactiveClient.mustache 28, // java/ReadType.mustache 22, // java/ReadTypeBinary.mustache 28, // java/ReadTypeContainer.mustache 31, // java/ReadTypeContainerNestedKey.mustache 40, // java/ReadTypeContainerNestedValue.mustache 42, // java/Requiredness.mustache 26, // java/RpcServerHandler.mustache 30, // java/Service.mustache 21, // java/SetterName.mustache 24, // java/SinkResponseGeneric.mustache 33, // java/SinkReturnType.mustache 28, // java/SinkWrapperReturnType.mustache 35, // java/StreamResponseGeneric.mustache 35, // java/StreamReturnType.mustache 30, // java/Struct.mustache 20, // java/TType.mustache 19, // java/ThriftBoxedType.mustache 29, // java/ThriftFieldAnnotation.mustache 35, // java/ThriftFieldType.mustache 29, // java/ThriftType.mustache 24, // java/ToThriftEnd.mustache 25, // java/ToThriftStart.mustache 27, // java/Type.mustache 18, // java/TypeCap.mustache 21, // java/TypeList.mustache 22, // java/TypeReader.mustache 24, // java/Union.mustache 19, // java/Utf8Validation.mustache 28, // java/WriteNestedType.mustache 29, // java/WriteRequestType.mustache 30, // java/WriteResponseType.mustache 31, // java/WriteSinkPayloadType.mustache 34, // java/WriteType.mustache 23, // java/WriteTypeAdapter.mustache 30, // java/common/ObjectCustomAnnotation.mustache 43, // java/deprecated/ServiceAsyncClient.mustache 43, // java/deprecated/ServiceClient.mustache 38, // java/enum/ClosedEnum.mustache 29, // java/enum/OpenEnum.mustache 27, // java/struct/AdapterDefinition.mustache 38, // java/struct/CreateStruct.mustache 33, // java/struct/FieldGetter.mustache 32, // java/struct/FieldNullability.mustache 37, // java/struct/FieldSetter.mustache 32, // java/struct/FieldValue.mustache 31, // java/struct/FieldValueNoWrapper.mustache 40, // java/struct/IntrinsicDefault.mustache 37, // java/struct/NestedAdapterDefinition.mustache 44, // java/struct/StructBuilder.mustache 34, // java/struct/StructEquals.mustache 33, // java/struct/StructHashCode.mustache 35, // java/struct/StructRead.mustache 31, // java/struct/StructToString.mustache 35, // java/struct/StructWrite.mustache 32, // java/struct/ThriftConstructor.mustache 38, // java/union/UnionBuilder.mustache 32, // java/union/UnionRead.mustache 29, // java/union/UnionSetter.mustache 31, // java/union/UnionWrite.mustache 30, // json/const_value.mustache 25, // json/enums.mustache 19, // json/return_type.mustache 25, // json/services.mustache 22, // json/structs.mustache 21, // json/structured_annotations.mustache 36, // json/thrift_ast.mustache 24, // json/type.mustache 18, // py3/builders.pxd.mustache 25, // py3/builders.pyi.mustache 25, // py3/builders.pyx.mustache 25, // py3/clients.pxd.mustache 24, // py3/clients.py.mustache 23, // py3/clients.pyi.mustache 24, // py3/clients.pyx.mustache 24, // py3/clients/callback.mustache 29, // py3/clients/callback_body.mustache 34, // py3/clients/clients_wrapper.cpp_func_body.mustache 50, // py3/clients/cpp_return_type.mustache 36, // py3/clients/cython_cpp_value_to_return_value.mustache 53, // py3/clients/cython_python_to_cpp_arg.mustache 45, // py3/clients/cython_return_type_cpp_type.mustache 48, // py3/clients/stream_response_class_name.mustache 47, // py3/clients_wrapper.cpp.mustache 32, // py3/clients_wrapper.h.mustache 30, // py3/clients_wrapper.pxd.mustache 32, // py3/common/annotation.mustache 30, // py3/common/auto_generated_c.mustache 36, // py3/common/auto_generated_py.mustache 37, // py3/common/auto_migrate_import_prefix.mustache 46, // py3/common/auto_migrate_prefix.mustache 39, // py3/common/python_types_module_path.mustache 44, // py3/converter.pxd.mustache 26, // py3/converter.pyx.mustache 26, // py3/metadata.cpp.mustache 25, // py3/metadata.h.mustache 23, // py3/metadata.pxd.mustache 25, // py3/metadata.py.mustache 24, // py3/metadata.pyi.mustache 25, // py3/metadata.pyx.mustache 25, // py3/py3_clients.pxd.mustache 28, // py3/py3_clients.pyi.mustache 28, // py3/py3_clients.pyx.mustache 28, // py3/py3_services.pxd.mustache 29, // py3/py3_services.pyi.mustache 29, // py3/py3_services.pyx.mustache 29, // py3/py3_types.pxd.mustache 26, // py3/py3_types.pyi.mustache 26, // py3/py3_types.pyx.mustache 26, // py3/services.pxd.mustache 25, // py3/services.py.mustache 24, // py3/services.pyi.mustache 25, // py3/services.pyx.mustache 25, // py3/services/callback.mustache 30, // py3/services/cpp_field_capture.mustache 39, // py3/services/cpp_handler_callback_type.mustache 47, // py3/services/cpp_pass_field.mustache 36, // py3/services/cpp_return_type.mustache 37, // py3/services/cython_cpp_to_python.mustache 42, // py3/services/cython_field_type.mustache 39, // py3/services/cython_return_type_cpp_type.mustache 49, // py3/services/cython_return_value.mustache 41, // py3/services/promise.mustache 29, // py3/services/promise_name.mustache 34, // py3/services/return_type_pep484_type.mustache 45, // py3/services/stream_response_class_name.mustache 48, // py3/services_reflection.pxd.mustache 36, // py3/services_reflection.pyx.mustache 36, // py3/services_wrapper.cpp.mustache 33, // py3/services_wrapper.h.mustache 31, // py3/services_wrapper.pxd.mustache 33, // py3/stream/cython_cpp_value_to_python_value.mustache 52, // py3/stream/response_class_name_suffix.mustache 46, // py3/stream/stream_promises.mustache 35, // py3/types.h.mustache 20, // py3/types.pxd.mustache 22, // py3/types.py.mustache 21, // py3/types.pyi.mustache 22, // py3/types.pyx.mustache 22, // py3/types/cimport_extern.mustache 33, // py3/types/compatible_pep484_containers.mustache 47, // py3/types/compatible_pep484_type.mustache 41, // py3/types/constant_extern.mustache 34, // py3/types/constant_value.mustache 33, // py3/types/container_cython_cpp_to_python_item.mustache 54, // py3/types/container_cython_cpp_to_python_key.mustache 53, // py3/types/cpp_arg_type.mustache 31, // py3/types/cpp_stack_arg_type.mustache 37, // py3/types/cpp_value_type.mustache 33, // py3/types/current_module_types.mustache 39, // py3/types/custom_template.mustache 34, // py3/types/custom_type.mustache 30, // py3/types/cython_cast_or_create_python_type.mustache 52, // py3/types/cython_cpp_basic_type.mustache 40, // py3/types/cython_cpp_return_type_ident.mustache 47, // py3/types/cython_cpp_struct_field_type.mustache 47, // py3/types/cython_cpp_type.mustache 34, // py3/types/cython_cpp_type_ident.mustache 40, // py3/types/cython_cpp_value_to_python.mustache 45, // py3/types/cython_field_ref.mustache 35, // py3/types/cython_field_value_for_assignment.mustache 52, // py3/types/cython_field_value_ref.mustache 41, // py3/types/cython_python_to_cpp_item.mustache 44, // py3/types/cython_python_to_cpp_key.mustache 43, // py3/types/cython_python_type.mustache 37, // py3/types/cython_struct_getter.mustache 39, // py3/types/cython_union_assign_field.mustache 44, // py3/types/cython_union_getter.mustache 38, // py3/types/enum.mustache 23, // py3/types/enum_defs.mustache 28, // py3/types/enum_extern.mustache 30, // py3/types/field_cppname.mustache 32, // py3/types/pep484_containers.mustache 36, // py3/types/pep484_type.mustache 30, // py3/types/python_is_instance_type.mustache 42, // py3/types/python_struct_class.mustache 38, // py3/types/python_type.mustache 30, // py3/types/struct_extern.mustache 32, // py3/types/thrift_number_type.mustache 37, // py3/types/type_default_value.mustache 37, // py3/types/union_type_enum.mustache 34, // py3/types_fields.pxd.mustache 29, // py3/types_fields.pyx.mustache 29, // py3/types_reflection.py.mustache 32, // pyi/common/AutoGeneratedPy.mustache 35, // pyi/common/Constant.mustache 28, // pyi/common/FieldType.mustache 29, // pyi/common/ModulePath.mustache 30, // pyi/common/OptionalFieldType.mustache 37, // pyi/constants.pyi.mustache 26, // pyi/service.pyi.mustache 24, // pyi/ttypes.pyi.mustache 23, // python/clients/client_body.mustache 35, // python/clients/client_return_type.mustache 42, // python/clients/stream_response_class_name.mustache 50, // python/common/annotation.mustache 33, // python/common/auto_generated_py.mustache 40, // python/fields/adapted_type.mustache 35, // python/fields/adapter_info.mustache 35, // python/fields/compatible_adapted_type.mustache 46, // python/fields/is_primitive.mustache 35, // python/metadata/const_struct.mustache 37, // python/metadata/const_value.mustache 36, // python/metadata/recursive_call.mustache 39, // python/metadata/return_type.mustache 36, // python/metadata/service_metadata.mustache 41, // python/metadata/thrift_type.mustache 36, // python/services/client_module_path.mustache 43, // python/services/function_kind.mustache 38, // python/services/get_handler_result.mustache 43, // python/services/service_func_return_type.mustache 49, // python/services/service_handler_return_type.mustache 52, // python/structs/unadapted_name.mustache 38, // python/thrift_clients.py.mustache 33, // python/thrift_metadata.py.mustache 34, // python/thrift_mutable_types.py.mustache 39, // python/thrift_mutable_types.pyi.mustache 40, // python/thrift_services.py.mustache 34, // python/thrift_types.py.mustache 31, // python/thrift_types.pyi.mustache 32, // python/types/compatible_pep484_type.mustache 44, // python/types/compatible_unadapted_pep484_type.mustache 54, // python/types/constant_value.mustache 36, // python/types/field_value_pep484_union_type.mustache 51, // python/types/function_args_type.mustache 40, // python/types/function_return_type.mustache 42, // python/types/function_second_return_type.mustache 49, // python/types/pep484_return_type.mustache 40, // python/types/pep484_type.mustache 33, // python/types/python_type.mustache 33, // python/types/service_arg_type_list.mustache 43, // python/types/service_arg_types.mustache 39, // python/types/service_arg_types_pyi.mustache 43, // python/types/typedef_const_pep484_type.mustache 47, // python/types/typeinfo.mustache 30, // python/types/unadapted_pep484_type.mustache 43, // python_capi/common/auto_generated_cpp.mustache 46, // python_capi/common/auto_generated_cython.mustache 49, // python_capi/common/tuple_position.mustache 42, // python_capi/thrift_types_capi.cpp.mustache 42, // python_capi/thrift_types_capi.h.mustache 40, // python_capi/thrift_types_capi.pxd.mustache 42, // python_capi/thrift_types_capi.pyx.mustache 42, // rust/client.rs.mustache 23, // rust/consts.rs.mustache 23, // rust/errors.rs.mustache 23, // rust/lib/adapter/const_test.mustache 36, // rust/lib/adapter/default_test.mustache 38, // rust/lib/adapter/name.mustache 30, // rust/lib/adapter/qualified.mustache 35, // rust/lib/annfieldread.mustache 30, // rust/lib/annfieldtype.mustache 30, // rust/lib/annfieldwrite.mustache 31, // rust/lib/arg.mustache 21, // rust/lib/arg_inner.mustache 27, // rust/lib/arg_life.mustache 26, // rust/lib/block.mustache 23, // rust/lib/client.mustache 24, // rust/lib/client_errors.mustache 31, // rust/lib/client_return_type.mustache 36, // rust/lib/const.mustache 23, // rust/lib/enum.mustache 22, // rust/lib/errors.mustache 24, // rust/lib/fieldtype.mustache 27, // rust/lib/fieldvalue.mustache 28, // rust/lib/function_stream_elem_type.mustache 43, // rust/lib/function_stream_first_response_type.mustache 53, // rust/lib/metadata/struct.mustache 33, // rust/lib/method_names.mustache 30, // rust/lib/mod.adapted_types.mustache 35, // rust/lib/mod.adapters.mustache 30, // rust/lib/mod.impl.mustache 26, // rust/lib/mod.unadapted.mustache 31, // rust/lib/rawtype.mustache 25, // rust/lib/read.mustache 22, // rust/lib/return_type.mustache 29, // rust/lib/server.mustache 24, // rust/lib/server_errors.mustache 31, // rust/lib/server_ok_type.mustache 32, // rust/lib/server_return_type.mustache 36, // rust/lib/service.mustache 25, // rust/lib/struct.mustache 24, // rust/lib/structimpl.mustache 28, // rust/lib/structvalue_epilogue.mustache 38, // rust/lib/super.mustache 23, // rust/lib/ttype.mustache 23, // rust/lib/type.mustache 22, // rust/lib/typedef.mustache 25, // rust/lib/typedefimpl.mustache 29, // rust/lib/unionimpl.mustache 27, // rust/lib/value.mustache 23, // rust/lib/write.mustache 23, // rust/mock.rs.mustache 21, // rust/server.rs.mustache 23, // rust/services.rs.mustache 25, // rust/types.rs.mustache 22, // starlark/consts.mustache 24, // starlark/consts/value.mustache 30, // starlark/definitions.star.mustache 34, // starlark/enums.mustache 23, }; char const* const templates_name_datas[] = { // cpp2/Autogen.mustache "cpp2/Autogen.mustache", // cpp2/ServiceAsyncClient.cpp.mustache "cpp2/ServiceAsyncClient.cpp.mustache", // cpp2/ServiceAsyncClient.h.mustache "cpp2/ServiceAsyncClient.h.mustache", // cpp2/common/colon_newline.mustache "cpp2/common/colon_newline.mustache", // cpp2/common/comma_newline.mustache "cpp2/common/comma_newline.mustache", // cpp2/common/const_type_recursive.mustache "cpp2/common/const_type_recursive.mustache", // cpp2/common/const_value.mustache "cpp2/common/const_value.mustache", // cpp2/common/field_suffix.mustache "cpp2/common/field_suffix.mustache", // cpp2/common/field_value.mustache "cpp2/common/field_value.mustache", // cpp2/common/frozen2_union_field_suffix.mustache "cpp2/common/frozen2_union_field_suffix.mustache", // cpp2/common/fun_docblock.mustache "cpp2/common/fun_docblock.mustache", // cpp2/common/function_name.mustache "cpp2/common/function_name.mustache", // cpp2/common/iterate_const_values.mustache "cpp2/common/iterate_const_values.mustache", // cpp2/common/iterate_const_values_adapted.mustache "cpp2/common/iterate_const_values_adapted.mustache", // cpp2/common/iterate_const_values_non_referenceable.mustache "cpp2/common/iterate_const_values_non_referenceable.mustache", // cpp2/common/namespace_cpp2.mustache "cpp2/common/namespace_cpp2.mustache", // cpp2/common/namespace_cpp2_begin.mustache "cpp2/common/namespace_cpp2_begin.mustache", // cpp2/common/namespace_cpp2_end.mustache "cpp2/common/namespace_cpp2_end.mustache", // cpp2/common/service_namespace_cpp2.mustache "cpp2/common/service_namespace_cpp2.mustache", // cpp2/common/service_namespace_cpp2_begin.mustache "cpp2/common/service_namespace_cpp2_begin.mustache", // cpp2/common/service_namespace_cpp2_end.mustache "cpp2/common/service_namespace_cpp2_end.mustache", // cpp2/common/type_namespace_cpp2.mustache "cpp2/common/type_namespace_cpp2.mustache", // cpp2/fatal/fatal_using_string_declaration.mustache "cpp2/fatal/fatal_using_string_declaration.mustache", // cpp2/field/default.mustache "cpp2/field/default.mustache", // cpp2/field/intrinsic_default.mustache "cpp2/field/intrinsic_default.mustache", // cpp2/field/member.mustache "cpp2/field/member.mustache", // cpp2/field/tag.mustache "cpp2/field/tag.mustache", // cpp2/metadata/const_struct.mustache "cpp2/metadata/const_struct.mustache", // cpp2/metadata/const_value.mustache "cpp2/metadata/const_value.mustache", // cpp2/metadata/field_gen.mustache "cpp2/metadata/field_gen.mustache", // cpp2/metadata/func_field_gen.mustache "cpp2/metadata/func_field_gen.mustache", // cpp2/metadata/func_field_name.mustache "cpp2/metadata/func_field_name.mustache", // cpp2/metadata/return_type_gen.mustache "cpp2/metadata/return_type_gen.mustache", // cpp2/metadata/type_gen.mustache "cpp2/metadata/type_gen.mustache", // cpp2/metadata/unstructured_field_gen.mustache "cpp2/metadata/unstructured_field_gen.mustache", // cpp2/module_clients.cpp.mustache "cpp2/module_clients.cpp.mustache", // cpp2/module_clients.h.mustache "cpp2/module_clients.h.mustache", // cpp2/module_clients_out_of_line.h.mustache "cpp2/module_clients_out_of_line.h.mustache", // cpp2/module_constants.cpp.mustache "cpp2/module_constants.cpp.mustache", // cpp2/module_constants.h.mustache "cpp2/module_constants.h.mustache", // cpp2/module_data.cpp.mustache "cpp2/module_data.cpp.mustache", // cpp2/module_data.h.mustache "cpp2/module_data.h.mustache", // cpp2/module_fatal.h.mustache "cpp2/module_fatal.h.mustache", // cpp2/module_fatal_all.h.mustache "cpp2/module_fatal_all.h.mustache", // cpp2/module_fatal_constant.h.mustache "cpp2/module_fatal_constant.h.mustache", // cpp2/module_fatal_enum.h.mustache "cpp2/module_fatal_enum.h.mustache", // cpp2/module_fatal_service.h.mustache "cpp2/module_fatal_service.h.mustache", // cpp2/module_fatal_struct.h.mustache "cpp2/module_fatal_struct.h.mustache", // cpp2/module_fatal_types.h.mustache "cpp2/module_fatal_types.h.mustache", // cpp2/module_fatal_union.h.mustache "cpp2/module_fatal_union.h.mustache", // cpp2/module_for_each_field.h.mustache "cpp2/module_for_each_field.h.mustache", // cpp2/module_handlers-inl.h.mustache "cpp2/module_handlers-inl.h.mustache", // cpp2/module_handlers.cpp.mustache "cpp2/module_handlers.cpp.mustache", // cpp2/module_handlers.h.mustache "cpp2/module_handlers.h.mustache", // cpp2/module_handlers_out_of_line.h.mustache "cpp2/module_handlers_out_of_line.h.mustache", // cpp2/module_layouts.cpp.mustache "cpp2/module_layouts.cpp.mustache", // cpp2/module_layouts.h.mustache "cpp2/module_layouts.h.mustache", // cpp2/module_layouts_cpp/frozen_freeze_union.mustache "cpp2/module_layouts_cpp/frozen_freeze_union.mustache", // cpp2/module_layouts_cpp/frozen_layout_union.mustache "cpp2/module_layouts_cpp/frozen_layout_union.mustache", // cpp2/module_layouts_cpp/frozen_thaw_union.mustache "cpp2/module_layouts_cpp/frozen_thaw_union.mustache", // cpp2/module_layouts_h/frozen_view_union.mustache "cpp2/module_layouts_h/frozen_view_union.mustache", // cpp2/module_metadata.cpp.mustache "cpp2/module_metadata.cpp.mustache", // cpp2/module_metadata.h.mustache "cpp2/module_metadata.h.mustache", // cpp2/module_sinit.cpp.mustache "cpp2/module_sinit.cpp.mustache", // cpp2/module_types.cpp.mustache "cpp2/module_types.cpp.mustache", // cpp2/module_types.h.mustache "cpp2/module_types.h.mustache", // cpp2/module_types.tcc.mustache "cpp2/module_types.tcc.mustache", // cpp2/module_types_cpp/assign_overload.mustache "cpp2/module_types_cpp/assign_overload.mustache", // cpp2/module_types_cpp/clear_fields.mustache "cpp2/module_types_cpp/clear_fields.mustache", // cpp2/module_types_cpp/clear_terse_fields.mustache "cpp2/module_types_cpp/clear_terse_fields.mustache", // cpp2/module_types_cpp/copy_ctor.mustache "cpp2/module_types_cpp/copy_ctor.mustache", // cpp2/module_types_cpp/declare_enums.mustache "cpp2/module_types_cpp/declare_enums.mustache", // cpp2/module_types_cpp/declare_members.mustache "cpp2/module_types_cpp/declare_members.mustache", // cpp2/module_types_cpp/declare_union_types.mustache "cpp2/module_types_cpp/declare_union_types.mustache", // cpp2/module_types_cpp/eq_overload.mustache "cpp2/module_types_cpp/eq_overload.mustache", // cpp2/module_types_cpp/field_value_ref.mustache "cpp2/module_types_cpp/field_value_ref.mustache", // cpp2/module_types_cpp/fragile_ctor.mustache "cpp2/module_types_cpp/fragile_ctor.mustache", // cpp2/module_types_cpp/frozen.mustache "cpp2/module_types_cpp/frozen.mustache", // cpp2/module_types_cpp/getters_setters.mustache "cpp2/module_types_cpp/getters_setters.mustache", // cpp2/module_types_cpp/lazy_deserialization.mustache "cpp2/module_types_cpp/lazy_deserialization.mustache", // cpp2/module_types_cpp/move_ctor.mustache "cpp2/module_types_cpp/move_ctor.mustache", // cpp2/module_types_cpp/struct_operator_less.mustache "cpp2/module_types_cpp/struct_operator_less.mustache", // cpp2/module_types_cpp/swap.mustache "cpp2/module_types_cpp/swap.mustache", // cpp2/module_types_cpp/tcc_struct_traits.mustache "cpp2/module_types_cpp/tcc_struct_traits.mustache", // cpp2/module_types_cpp/union_copy_ctor.mustache "cpp2/module_types_cpp/union_copy_ctor.mustache", // cpp2/module_types_cpp/union_declare_members.mustache "cpp2/module_types_cpp/union_declare_members.mustache", // cpp2/module_types_cpp/union_eq_overload.mustache "cpp2/module_types_cpp/union_eq_overload.mustache", // cpp2/module_types_cpp/union_operator_less.mustache "cpp2/module_types_cpp/union_operator_less.mustache", // cpp2/module_types_cpp/union_setters.mustache "cpp2/module_types_cpp/union_setters.mustache", // cpp2/module_types_cpp/union_swap.mustache "cpp2/module_types_cpp/union_swap.mustache", // cpp2/module_types_custom_protocol.h.mustache "cpp2/module_types_custom_protocol.h.mustache", // cpp2/module_types_fwd.h.mustache "cpp2/module_types_fwd.h.mustache", // cpp2/module_types_h/alloc_extended_ctors.mustache "cpp2/module_types_h/alloc_extended_ctors.mustache", // cpp2/module_types_h/base_ctor.mustache "cpp2/module_types_h/base_ctor.mustache", // cpp2/module_types_h/base_ctor_no_alloc_init_list.mustache "cpp2/module_types_h/base_ctor_no_alloc_init_list.mustache", // cpp2/module_types_h/base_ctor_with_alloc_init_list.mustache "cpp2/module_types_h/base_ctor_with_alloc_init_list.mustache", // cpp2/module_types_h/declare_enums.mustache "cpp2/module_types_h/declare_enums.mustache", // cpp2/module_types_h/declare_members.mustache "cpp2/module_types_h/declare_members.mustache", // cpp2/module_types_h/declare_union_types.mustache "cpp2/module_types_h/declare_union_types.mustache", // cpp2/module_types_h/enum_bitwise_ops.mustache "cpp2/module_types_h/enum_bitwise_ops.mustache", // cpp2/module_types_h/field_interceptor.mustache "cpp2/module_types_h/field_interceptor.mustache", // cpp2/module_types_h/field_ref.mustache "cpp2/module_types_h/field_ref.mustache", // cpp2/module_types_h/field_ref_args.mustache "cpp2/module_types_h/field_ref_args.mustache", // cpp2/module_types_h/forward_declare.mustache "cpp2/module_types_h/forward_declare.mustache", // cpp2/module_types_h/fragile_ctor_param_list.mustache "cpp2/module_types_h/fragile_ctor_param_list.mustache", // cpp2/module_types_h/frozen.mustache "cpp2/module_types_h/frozen.mustache", // cpp2/module_types_h/getters_setters.mustache "cpp2/module_types_h/getters_setters.mustache", // cpp2/module_types_h/hash_and_equal_to.mustache "cpp2/module_types_h/hash_and_equal_to.mustache", // cpp2/module_types_h/lazy_deserialization.mustache "cpp2/module_types_h/lazy_deserialization.mustache", // cpp2/module_types_h/reflection.mustache "cpp2/module_types_h/reflection.mustache", // cpp2/module_types_h/smart_ptr_constructor.mustache "cpp2/module_types_h/smart_ptr_constructor.mustache", // cpp2/module_types_h/union_assign_overload.mustache "cpp2/module_types_h/union_assign_overload.mustache", // cpp2/module_types_h/union_copy_ctor.mustache "cpp2/module_types_h/union_copy_ctor.mustache", // cpp2/module_types_h/union_enum.mustache "cpp2/module_types_h/union_enum.mustache", // cpp2/module_types_h/union_field_ref.mustache "cpp2/module_types_h/union_field_ref.mustache", // cpp2/module_types_h/union_getters.mustache "cpp2/module_types_h/union_getters.mustache", // cpp2/module_types_h/union_moves.mustache "cpp2/module_types_h/union_moves.mustache", // cpp2/module_types_h/union_mutables.mustache "cpp2/module_types_h/union_mutables.mustache", // cpp2/module_types_h/union_setters.mustache "cpp2/module_types_h/union_setters.mustache", // cpp2/module_types_h/union_storage.mustache "cpp2/module_types_h/union_storage.mustache", // cpp2/module_types_tcc/container_struct_type.mustache "cpp2/module_types_tcc/container_struct_type.mustache", // cpp2/module_types_tcc/deprecated_terse_has_value.mustache "cpp2/module_types_tcc/deprecated_terse_has_value.mustache", // cpp2/module_types_tcc/deserialize_field.mustache "cpp2/module_types_tcc/deserialize_field.mustache", // cpp2/module_types_tcc/deserialize_struct.mustache "cpp2/module_types_tcc/deserialize_struct.mustache", // cpp2/module_types_tcc/deserialize_union.mustache "cpp2/module_types_tcc/deserialize_union.mustache", // cpp2/module_types_tcc/field_ref.mustache "cpp2/module_types_tcc/field_ref.mustache", // cpp2/module_types_tcc/if_should_write.mustache "cpp2/module_types_tcc/if_should_write.mustache", // cpp2/module_types_tcc/if_should_write_end.mustache "cpp2/module_types_tcc/if_should_write_end.mustache", // cpp2/module_types_tcc/member_or_ptr.mustache "cpp2/module_types_tcc/member_or_ptr.mustache", // cpp2/module_types_tcc/optional_has_value.mustache "cpp2/module_types_tcc/optional_has_value.mustache", // cpp2/module_types_tcc/pm.mustache "cpp2/module_types_tcc/pm.mustache", // cpp2/module_types_tcc/pm_value.mustache "cpp2/module_types_tcc/pm_value.mustache", // cpp2/module_types_tcc/serialize_field.mustache "cpp2/module_types_tcc/serialize_field.mustache", // cpp2/module_types_tcc/serialize_field_size.mustache "cpp2/module_types_tcc/serialize_field_size.mustache", // cpp2/module_types_tcc/serialize_field_size_zc.mustache "cpp2/module_types_tcc/serialize_field_size_zc.mustache", // cpp2/module_types_tcc/serialize_struct.mustache "cpp2/module_types_tcc/serialize_struct.mustache", // cpp2/module_types_tcc/serialize_union.mustache "cpp2/module_types_tcc/serialize_union.mustache", // cpp2/module_types_tcc/struct_field_type.mustache "cpp2/module_types_tcc/struct_field_type.mustache", // cpp2/module_types_tcc/struct_type.mustache "cpp2/module_types_tcc/struct_type.mustache", // cpp2/module_types_tcc/tcc_struct_traits.mustache "cpp2/module_types_tcc/tcc_struct_traits.mustache", // cpp2/module_types_tcc/terse_has_no_value.mustache "cpp2/module_types_tcc/terse_has_no_value.mustache", // cpp2/module_types_tcc/terse_has_value.mustache "cpp2/module_types_tcc/terse_has_value.mustache", // cpp2/module_types_tcc/union_setters.mustache "cpp2/module_types_tcc/union_setters.mustache", // cpp2/module_types_tcc/variable_name.mustache "cpp2/module_types_tcc/variable_name.mustache", // cpp2/module_visit_by_thrift_field_metadata.h.mustache "cpp2/module_visit_by_thrift_field_metadata.h.mustache", // cpp2/module_visit_union.h.mustache "cpp2/module_visit_union.h.mustache", // cpp2/module_visitation.h.mustache "cpp2/module_visitation.h.mustache", // cpp2/service.cpp.mustache "cpp2/service.cpp.mustache", // cpp2/service.h.mustache "cpp2/service.h.mustache", // cpp2/service.tcc.mustache "cpp2/service.tcc.mustache", // cpp2/service_async_client_cpp/coroutine_functions.mustache "cpp2/service_async_client_cpp/coroutine_functions.mustache", // cpp2/service_async_client_cpp/function_implementation.mustache "cpp2/service_async_client_cpp/function_implementation.mustache", // cpp2/service_async_client_cpp/future_functions.mustache "cpp2/service_async_client_cpp/future_functions.mustache", // cpp2/service_async_client_cpp/received.mustache "cpp2/service_async_client_cpp/received.mustache", // cpp2/service_async_client_cpp/received_instance.mustache "cpp2/service_async_client_cpp/received_instance.mustache", // cpp2/service_async_client_cpp/received_wrapped.mustache "cpp2/service_async_client_cpp/received_wrapped.mustache", // cpp2/service_async_client_cpp/sync_functions.mustache "cpp2/service_async_client_cpp/sync_functions.mustache", // cpp2/service_async_client_cpp/templated_received.mustache "cpp2/service_async_client_cpp/templated_received.mustache", // cpp2/service_common/client_class_name.mustache "cpp2/service_common/client_class_name.mustache", // cpp2/service_common/function_param_list_client.mustache "cpp2/service_common/function_param_list_client.mustache", // cpp2/service_common/function_param_list_interceptor.mustache "cpp2/service_common/function_param_list_interceptor.mustache", // cpp2/service_common/function_param_list_server.mustache "cpp2/service_common/function_param_list_server.mustache", // cpp2/service_common/function_param_list_server_commented_out.mustache "cpp2/service_common/function_param_list_server_commented_out.mustache", // cpp2/service_common/param_list.mustache "cpp2/service_common/param_list.mustache", // cpp2/service_common/param_list_move.mustache "cpp2/service_common/param_list_move.mustache", // cpp2/service_common/service_class_name.mustache "cpp2/service_common/service_class_name.mustache", // cpp2/service_common/sync_function_return_param_server.mustache "cpp2/service_common/sync_function_return_param_server.mustache", // cpp2/service_common/sync_function_return_type_server.mustache "cpp2/service_common/sync_function_return_type_server.mustache", // cpp2/service_common/typedefs.mustache "cpp2/service_common/typedefs.mustache", // cpp2/service_cpp/async_client_cpp.mustache "cpp2/service_cpp/async_client_cpp.mustache", // cpp2/service_cpp/handlers_cpp.mustache "cpp2/service_cpp/handlers_cpp.mustache", // cpp2/service_cpp/interaction_constructor_map.mustache "cpp2/service_cpp/interaction_constructor_map.mustache", // cpp2/service_cpp/processmap.mustache "cpp2/service_cpp/processmap.mustache", // cpp2/service_cpp/service_inl.mustache "cpp2/service_cpp/service_inl.mustache", // cpp2/service_cpp/service_interface_impl.mustache "cpp2/service_cpp/service_interface_impl.mustache", // cpp2/service_cpp/service_null_impl.mustache "cpp2/service_cpp/service_null_impl.mustache", // cpp2/service_h/async_client.mustache "cpp2/service_h/async_client.mustache", // cpp2/service_h/async_client_functions.mustache "cpp2/service_h/async_client_functions.mustache", // cpp2/service_h/async_processor.mustache "cpp2/service_h/async_processor.mustache", // cpp2/service_h/async_processor_per_function.mustache "cpp2/service_h/async_processor_per_function.mustache", // cpp2/service_h/handlers_h.mustache "cpp2/service_h/handlers_h.mustache", // cpp2/service_h/interaction_async_client.mustache "cpp2/service_h/interaction_async_client.mustache", // cpp2/service_h/interaction_service_interface.mustache "cpp2/service_h/interaction_service_interface.mustache", // cpp2/service_h/service_info_holder.mustache "cpp2/service_h/service_info_holder.mustache", // cpp2/service_h/service_interface.mustache "cpp2/service_h/service_interface.mustache", // cpp2/service_h/service_interface_functions.mustache "cpp2/service_h/service_interface_functions.mustache", // cpp2/service_h/service_null.mustache "cpp2/service_h/service_null.mustache", // cpp2/service_processmap_protocol.cpp.mustache "cpp2/service_processmap_protocol.cpp.mustache", // cpp2/service_tcc/field_data_params.mustache "cpp2/service_tcc/field_data_params.mustache", // cpp2/service_tcc/field_data_return.mustache "cpp2/service_tcc/field_data_return.mustache", // cpp2/service_tcc/field_data_throws.mustache "cpp2/service_tcc/field_data_throws.mustache", // cpp2/service_tcc/get_args_ref.mustache "cpp2/service_tcc/get_args_ref.mustache", // cpp2/service_tcc/process_and_return.mustache "cpp2/service_tcc/process_and_return.mustache", // cpp2/service_tcc/typedef_params.mustache "cpp2/service_tcc/typedef_params.mustache", // cpp2/service_tcc/typedef_result.mustache "cpp2/service_tcc/typedef_result.mustache", // cpp2/types/adapter_post.mustache "cpp2/types/adapter_post.mustache", // cpp2/types/adapter_pre.mustache "cpp2/types/adapter_pre.mustache", // cpp2/types/apply_indirection_post.mustache "cpp2/types/apply_indirection_post.mustache", // cpp2/types/apply_indirection_pre.mustache "cpp2/types/apply_indirection_pre.mustache", // cpp2/types/callback_type.mustache "cpp2/types/callback_type.mustache", // cpp2/types/const_value_type.mustache "cpp2/types/const_value_type.mustache", // cpp2/types/function_kind.mustache "cpp2/types/function_kind.mustache", // cpp2/types/indirected_string_type.mustache "cpp2/types/indirected_string_type.mustache", // cpp2/types/param_type_client.mustache "cpp2/types/param_type_client.mustache", // cpp2/types/param_type_server.mustache "cpp2/types/param_type_server.mustache", // cpp2/types/return_type_client.mustache "cpp2/types/return_type_client.mustache", // cpp2/types/return_type_client_lift_unit.mustache "cpp2/types/return_type_client_lift_unit.mustache", // cpp2/types/return_type_client_no_handle.mustache "cpp2/types/return_type_client_no_handle.mustache", // cpp2/types/return_type_server.mustache "cpp2/types/return_type_server.mustache", // cpp2/types/return_type_server_lift_unit.mustache "cpp2/types/return_type_server_lift_unit.mustache", // cpp2/types_custom_protocol.h.mustache "cpp2/types_custom_protocol.h.mustache", // go/codec/decode.mustache "go/codec/decode.mustache", // go/codec/decode_base.mustache "go/codec/decode_base.mustache", // go/codec/decode_enum.mustache "go/codec/decode_enum.mustache", // go/codec/decode_list.mustache "go/codec/decode_list.mustache", // go/codec/decode_map.mustache "go/codec/decode_map.mustache", // go/codec/decode_set.mustache "go/codec/decode_set.mustache", // go/codec/decode_struct.mustache "go/codec/decode_struct.mustache", // go/codec/decode_typedef.mustache "go/codec/decode_typedef.mustache", // go/codec/encode.mustache "go/codec/encode.mustache", // go/codec/encode_base.mustache "go/codec/encode_base.mustache", // go/codec/encode_enum.mustache "go/codec/encode_enum.mustache", // go/codec/encode_list.mustache "go/codec/encode_list.mustache", // go/codec/encode_map.mustache "go/codec/encode_map.mustache", // go/codec/encode_set.mustache "go/codec/encode_set.mustache", // go/codec/encode_struct.mustache "go/codec/encode_struct.mustache", // go/codec/encode_typedef.mustache "go/codec/encode_typedef.mustache", // go/common/go_zero_value.mustache "go/common/go_zero_value.mustache", // go/common/header.mustache "go/common/header.mustache", // go/common/natural_default_value.mustache "go/common/natural_default_value.mustache", // go/common/pointerize_func.mustache "go/common/pointerize_func.mustache", // go/common/primitive_decode_func.mustache "go/common/primitive_decode_func.mustache", // go/common/primitive_encode_func.mustache "go/common/primitive_encode_func.mustache", // go/common/registry.mustache "go/common/registry.mustache", // go/common/ttype.mustache "go/common/ttype.mustache", // go/common/type.mustache "go/common/type.mustache", // go/common/unused_imports_protection.mustache "go/common/unused_imports_protection.mustache", // go/const.go.mustache "go/const.go.mustache", // go/const/struct_value.mustache "go/const/struct_value.mustache", // go/const/value.mustache "go/const/value.mustache", // go/doc.go.mustache "go/doc.go.mustache", // go/metadata.go.mustache "go/metadata.go.mustache", // go/metadata/thrift_metadata_enum.mustache "go/metadata/thrift_metadata_enum.mustache", // go/metadata/thrift_metadata_exception.mustache "go/metadata/thrift_metadata_exception.mustache", // go/metadata/thrift_metadata_field.mustache "go/metadata/thrift_metadata_field.mustache", // go/metadata/thrift_metadata_function.mustache "go/metadata/thrift_metadata_function.mustache", // go/metadata/thrift_metadata_service.mustache "go/metadata/thrift_metadata_service.mustache", // go/metadata/thrift_metadata_struct.mustache "go/metadata/thrift_metadata_struct.mustache", // go/metadata/thrift_primitive_type.mustache "go/metadata/thrift_primitive_type.mustache", // go/metadata/thrift_type_instance.mustache "go/metadata/thrift_type_instance.mustache", // go/metadata/thrift_type_setter.mustache "go/metadata/thrift_type_setter.mustache", // go/svc/client.mustache "go/svc/client.mustache", // go/svc/func_signature.mustache "go/svc/func_signature.mustache", // go/svc/func_signature_no_ctx.mustache "go/svc/func_signature_no_ctx.mustache", // go/svc/func_signature_with_ctx.mustache "go/svc/func_signature_with_ctx.mustache", // go/svc/interface.mustache "go/svc/interface.mustache", // go/svc/proc_func_name.mustache "go/svc/proc_func_name.mustache", // go/svc/processor.mustache "go/svc/processor.mustache", // go/svcs.go.mustache "go/svcs.go.mustache", // go/types.go.mustache "go/types.go.mustache", // go/types/enum.mustache "go/types/enum.mustache", // go/types/field.mustache "go/types/field.mustache", // go/types/field_default_value.mustache "go/types/field_default_value.mustache", // go/types/field_method_default_get.mustache "go/types/field_method_default_get.mustache", // go/types/field_method_get.mustache "go/types/field_method_get.mustache", // go/types/field_method_is_set.mustache "go/types/field_method_is_set.mustache", // go/types/field_method_read.mustache "go/types/field_method_read.mustache", // go/types/field_method_set.mustache "go/types/field_method_set.mustache", // go/types/field_method_to_string.mustache "go/types/field_method_to_string.mustache", // go/types/field_method_write.mustache "go/types/field_method_write.mustache", // go/types/field_type.mustache "go/types/field_type.mustache", // go/types/struct.mustache "go/types/struct.mustache", // go/types/struct_builder.mustache "go/types/struct_builder.mustache", // go/types/struct_definition.mustache "go/types/struct_definition.mustache", // go/types/struct_method_error.mustache "go/types/struct_method_error.mustache", // go/types/struct_method_exception.mustache "go/types/struct_method_exception.mustache", // go/types/struct_method_new.mustache "go/types/struct_method_new.mustache", // go/types/struct_method_read.mustache "go/types/struct_method_read.mustache", // go/types/struct_method_string.mustache "go/types/struct_method_string.mustache", // go/types/struct_method_write.mustache "go/types/struct_method_write.mustache", // go/types/struct_methods.mustache "go/types/struct_methods.mustache", // go/types/typedef.mustache "go/types/typedef.mustache", // go/types/typedef_enum.mustache "go/types/typedef_enum.mustache", // go/types/typedef_enum_go_qualified_name.mustache "go/types/typedef_enum_go_qualified_name.mustache", // go/types/typedef_method_new.mustache "go/types/typedef_method_new.mustache", // go/types/typedef_method_read.mustache "go/types/typedef_method_read.mustache", // go/types/typedef_method_write.mustache "go/types/typedef_method_write.mustache", // html/index.html.mustache "html/index.html.mustache", // java/AdaptedBoxedType.mustache "java/AdaptedBoxedType.mustache", // java/AdaptedType.mustache "java/AdaptedType.mustache", // java/AsyncReactiveWrapper.mustache "java/AsyncReactiveWrapper.mustache", // java/AutoGenerated.mustache "java/AutoGenerated.mustache", // java/BlockingReactiveWrapper.mustache "java/BlockingReactiveWrapper.mustache", // java/BoxedType.mustache "java/BoxedType.mustache", // java/ConstantStruct.mustache "java/ConstantStruct.mustache", // java/ConstantUnion.mustache "java/ConstantUnion.mustache", // java/Constants.mustache "java/Constants.mustache", // java/Default.mustache "java/Default.mustache", // java/DefaultValue.mustache "java/DefaultValue.mustache", // java/DefaultValueContainer.mustache "java/DefaultValueContainer.mustache", // java/Enum.mustache "java/Enum.mustache", // java/Exception.mustache "java/Exception.mustache", // java/ExceptionMessage.mustache "java/ExceptionMessage.mustache", // java/FieldType.mustache "java/FieldType.mustache", // java/FieldTypeNoWrapper.mustache "java/FieldTypeNoWrapper.mustache", // java/FromThriftEnd.mustache "java/FromThriftEnd.mustache", // java/FromThriftStart.mustache "java/FromThriftStart.mustache", // java/GetterName.mustache "java/GetterName.mustache", // java/KeyValue.mustache "java/KeyValue.mustache", // java/Object.mustache "java/Object.mustache", // java/ReactiveAsyncWrapper.mustache "java/ReactiveAsyncWrapper.mustache", // java/ReactiveBlockingWrapper.mustache "java/ReactiveBlockingWrapper.mustache", // java/ReactiveClient.mustache "java/ReactiveClient.mustache", // java/ReadType.mustache "java/ReadType.mustache", // java/ReadTypeBinary.mustache "java/ReadTypeBinary.mustache", // java/ReadTypeContainer.mustache "java/ReadTypeContainer.mustache", // java/ReadTypeContainerNestedKey.mustache "java/ReadTypeContainerNestedKey.mustache", // java/ReadTypeContainerNestedValue.mustache "java/ReadTypeContainerNestedValue.mustache", // java/Requiredness.mustache "java/Requiredness.mustache", // java/RpcServerHandler.mustache "java/RpcServerHandler.mustache", // java/Service.mustache "java/Service.mustache", // java/SetterName.mustache "java/SetterName.mustache", // java/SinkResponseGeneric.mustache "java/SinkResponseGeneric.mustache", // java/SinkReturnType.mustache "java/SinkReturnType.mustache", // java/SinkWrapperReturnType.mustache "java/SinkWrapperReturnType.mustache", // java/StreamResponseGeneric.mustache "java/StreamResponseGeneric.mustache", // java/StreamReturnType.mustache "java/StreamReturnType.mustache", // java/Struct.mustache "java/Struct.mustache", // java/TType.mustache "java/TType.mustache", // java/ThriftBoxedType.mustache "java/ThriftBoxedType.mustache", // java/ThriftFieldAnnotation.mustache "java/ThriftFieldAnnotation.mustache", // java/ThriftFieldType.mustache "java/ThriftFieldType.mustache", // java/ThriftType.mustache "java/ThriftType.mustache", // java/ToThriftEnd.mustache "java/ToThriftEnd.mustache", // java/ToThriftStart.mustache "java/ToThriftStart.mustache", // java/Type.mustache "java/Type.mustache", // java/TypeCap.mustache "java/TypeCap.mustache", // java/TypeList.mustache "java/TypeList.mustache", // java/TypeReader.mustache "java/TypeReader.mustache", // java/Union.mustache "java/Union.mustache", // java/Utf8Validation.mustache "java/Utf8Validation.mustache", // java/WriteNestedType.mustache "java/WriteNestedType.mustache", // java/WriteRequestType.mustache "java/WriteRequestType.mustache", // java/WriteResponseType.mustache "java/WriteResponseType.mustache", // java/WriteSinkPayloadType.mustache "java/WriteSinkPayloadType.mustache", // java/WriteType.mustache "java/WriteType.mustache", // java/WriteTypeAdapter.mustache "java/WriteTypeAdapter.mustache", // java/common/ObjectCustomAnnotation.mustache "java/common/ObjectCustomAnnotation.mustache", // java/deprecated/ServiceAsyncClient.mustache "java/deprecated/ServiceAsyncClient.mustache", // java/deprecated/ServiceClient.mustache "java/deprecated/ServiceClient.mustache", // java/enum/ClosedEnum.mustache "java/enum/ClosedEnum.mustache", // java/enum/OpenEnum.mustache "java/enum/OpenEnum.mustache", // java/struct/AdapterDefinition.mustache "java/struct/AdapterDefinition.mustache", // java/struct/CreateStruct.mustache "java/struct/CreateStruct.mustache", // java/struct/FieldGetter.mustache "java/struct/FieldGetter.mustache", // java/struct/FieldNullability.mustache "java/struct/FieldNullability.mustache", // java/struct/FieldSetter.mustache "java/struct/FieldSetter.mustache", // java/struct/FieldValue.mustache "java/struct/FieldValue.mustache", // java/struct/FieldValueNoWrapper.mustache "java/struct/FieldValueNoWrapper.mustache", // java/struct/IntrinsicDefault.mustache "java/struct/IntrinsicDefault.mustache", // java/struct/NestedAdapterDefinition.mustache "java/struct/NestedAdapterDefinition.mustache", // java/struct/StructBuilder.mustache "java/struct/StructBuilder.mustache", // java/struct/StructEquals.mustache "java/struct/StructEquals.mustache", // java/struct/StructHashCode.mustache "java/struct/StructHashCode.mustache", // java/struct/StructRead.mustache "java/struct/StructRead.mustache", // java/struct/StructToString.mustache "java/struct/StructToString.mustache", // java/struct/StructWrite.mustache "java/struct/StructWrite.mustache", // java/struct/ThriftConstructor.mustache "java/struct/ThriftConstructor.mustache", // java/union/UnionBuilder.mustache "java/union/UnionBuilder.mustache", // java/union/UnionRead.mustache "java/union/UnionRead.mustache", // java/union/UnionSetter.mustache "java/union/UnionSetter.mustache", // java/union/UnionWrite.mustache "java/union/UnionWrite.mustache", // json/const_value.mustache "json/const_value.mustache", // json/enums.mustache "json/enums.mustache", // json/return_type.mustache "json/return_type.mustache", // json/services.mustache "json/services.mustache", // json/structs.mustache "json/structs.mustache", // json/structured_annotations.mustache "json/structured_annotations.mustache", // json/thrift_ast.mustache "json/thrift_ast.mustache", // json/type.mustache "json/type.mustache", // py3/builders.pxd.mustache "py3/builders.pxd.mustache", // py3/builders.pyi.mustache "py3/builders.pyi.mustache", // py3/builders.pyx.mustache "py3/builders.pyx.mustache", // py3/clients.pxd.mustache "py3/clients.pxd.mustache", // py3/clients.py.mustache "py3/clients.py.mustache", // py3/clients.pyi.mustache "py3/clients.pyi.mustache", // py3/clients.pyx.mustache "py3/clients.pyx.mustache", // py3/clients/callback.mustache "py3/clients/callback.mustache", // py3/clients/callback_body.mustache "py3/clients/callback_body.mustache", // py3/clients/clients_wrapper.cpp_func_body.mustache "py3/clients/clients_wrapper.cpp_func_body.mustache", // py3/clients/cpp_return_type.mustache "py3/clients/cpp_return_type.mustache", // py3/clients/cython_cpp_value_to_return_value.mustache "py3/clients/cython_cpp_value_to_return_value.mustache", // py3/clients/cython_python_to_cpp_arg.mustache "py3/clients/cython_python_to_cpp_arg.mustache", // py3/clients/cython_return_type_cpp_type.mustache "py3/clients/cython_return_type_cpp_type.mustache", // py3/clients/stream_response_class_name.mustache "py3/clients/stream_response_class_name.mustache", // py3/clients_wrapper.cpp.mustache "py3/clients_wrapper.cpp.mustache", // py3/clients_wrapper.h.mustache "py3/clients_wrapper.h.mustache", // py3/clients_wrapper.pxd.mustache "py3/clients_wrapper.pxd.mustache", // py3/common/annotation.mustache "py3/common/annotation.mustache", // py3/common/auto_generated_c.mustache "py3/common/auto_generated_c.mustache", // py3/common/auto_generated_py.mustache "py3/common/auto_generated_py.mustache", // py3/common/auto_migrate_import_prefix.mustache "py3/common/auto_migrate_import_prefix.mustache", // py3/common/auto_migrate_prefix.mustache "py3/common/auto_migrate_prefix.mustache", // py3/common/python_types_module_path.mustache "py3/common/python_types_module_path.mustache", // py3/converter.pxd.mustache "py3/converter.pxd.mustache", // py3/converter.pyx.mustache "py3/converter.pyx.mustache", // py3/metadata.cpp.mustache "py3/metadata.cpp.mustache", // py3/metadata.h.mustache "py3/metadata.h.mustache", // py3/metadata.pxd.mustache "py3/metadata.pxd.mustache", // py3/metadata.py.mustache "py3/metadata.py.mustache", // py3/metadata.pyi.mustache "py3/metadata.pyi.mustache", // py3/metadata.pyx.mustache "py3/metadata.pyx.mustache", // py3/py3_clients.pxd.mustache "py3/py3_clients.pxd.mustache", // py3/py3_clients.pyi.mustache "py3/py3_clients.pyi.mustache", // py3/py3_clients.pyx.mustache "py3/py3_clients.pyx.mustache", // py3/py3_services.pxd.mustache "py3/py3_services.pxd.mustache", // py3/py3_services.pyi.mustache "py3/py3_services.pyi.mustache", // py3/py3_services.pyx.mustache "py3/py3_services.pyx.mustache", // py3/py3_types.pxd.mustache "py3/py3_types.pxd.mustache", // py3/py3_types.pyi.mustache "py3/py3_types.pyi.mustache", // py3/py3_types.pyx.mustache "py3/py3_types.pyx.mustache", // py3/services.pxd.mustache "py3/services.pxd.mustache", // py3/services.py.mustache "py3/services.py.mustache", // py3/services.pyi.mustache "py3/services.pyi.mustache", // py3/services.pyx.mustache "py3/services.pyx.mustache", // py3/services/callback.mustache "py3/services/callback.mustache", // py3/services/cpp_field_capture.mustache "py3/services/cpp_field_capture.mustache", // py3/services/cpp_handler_callback_type.mustache "py3/services/cpp_handler_callback_type.mustache", // py3/services/cpp_pass_field.mustache "py3/services/cpp_pass_field.mustache", // py3/services/cpp_return_type.mustache "py3/services/cpp_return_type.mustache", // py3/services/cython_cpp_to_python.mustache "py3/services/cython_cpp_to_python.mustache", // py3/services/cython_field_type.mustache "py3/services/cython_field_type.mustache", // py3/services/cython_return_type_cpp_type.mustache "py3/services/cython_return_type_cpp_type.mustache", // py3/services/cython_return_value.mustache "py3/services/cython_return_value.mustache", // py3/services/promise.mustache "py3/services/promise.mustache", // py3/services/promise_name.mustache "py3/services/promise_name.mustache", // py3/services/return_type_pep484_type.mustache "py3/services/return_type_pep484_type.mustache", // py3/services/stream_response_class_name.mustache "py3/services/stream_response_class_name.mustache", // py3/services_reflection.pxd.mustache "py3/services_reflection.pxd.mustache", // py3/services_reflection.pyx.mustache "py3/services_reflection.pyx.mustache", // py3/services_wrapper.cpp.mustache "py3/services_wrapper.cpp.mustache", // py3/services_wrapper.h.mustache "py3/services_wrapper.h.mustache", // py3/services_wrapper.pxd.mustache "py3/services_wrapper.pxd.mustache", // py3/stream/cython_cpp_value_to_python_value.mustache "py3/stream/cython_cpp_value_to_python_value.mustache", // py3/stream/response_class_name_suffix.mustache "py3/stream/response_class_name_suffix.mustache", // py3/stream/stream_promises.mustache "py3/stream/stream_promises.mustache", // py3/types.h.mustache "py3/types.h.mustache", // py3/types.pxd.mustache "py3/types.pxd.mustache", // py3/types.py.mustache "py3/types.py.mustache", // py3/types.pyi.mustache "py3/types.pyi.mustache", // py3/types.pyx.mustache "py3/types.pyx.mustache", // py3/types/cimport_extern.mustache "py3/types/cimport_extern.mustache", // py3/types/compatible_pep484_containers.mustache "py3/types/compatible_pep484_containers.mustache", // py3/types/compatible_pep484_type.mustache "py3/types/compatible_pep484_type.mustache", // py3/types/constant_extern.mustache "py3/types/constant_extern.mustache", // py3/types/constant_value.mustache "py3/types/constant_value.mustache", // py3/types/container_cython_cpp_to_python_item.mustache "py3/types/container_cython_cpp_to_python_item.mustache", // py3/types/container_cython_cpp_to_python_key.mustache "py3/types/container_cython_cpp_to_python_key.mustache", // py3/types/cpp_arg_type.mustache "py3/types/cpp_arg_type.mustache", // py3/types/cpp_stack_arg_type.mustache "py3/types/cpp_stack_arg_type.mustache", // py3/types/cpp_value_type.mustache "py3/types/cpp_value_type.mustache", // py3/types/current_module_types.mustache "py3/types/current_module_types.mustache", // py3/types/custom_template.mustache "py3/types/custom_template.mustache", // py3/types/custom_type.mustache "py3/types/custom_type.mustache", // py3/types/cython_cast_or_create_python_type.mustache "py3/types/cython_cast_or_create_python_type.mustache", // py3/types/cython_cpp_basic_type.mustache "py3/types/cython_cpp_basic_type.mustache", // py3/types/cython_cpp_return_type_ident.mustache "py3/types/cython_cpp_return_type_ident.mustache", // py3/types/cython_cpp_struct_field_type.mustache "py3/types/cython_cpp_struct_field_type.mustache", // py3/types/cython_cpp_type.mustache "py3/types/cython_cpp_type.mustache", // py3/types/cython_cpp_type_ident.mustache "py3/types/cython_cpp_type_ident.mustache", // py3/types/cython_cpp_value_to_python.mustache "py3/types/cython_cpp_value_to_python.mustache", // py3/types/cython_field_ref.mustache "py3/types/cython_field_ref.mustache", // py3/types/cython_field_value_for_assignment.mustache "py3/types/cython_field_value_for_assignment.mustache", // py3/types/cython_field_value_ref.mustache "py3/types/cython_field_value_ref.mustache", // py3/types/cython_python_to_cpp_item.mustache "py3/types/cython_python_to_cpp_item.mustache", // py3/types/cython_python_to_cpp_key.mustache "py3/types/cython_python_to_cpp_key.mustache", // py3/types/cython_python_type.mustache "py3/types/cython_python_type.mustache", // py3/types/cython_struct_getter.mustache "py3/types/cython_struct_getter.mustache", // py3/types/cython_union_assign_field.mustache "py3/types/cython_union_assign_field.mustache", // py3/types/cython_union_getter.mustache "py3/types/cython_union_getter.mustache", // py3/types/enum.mustache "py3/types/enum.mustache", // py3/types/enum_defs.mustache "py3/types/enum_defs.mustache", // py3/types/enum_extern.mustache "py3/types/enum_extern.mustache", // py3/types/field_cppname.mustache "py3/types/field_cppname.mustache", // py3/types/pep484_containers.mustache "py3/types/pep484_containers.mustache", // py3/types/pep484_type.mustache "py3/types/pep484_type.mustache", // py3/types/python_is_instance_type.mustache "py3/types/python_is_instance_type.mustache", // py3/types/python_struct_class.mustache "py3/types/python_struct_class.mustache", // py3/types/python_type.mustache "py3/types/python_type.mustache", // py3/types/struct_extern.mustache "py3/types/struct_extern.mustache", // py3/types/thrift_number_type.mustache "py3/types/thrift_number_type.mustache", // py3/types/type_default_value.mustache "py3/types/type_default_value.mustache", // py3/types/union_type_enum.mustache "py3/types/union_type_enum.mustache", // py3/types_fields.pxd.mustache "py3/types_fields.pxd.mustache", // py3/types_fields.pyx.mustache "py3/types_fields.pyx.mustache", // py3/types_reflection.py.mustache "py3/types_reflection.py.mustache", // pyi/common/AutoGeneratedPy.mustache "pyi/common/AutoGeneratedPy.mustache", // pyi/common/Constant.mustache "pyi/common/Constant.mustache", // pyi/common/FieldType.mustache "pyi/common/FieldType.mustache", // pyi/common/ModulePath.mustache "pyi/common/ModulePath.mustache", // pyi/common/OptionalFieldType.mustache "pyi/common/OptionalFieldType.mustache", // pyi/constants.pyi.mustache "pyi/constants.pyi.mustache", // pyi/service.pyi.mustache "pyi/service.pyi.mustache", // pyi/ttypes.pyi.mustache "pyi/ttypes.pyi.mustache", // python/clients/client_body.mustache "python/clients/client_body.mustache", // python/clients/client_return_type.mustache "python/clients/client_return_type.mustache", // python/clients/stream_response_class_name.mustache "python/clients/stream_response_class_name.mustache", // python/common/annotation.mustache "python/common/annotation.mustache", // python/common/auto_generated_py.mustache "python/common/auto_generated_py.mustache", // python/fields/adapted_type.mustache "python/fields/adapted_type.mustache", // python/fields/adapter_info.mustache "python/fields/adapter_info.mustache", // python/fields/compatible_adapted_type.mustache "python/fields/compatible_adapted_type.mustache", // python/fields/is_primitive.mustache "python/fields/is_primitive.mustache", // python/metadata/const_struct.mustache "python/metadata/const_struct.mustache", // python/metadata/const_value.mustache "python/metadata/const_value.mustache", // python/metadata/recursive_call.mustache "python/metadata/recursive_call.mustache", // python/metadata/return_type.mustache "python/metadata/return_type.mustache", // python/metadata/service_metadata.mustache "python/metadata/service_metadata.mustache", // python/metadata/thrift_type.mustache "python/metadata/thrift_type.mustache", // python/services/client_module_path.mustache "python/services/client_module_path.mustache", // python/services/function_kind.mustache "python/services/function_kind.mustache", // python/services/get_handler_result.mustache "python/services/get_handler_result.mustache", // python/services/service_func_return_type.mustache "python/services/service_func_return_type.mustache", // python/services/service_handler_return_type.mustache "python/services/service_handler_return_type.mustache", // python/structs/unadapted_name.mustache "python/structs/unadapted_name.mustache", // python/thrift_clients.py.mustache "python/thrift_clients.py.mustache", // python/thrift_metadata.py.mustache "python/thrift_metadata.py.mustache", // python/thrift_mutable_types.py.mustache "python/thrift_mutable_types.py.mustache", // python/thrift_mutable_types.pyi.mustache "python/thrift_mutable_types.pyi.mustache", // python/thrift_services.py.mustache "python/thrift_services.py.mustache", // python/thrift_types.py.mustache "python/thrift_types.py.mustache", // python/thrift_types.pyi.mustache "python/thrift_types.pyi.mustache", // python/types/compatible_pep484_type.mustache "python/types/compatible_pep484_type.mustache", // python/types/compatible_unadapted_pep484_type.mustache "python/types/compatible_unadapted_pep484_type.mustache", // python/types/constant_value.mustache "python/types/constant_value.mustache", // python/types/field_value_pep484_union_type.mustache "python/types/field_value_pep484_union_type.mustache", // python/types/function_args_type.mustache "python/types/function_args_type.mustache", // python/types/function_return_type.mustache "python/types/function_return_type.mustache", // python/types/function_second_return_type.mustache "python/types/function_second_return_type.mustache", // python/types/pep484_return_type.mustache "python/types/pep484_return_type.mustache", // python/types/pep484_type.mustache "python/types/pep484_type.mustache", // python/types/python_type.mustache "python/types/python_type.mustache", // python/types/service_arg_type_list.mustache "python/types/service_arg_type_list.mustache", // python/types/service_arg_types.mustache "python/types/service_arg_types.mustache", // python/types/service_arg_types_pyi.mustache "python/types/service_arg_types_pyi.mustache", // python/types/typedef_const_pep484_type.mustache "python/types/typedef_const_pep484_type.mustache", // python/types/typeinfo.mustache "python/types/typeinfo.mustache", // python/types/unadapted_pep484_type.mustache "python/types/unadapted_pep484_type.mustache", // python_capi/common/auto_generated_cpp.mustache "python_capi/common/auto_generated_cpp.mustache", // python_capi/common/auto_generated_cython.mustache "python_capi/common/auto_generated_cython.mustache", // python_capi/common/tuple_position.mustache "python_capi/common/tuple_position.mustache", // python_capi/thrift_types_capi.cpp.mustache "python_capi/thrift_types_capi.cpp.mustache", // python_capi/thrift_types_capi.h.mustache "python_capi/thrift_types_capi.h.mustache", // python_capi/thrift_types_capi.pxd.mustache "python_capi/thrift_types_capi.pxd.mustache", // python_capi/thrift_types_capi.pyx.mustache "python_capi/thrift_types_capi.pyx.mustache", // rust/client.rs.mustache "rust/client.rs.mustache", // rust/consts.rs.mustache "rust/consts.rs.mustache", // rust/errors.rs.mustache "rust/errors.rs.mustache", // rust/lib/adapter/const_test.mustache "rust/lib/adapter/const_test.mustache", // rust/lib/adapter/default_test.mustache "rust/lib/adapter/default_test.mustache", // rust/lib/adapter/name.mustache "rust/lib/adapter/name.mustache", // rust/lib/adapter/qualified.mustache "rust/lib/adapter/qualified.mustache", // rust/lib/annfieldread.mustache "rust/lib/annfieldread.mustache", // rust/lib/annfieldtype.mustache "rust/lib/annfieldtype.mustache", // rust/lib/annfieldwrite.mustache "rust/lib/annfieldwrite.mustache", // rust/lib/arg.mustache "rust/lib/arg.mustache", // rust/lib/arg_inner.mustache "rust/lib/arg_inner.mustache", // rust/lib/arg_life.mustache "rust/lib/arg_life.mustache", // rust/lib/block.mustache "rust/lib/block.mustache", // rust/lib/client.mustache "rust/lib/client.mustache", // rust/lib/client_errors.mustache "rust/lib/client_errors.mustache", // rust/lib/client_return_type.mustache "rust/lib/client_return_type.mustache", // rust/lib/const.mustache "rust/lib/const.mustache", // rust/lib/enum.mustache "rust/lib/enum.mustache", // rust/lib/errors.mustache "rust/lib/errors.mustache", // rust/lib/fieldtype.mustache "rust/lib/fieldtype.mustache", // rust/lib/fieldvalue.mustache "rust/lib/fieldvalue.mustache", // rust/lib/function_stream_elem_type.mustache "rust/lib/function_stream_elem_type.mustache", // rust/lib/function_stream_first_response_type.mustache "rust/lib/function_stream_first_response_type.mustache", // rust/lib/metadata/struct.mustache "rust/lib/metadata/struct.mustache", // rust/lib/method_names.mustache "rust/lib/method_names.mustache", // rust/lib/mod.adapted_types.mustache "rust/lib/mod.adapted_types.mustache", // rust/lib/mod.adapters.mustache "rust/lib/mod.adapters.mustache", // rust/lib/mod.impl.mustache "rust/lib/mod.impl.mustache", // rust/lib/mod.unadapted.mustache "rust/lib/mod.unadapted.mustache", // rust/lib/rawtype.mustache "rust/lib/rawtype.mustache", // rust/lib/read.mustache "rust/lib/read.mustache", // rust/lib/return_type.mustache "rust/lib/return_type.mustache", // rust/lib/server.mustache "rust/lib/server.mustache", // rust/lib/server_errors.mustache "rust/lib/server_errors.mustache", // rust/lib/server_ok_type.mustache "rust/lib/server_ok_type.mustache", // rust/lib/server_return_type.mustache "rust/lib/server_return_type.mustache", // rust/lib/service.mustache "rust/lib/service.mustache", // rust/lib/struct.mustache "rust/lib/struct.mustache", // rust/lib/structimpl.mustache "rust/lib/structimpl.mustache", // rust/lib/structvalue_epilogue.mustache "rust/lib/structvalue_epilogue.mustache", // rust/lib/super.mustache "rust/lib/super.mustache", // rust/lib/ttype.mustache "rust/lib/ttype.mustache", // rust/lib/type.mustache "rust/lib/type.mustache", // rust/lib/typedef.mustache "rust/lib/typedef.mustache", // rust/lib/typedefimpl.mustache "rust/lib/typedefimpl.mustache", // rust/lib/unionimpl.mustache "rust/lib/unionimpl.mustache", // rust/lib/value.mustache "rust/lib/value.mustache", // rust/lib/write.mustache "rust/lib/write.mustache", // rust/mock.rs.mustache "rust/mock.rs.mustache", // rust/server.rs.mustache "rust/server.rs.mustache", // rust/services.rs.mustache "rust/services.rs.mustache", // rust/types.rs.mustache "rust/types.rs.mustache", // starlark/consts.mustache "starlark/consts.mustache", // starlark/consts/value.mustache "starlark/consts/value.mustache", // starlark/definitions.star.mustache "starlark/definitions.star.mustache", // starlark/enums.mustache "starlark/enums.mustache", }; std::size_t const templates_content_sizes[] = { // cpp2/Autogen.mustache 832, // cpp2/ServiceAsyncClient.cpp.mustache 773, // cpp2/ServiceAsyncClient.h.mustache 1862, // cpp2/common/colon_newline.mustache 634, // cpp2/common/comma_newline.mustache 631, // cpp2/common/const_type_recursive.mustache 1029, // cpp2/common/const_value.mustache 1290, // cpp2/common/field_suffix.mustache 815, // cpp2/common/field_value.mustache 741, // cpp2/common/frozen2_union_field_suffix.mustache 634, // cpp2/common/fun_docblock.mustache 931, // cpp2/common/function_name.mustache 693, // cpp2/common/iterate_const_values.mustache 1877, // cpp2/common/iterate_const_values_adapted.mustache 801, // cpp2/common/iterate_const_values_non_referenceable.mustache 2623, // cpp2/common/namespace_cpp2.mustache 743, // cpp2/common/namespace_cpp2_begin.mustache 843, // cpp2/common/namespace_cpp2_end.mustache 852, // cpp2/common/service_namespace_cpp2.mustache 703, // cpp2/common/service_namespace_cpp2_begin.mustache 695, // cpp2/common/service_namespace_cpp2_end.mustache 716, // cpp2/common/type_namespace_cpp2.mustache 700, // cpp2/fatal/fatal_using_string_declaration.mustache 736, // cpp2/field/default.mustache 1869, // cpp2/field/intrinsic_default.mustache 1052, // cpp2/field/member.mustache 720, // cpp2/field/tag.mustache 884, // cpp2/metadata/const_struct.mustache 755, // cpp2/metadata/const_value.mustache 1789, // cpp2/metadata/field_gen.mustache 950, // cpp2/metadata/func_field_gen.mustache 1305, // cpp2/metadata/func_field_name.mustache 676, // cpp2/metadata/return_type_gen.mustache 1436, // cpp2/metadata/type_gen.mustache 2846, // cpp2/metadata/unstructured_field_gen.mustache 800, // cpp2/module_clients.cpp.mustache 826, // cpp2/module_clients.h.mustache 1686, // cpp2/module_clients_out_of_line.h.mustache 732, // cpp2/module_constants.cpp.mustache 3004, // cpp2/module_constants.h.mustache 1602, // cpp2/module_data.cpp.mustache 3073, // cpp2/module_data.h.mustache 2658, // cpp2/module_fatal.h.mustache 4246, // cpp2/module_fatal_all.h.mustache 1034, // cpp2/module_fatal_constant.h.mustache 776, // cpp2/module_fatal_enum.h.mustache 4488, // cpp2/module_fatal_service.h.mustache 769, // cpp2/module_fatal_struct.h.mustache 6206, // cpp2/module_fatal_types.h.mustache 1030, // cpp2/module_fatal_union.h.mustache 7242, // cpp2/module_for_each_field.h.mustache 1219, // cpp2/module_handlers-inl.h.mustache 836, // cpp2/module_handlers.cpp.mustache 1072, // cpp2/module_handlers.h.mustache 1614, // cpp2/module_handlers_out_of_line.h.mustache 721, // cpp2/module_layouts.cpp.mustache 2900, // cpp2/module_layouts.h.mustache 2715, // cpp2/module_layouts_cpp/frozen_freeze_union.mustache 1112, // cpp2/module_layouts_cpp/frozen_layout_union.mustache 1199, // cpp2/module_layouts_cpp/frozen_thaw_union.mustache 2108, // cpp2/module_layouts_h/frozen_view_union.mustache 1756, // cpp2/module_metadata.cpp.mustache 9807, // cpp2/module_metadata.h.mustache 3692, // cpp2/module_sinit.cpp.mustache 1261, // cpp2/module_types.cpp.mustache 12521, // cpp2/module_types.h.mustache 13782, // cpp2/module_types.tcc.mustache 3085, // cpp2/module_types_cpp/assign_overload.mustache 1210, // cpp2/module_types_cpp/clear_fields.mustache 5396, // cpp2/module_types_cpp/clear_terse_fields.mustache 2185, // cpp2/module_types_cpp/copy_ctor.mustache 2873, // cpp2/module_types_cpp/declare_enums.mustache 1766, // cpp2/module_types_cpp/declare_members.mustache 3982, // cpp2/module_types_cpp/declare_union_types.mustache 1385, // cpp2/module_types_cpp/eq_overload.mustache 796, // cpp2/module_types_cpp/field_value_ref.mustache 1104, // cpp2/module_types_cpp/fragile_ctor.mustache 1569, // cpp2/module_types_cpp/frozen.mustache 2535, // cpp2/module_types_cpp/getters_setters.mustache 1599, // cpp2/module_types_cpp/lazy_deserialization.mustache 2704, // cpp2/module_types_cpp/move_ctor.mustache 2561, // cpp2/module_types_cpp/struct_operator_less.mustache 795, // cpp2/module_types_cpp/swap.mustache 1733, // cpp2/module_types_cpp/tcc_struct_traits.mustache 1222, // cpp2/module_types_cpp/union_copy_ctor.mustache 2692, // cpp2/module_types_cpp/union_declare_members.mustache 1363, // cpp2/module_types_cpp/union_eq_overload.mustache 779, // cpp2/module_types_cpp/union_operator_less.mustache 794, // cpp2/module_types_cpp/union_setters.mustache 1718, // cpp2/module_types_cpp/union_swap.mustache 791, // cpp2/module_types_custom_protocol.h.mustache 1116, // cpp2/module_types_fwd.h.mustache 1096, // cpp2/module_types_h/alloc_extended_ctors.mustache 4374, // cpp2/module_types_h/base_ctor.mustache 1486, // cpp2/module_types_h/base_ctor_no_alloc_init_list.mustache 1596, // cpp2/module_types_h/base_ctor_with_alloc_init_list.mustache 1538, // cpp2/module_types_h/declare_enums.mustache 2315, // cpp2/module_types_h/declare_members.mustache 1000, // cpp2/module_types_h/declare_union_types.mustache 1432, // cpp2/module_types_h/enum_bitwise_ops.mustache 1813, // cpp2/module_types_h/field_interceptor.mustache 888, // cpp2/module_types_h/field_ref.mustache 6964, // cpp2/module_types_h/field_ref_args.mustache 830, // cpp2/module_types_h/forward_declare.mustache 1043, // cpp2/module_types_h/fragile_ctor_param_list.mustache 697, // cpp2/module_types_h/frozen.mustache 1330, // cpp2/module_types_h/getters_setters.mustache 3925, // cpp2/module_types_h/hash_and_equal_to.mustache 1189, // cpp2/module_types_h/lazy_deserialization.mustache 1954, // cpp2/module_types_h/reflection.mustache 1868, // cpp2/module_types_h/smart_ptr_constructor.mustache 1175, // cpp2/module_types_h/union_assign_overload.mustache 1486, // cpp2/module_types_h/union_copy_ctor.mustache 1446, // cpp2/module_types_h/union_enum.mustache 813, // cpp2/module_types_h/union_field_ref.mustache 2043, // cpp2/module_types_h/union_getters.mustache 1268, // cpp2/module_types_h/union_moves.mustache 869, // cpp2/module_types_h/union_mutables.mustache 862, // cpp2/module_types_h/union_setters.mustache 6659, // cpp2/module_types_h/union_storage.mustache 850, // cpp2/module_types_tcc/container_struct_type.mustache 1167, // cpp2/module_types_tcc/deprecated_terse_has_value.mustache 2028, // cpp2/module_types_tcc/deserialize_field.mustache 3333, // cpp2/module_types_tcc/deserialize_struct.mustache 6448, // cpp2/module_types_tcc/deserialize_union.mustache 2335, // cpp2/module_types_tcc/field_ref.mustache 1081, // cpp2/module_types_tcc/if_should_write.mustache 1486, // cpp2/module_types_tcc/if_should_write_end.mustache 708, // cpp2/module_types_tcc/member_or_ptr.mustache 828, // cpp2/module_types_tcc/optional_has_value.mustache 1255, // cpp2/module_types_tcc/pm.mustache 769, // cpp2/module_types_tcc/pm_value.mustache 957, // cpp2/module_types_tcc/serialize_field.mustache 5244, // cpp2/module_types_tcc/serialize_field_size.mustache 4800, // cpp2/module_types_tcc/serialize_field_size_zc.mustache 4773, // cpp2/module_types_tcc/serialize_struct.mustache 2477, // cpp2/module_types_tcc/serialize_union.mustache 2306, // cpp2/module_types_tcc/struct_field_type.mustache 1135, // cpp2/module_types_tcc/struct_type.mustache 1222, // cpp2/module_types_tcc/tcc_struct_traits.mustache 991, // cpp2/module_types_tcc/terse_has_no_value.mustache 1088, // cpp2/module_types_tcc/terse_has_value.mustache 655, // cpp2/module_types_tcc/union_setters.mustache 609, // cpp2/module_types_tcc/variable_name.mustache 722, // cpp2/module_visit_by_thrift_field_metadata.h.mustache 1390, // cpp2/module_visit_union.h.mustache 1636, // cpp2/module_visitation.h.mustache 987, // cpp2/service.cpp.mustache 1027, // cpp2/service.h.mustache 1889, // cpp2/service.tcc.mustache 771, // cpp2/service_async_client_cpp/coroutine_functions.mustache 3351, // cpp2/service_async_client_cpp/function_implementation.mustache 5215, // cpp2/service_async_client_cpp/future_functions.mustache 6481, // cpp2/service_async_client_cpp/received.mustache 1606, // cpp2/service_async_client_cpp/received_instance.mustache 1888, // cpp2/service_async_client_cpp/received_wrapped.mustache 3466, // cpp2/service_async_client_cpp/sync_functions.mustache 7429, // cpp2/service_async_client_cpp/templated_received.mustache 3255, // cpp2/service_common/client_class_name.mustache 846, // cpp2/service_common/function_param_list_client.mustache 764, // cpp2/service_common/function_param_list_interceptor.mustache 760, // cpp2/service_common/function_param_list_server.mustache 764, // cpp2/service_common/function_param_list_server_commented_out.mustache 766, // cpp2/service_common/param_list.mustache 741, // cpp2/service_common/param_list_move.mustache 1126, // cpp2/service_common/service_class_name.mustache 894, // cpp2/service_common/sync_function_return_param_server.mustache 758, // cpp2/service_common/sync_function_return_type_server.mustache 830, // cpp2/service_common/typedefs.mustache 788, // cpp2/service_cpp/async_client_cpp.mustache 3000, // cpp2/service_cpp/handlers_cpp.mustache 3503, // cpp2/service_cpp/interaction_constructor_map.mustache 1364, // cpp2/service_cpp/processmap.mustache 4652, // cpp2/service_cpp/service_inl.mustache 868, // cpp2/service_cpp/service_interface_impl.mustache 11800, // cpp2/service_cpp/service_null_impl.mustache 1701, // cpp2/service_h/async_client.mustache 1871, // cpp2/service_h/async_client_functions.mustache 16664, // cpp2/service_h/async_processor.mustache 3518, // cpp2/service_h/async_processor_per_function.mustache 2779, // cpp2/service_h/handlers_h.mustache 787, // cpp2/service_h/interaction_async_client.mustache 995, // cpp2/service_h/interaction_service_interface.mustache 1276, // cpp2/service_h/service_info_holder.mustache 863, // cpp2/service_h/service_interface.mustache 2268, // cpp2/service_h/service_interface_functions.mustache 3088, // cpp2/service_h/service_null.mustache 1370, // cpp2/service_processmap_protocol.cpp.mustache 810, // cpp2/service_tcc/field_data_params.mustache 842, // cpp2/service_tcc/field_data_return.mustache 806, // cpp2/service_tcc/field_data_throws.mustache 805, // cpp2/service_tcc/get_args_ref.mustache 1127, // cpp2/service_tcc/process_and_return.mustache 17657, // cpp2/service_tcc/typedef_params.mustache 781, // cpp2/service_tcc/typedef_result.mustache 2659, // cpp2/types/adapter_post.mustache 652, // cpp2/types/adapter_pre.mustache 684, // cpp2/types/apply_indirection_post.mustache 662, // cpp2/types/apply_indirection_pre.mustache 697, // cpp2/types/callback_type.mustache 983, // cpp2/types/const_value_type.mustache 722, // cpp2/types/function_kind.mustache 1181, // cpp2/types/indirected_string_type.mustache 1129, // cpp2/types/param_type_client.mustache 832, // cpp2/types/param_type_server.mustache 1018, // cpp2/types/return_type_client.mustache 1176, // cpp2/types/return_type_client_lift_unit.mustache 733, // cpp2/types/return_type_client_no_handle.mustache 2188, // cpp2/types/return_type_server.mustache 1353, // cpp2/types/return_type_server_lift_unit.mustache 733, // cpp2/types_custom_protocol.h.mustache 1307, // go/codec/decode.mustache 1409, // go/codec/decode_base.mustache 1131, // go/codec/decode_enum.mustache 800, // go/codec/decode_list.mustache 1320, // go/codec/decode_map.mustache 1579, // go/codec/decode_set.mustache 1309, // go/codec/decode_struct.mustache 789, // go/codec/decode_typedef.mustache 770, // go/codec/encode.mustache 1410, // go/codec/encode_base.mustache 1121, // go/codec/encode_enum.mustache 757, // go/codec/encode_list.mustache 1266, // go/codec/encode_map.mustache 1705, // go/codec/encode_set.mustache 1255, // go/codec/encode_struct.mustache 748, // go/codec/encode_typedef.mustache 774, // go/common/go_zero_value.mustache 1667, // go/common/header.mustache 804, // go/common/natural_default_value.mustache 2426, // go/common/pointerize_func.mustache 1163, // go/common/primitive_decode_func.mustache 1169, // go/common/primitive_encode_func.mustache 1179, // go/common/registry.mustache 1345, // go/common/ttype.mustache 1359, // go/common/type.mustache 2675, // go/common/unused_imports_protection.mustache 776, // go/const.go.mustache 1584, // go/const/struct_value.mustache 1170, // go/const/value.mustache 3959, // go/doc.go.mustache 684, // go/metadata.go.mustache 7251, // go/metadata/thrift_metadata_enum.mustache 924, // go/metadata/thrift_metadata_exception.mustache 1011, // go/metadata/thrift_metadata_field.mustache 954, // go/metadata/thrift_metadata_function.mustache 1471, // go/metadata/thrift_metadata_service.mustache 1215, // go/metadata/thrift_metadata_struct.mustache 1104, // go/metadata/thrift_primitive_type.mustache 1227, // go/metadata/thrift_type_instance.mustache 2394, // go/metadata/thrift_type_setter.mustache 1750, // go/svc/client.mustache 4723, // go/svc/func_signature.mustache 1082, // go/svc/func_signature_no_ctx.mustache 1032, // go/svc/func_signature_with_ctx.mustache 1089, // go/svc/interface.mustache 2330, // go/svc/proc_func_name.mustache 699, // go/svc/processor.mustache 6537, // go/svcs.go.mustache 1669, // go/types.go.mustache 1435, // go/types/enum.mustache 1829, // go/types/field.mustache 1145, // go/types/field_default_value.mustache 1022, // go/types/field_method_default_get.mustache 1059, // go/types/field_method_get.mustache 1474, // go/types/field_method_is_set.mustache 814, // go/types/field_method_read.mustache 993, // go/types/field_method_set.mustache 1522, // go/types/field_method_to_string.mustache 1151, // go/types/field_method_write.mustache 1561, // go/types/field_type.mustache 775, // go/types/struct.mustache 1286, // go/types/struct_builder.mustache 1986, // go/types/struct_definition.mustache 1468, // go/types/struct_method_error.mustache 756, // go/types/struct_method_exception.mustache 1018, // go/types/struct_method_new.mustache 1850, // go/types/struct_method_read.mustache 1842, // go/types/struct_method_string.mustache 1192, // go/types/struct_method_write.mustache 1561, // go/types/struct_methods.mustache 1952, // go/types/typedef.mustache 1029, // go/types/typedef_enum.mustache 1377, // go/types/typedef_enum_go_qualified_name.mustache 1235, // go/types/typedef_method_new.mustache 853, // go/types/typedef_method_read.mustache 1477, // go/types/typedef_method_write.mustache 1349, // html/index.html.mustache 794, // java/AdaptedBoxedType.mustache 1145, // java/AdaptedType.mustache 892, // java/AsyncReactiveWrapper.mustache 5424, // java/AutoGenerated.mustache 151, // java/BlockingReactiveWrapper.mustache 9032, // java/BoxedType.mustache 2882, // java/ConstantStruct.mustache 1051, // java/ConstantUnion.mustache 906, // java/Constants.mustache 1573, // java/Default.mustache 288, // java/DefaultValue.mustache 5066, // java/DefaultValueContainer.mustache 6599, // java/Enum.mustache 897, // java/Exception.mustache 3075, // java/ExceptionMessage.mustache 699, // java/FieldType.mustache 1237, // java/FieldTypeNoWrapper.mustache 1095, // java/FromThriftEnd.mustache 757, // java/FromThriftStart.mustache 859, // java/GetterName.mustache 729, // java/KeyValue.mustache 783, // java/Object.mustache 775, // java/ReactiveAsyncWrapper.mustache 5272, // java/ReactiveBlockingWrapper.mustache 4733, // java/ReactiveClient.mustache 42777, // java/ReadType.mustache 5215, // java/ReadTypeBinary.mustache 1064, // java/ReadTypeContainer.mustache 5638, // java/ReadTypeContainerNestedKey.mustache 6250, // java/ReadTypeContainerNestedValue.mustache 7112, // java/Requiredness.mustache 869, // java/RpcServerHandler.mustache 25831, // java/Service.mustache 20858, // java/SetterName.mustache 637, // java/SinkResponseGeneric.mustache 1240, // java/SinkReturnType.mustache 1249, // java/SinkWrapperReturnType.mustache 1283, // java/StreamResponseGeneric.mustache 1223, // java/StreamReturnType.mustache 1175, // java/Struct.mustache 4059, // java/TType.mustache 1380, // java/ThriftBoxedType.mustache 3196, // java/ThriftFieldAnnotation.mustache 864, // java/ThriftFieldType.mustache 893, // java/ThriftType.mustache 1392, // java/ToThriftEnd.mustache 823, // java/ToThriftStart.mustache 957, // java/Type.mustache 1387, // java/TypeCap.mustache 1382, // java/TypeList.mustache 1421, // java/TypeReader.mustache 2034, // java/Union.mustache 6462, // java/Utf8Validation.mustache 804, // java/WriteNestedType.mustache 913, // java/WriteRequestType.mustache 8022, // java/WriteResponseType.mustache 9816, // java/WriteSinkPayloadType.mustache 8114, // java/WriteType.mustache 10000, // java/WriteTypeAdapter.mustache 1042, // java/common/ObjectCustomAnnotation.mustache 693, // java/deprecated/ServiceAsyncClient.mustache 5053, // java/deprecated/ServiceClient.mustache 5901, // java/enum/ClosedEnum.mustache 3513, // java/enum/OpenEnum.mustache 3576, // java/struct/AdapterDefinition.mustache 1728, // java/struct/CreateStruct.mustache 1109, // java/struct/FieldGetter.mustache 888, // java/struct/FieldNullability.mustache 801, // java/struct/FieldSetter.mustache 835, // java/struct/FieldValue.mustache 2335, // java/struct/FieldValueNoWrapper.mustache 2225, // java/struct/IntrinsicDefault.mustache 2299, // java/struct/NestedAdapterDefinition.mustache 1608, // java/struct/StructBuilder.mustache 2954, // java/struct/StructEquals.mustache 1963, // java/struct/StructHashCode.mustache 851, // java/struct/StructRead.mustache 2617, // java/struct/StructToString.mustache 983, // java/struct/StructWrite.mustache 4422, // java/struct/ThriftConstructor.mustache 1600, // java/union/UnionBuilder.mustache 2011, // java/union/UnionRead.mustache 2217, // java/union/UnionSetter.mustache 870, // java/union/UnionWrite.mustache 2754, // json/const_value.mustache 1029, // json/enums.mustache 661, // json/return_type.mustache 1132, // json/services.mustache 3244, // json/structs.mustache 1874, // json/structured_annotations.mustache 356, // json/thrift_ast.mustache 2054, // json/type.mustache 1204, // py3/builders.pxd.mustache 2317, // py3/builders.pyi.mustache 2261, // py3/builders.pyx.mustache 1155, // py3/clients.pxd.mustache 237, // py3/clients.py.mustache 1874, // py3/clients.pyi.mustache 23, // py3/clients.pyx.mustache 23, // py3/clients/callback.mustache 1777, // py3/clients/callback_body.mustache 1013, // py3/clients/clients_wrapper.cpp_func_body.mustache 982, // py3/clients/cpp_return_type.mustache 1243, // py3/clients/cython_cpp_value_to_return_value.mustache 2223, // py3/clients/cython_python_to_cpp_arg.mustache 2186, // py3/clients/cython_return_type_cpp_type.mustache 1228, // py3/clients/stream_response_class_name.mustache 1011, // py3/clients_wrapper.cpp.mustache 3202, // py3/clients_wrapper.h.mustache 3745, // py3/clients_wrapper.pxd.mustache 6250, // py3/common/annotation.mustache 1010, // py3/common/auto_generated_c.mustache 157, // py3/common/auto_generated_py.mustache 149, // py3/common/auto_migrate_import_prefix.mustache 785, // py3/common/auto_migrate_prefix.mustache 720, // py3/common/python_types_module_path.mustache 742, // py3/converter.pxd.mustache 450, // py3/converter.pyx.mustache 1365, // py3/metadata.cpp.mustache 1727, // py3/metadata.h.mustache 1036, // py3/metadata.pxd.mustache 1029, // py3/metadata.py.mustache 1646, // py3/metadata.pyi.mustache 746, // py3/metadata.pyx.mustache 1154, // py3/py3_clients.pxd.mustache 1931, // py3/py3_clients.pyi.mustache 4066, // py3/py3_clients.pyx.mustache 11536, // py3/py3_services.pxd.mustache 2055, // py3/py3_services.pyi.mustache 3084, // py3/py3_services.pyx.mustache 11081, // py3/py3_types.pxd.mustache 6560, // py3/py3_types.pyi.mustache 9554, // py3/py3_types.pyx.mustache 40034, // py3/services.pxd.mustache 239, // py3/services.py.mustache 1876, // py3/services.pyi.mustache 24, // py3/services.pyx.mustache 24, // py3/services/callback.mustache 6395, // py3/services/cpp_field_capture.mustache 2200, // py3/services/cpp_handler_callback_type.mustache 999, // py3/services/cpp_pass_field.mustache 1652, // py3/services/cpp_return_type.mustache 1384, // py3/services/cython_cpp_to_python.mustache 2255, // py3/services/cython_field_type.mustache 1295, // py3/services/cython_return_type_cpp_type.mustache 1370, // py3/services/cython_return_value.mustache 3978, // py3/services/promise.mustache 2030, // py3/services/promise_name.mustache 837, // py3/services/return_type_pep484_type.mustache 1481, // py3/services/stream_response_class_name.mustache 995, // py3/services_reflection.pxd.mustache 1243, // py3/services_reflection.pyx.mustache 3407, // py3/services_wrapper.cpp.mustache 4742, // py3/services_wrapper.h.mustache 3010, // py3/services_wrapper.pxd.mustache 1387, // py3/stream/cython_cpp_value_to_python_value.mustache 1932, // py3/stream/response_class_name_suffix.mustache 863, // py3/stream/stream_promises.mustache 1736, // py3/types.h.mustache 3524, // py3/types.pxd.mustache 749, // py3/types.py.mustache 1870, // py3/types.pyi.mustache 21, // py3/types.pyx.mustache 22, // py3/types/cimport_extern.mustache 1836, // py3/types/compatible_pep484_containers.mustache 1189, // py3/types/compatible_pep484_type.mustache 1817, // py3/types/constant_extern.mustache 1409, // py3/types/constant_value.mustache 2906, // py3/types/container_cython_cpp_to_python_item.mustache 2017, // py3/types/container_cython_cpp_to_python_key.mustache 1667, // py3/types/cpp_arg_type.mustache 1167, // py3/types/cpp_stack_arg_type.mustache 1108, // py3/types/cpp_value_type.mustache 2112, // py3/types/current_module_types.mustache 691, // py3/types/custom_template.mustache 5057, // py3/types/custom_type.mustache 6986, // py3/types/cython_cast_or_create_python_type.mustache 924, // py3/types/cython_cpp_basic_type.mustache 2713, // py3/types/cython_cpp_return_type_ident.mustache 1148, // py3/types/cython_cpp_struct_field_type.mustache 1317, // py3/types/cython_cpp_type.mustache 1307, // py3/types/cython_cpp_type_ident.mustache 2650, // py3/types/cython_cpp_value_to_python.mustache 2221, // py3/types/cython_field_ref.mustache 1470, // py3/types/cython_field_value_for_assignment.mustache 2462, // py3/types/cython_field_value_ref.mustache 1196, // py3/types/cython_python_to_cpp_item.mustache 2122, // py3/types/cython_python_to_cpp_key.mustache 1723, // py3/types/cython_python_type.mustache 2004, // py3/types/cython_struct_getter.mustache 3543, // py3/types/cython_union_assign_field.mustache 5336, // py3/types/cython_union_getter.mustache 5727, // py3/types/enum.mustache 2908, // py3/types/enum_defs.mustache 858, // py3/types/enum_extern.mustache 1284, // py3/types/field_cppname.mustache 836, // py3/types/pep484_containers.mustache 1156, // py3/types/pep484_type.mustache 1673, // py3/types/python_is_instance_type.mustache 1700, // py3/types/python_struct_class.mustache 878, // py3/types/python_type.mustache 1696, // py3/types/struct_extern.mustache 5034, // py3/types/thrift_number_type.mustache 1042, // py3/types/type_default_value.mustache 687, // py3/types/union_type_enum.mustache 1995, // py3/types_fields.pxd.mustache 2943, // py3/types_fields.pyx.mustache 5848, // py3/types_reflection.py.mustache 5399, // pyi/common/AutoGeneratedPy.mustache 149, // pyi/common/Constant.mustache 687, // pyi/common/FieldType.mustache 2112, // pyi/common/ModulePath.mustache 807, // pyi/common/OptionalFieldType.mustache 984, // pyi/constants.pyi.mustache 989, // pyi/service.pyi.mustache 6609, // pyi/ttypes.pyi.mustache 3931, // python/clients/client_body.mustache 9752, // python/clients/client_return_type.mustache 808, // python/clients/stream_response_class_name.mustache 1040, // python/common/annotation.mustache 1010, // python/common/auto_generated_py.mustache 208, // python/fields/adapted_type.mustache 977, // python/fields/adapter_info.mustache 1215, // python/fields/compatible_adapted_type.mustache 988, // python/fields/is_primitive.mustache 545, // python/metadata/const_struct.mustache 991, // python/metadata/const_value.mustache 1617, // python/metadata/recursive_call.mustache 1637, // python/metadata/return_type.mustache 1771, // python/metadata/service_metadata.mustache 4148, // python/metadata/thrift_type.mustache 3914, // python/services/client_module_path.mustache 783, // python/services/function_kind.mustache 1113, // python/services/get_handler_result.mustache 1395, // python/services/service_func_return_type.mustache 1454, // python/services/service_handler_return_type.mustache 943, // python/structs/unadapted_name.mustache 735, // python/thrift_clients.py.mustache 2405, // python/thrift_metadata.py.mustache 7236, // python/thrift_mutable_types.py.mustache 2963, // python/thrift_mutable_types.pyi.mustache 927, // python/thrift_services.py.mustache 6257, // python/thrift_types.py.mustache 8285, // python/thrift_types.pyi.mustache 5653, // python/types/compatible_pep484_type.mustache 1032, // python/types/compatible_unadapted_pep484_type.mustache 2110, // python/types/constant_value.mustache 4303, // python/types/field_value_pep484_union_type.mustache 790, // python/types/function_args_type.mustache 795, // python/types/function_return_type.mustache 854, // python/types/function_second_return_type.mustache 842, // python/types/pep484_return_type.mustache 996, // python/types/pep484_type.mustache 1021, // python/types/python_type.mustache 2032, // python/types/service_arg_type_list.mustache 1044, // python/types/service_arg_types.mustache 3745, // python/types/service_arg_types_pyi.mustache 3753, // python/types/typedef_const_pep484_type.mustache 1275, // python/types/typeinfo.mustache 3062, // python/types/unadapted_pep484_type.mustache 2025, // python_capi/common/auto_generated_cpp.mustache 102, // python_capi/common/auto_generated_cython.mustache 91, // python_capi/common/tuple_position.mustache 334, // python_capi/thrift_types_capi.cpp.mustache 9926, // python_capi/thrift_types_capi.h.mustache 2485, // python_capi/thrift_types_capi.pxd.mustache 1549, // python_capi/thrift_types_capi.pyx.mustache 2319, // rust/client.rs.mustache 2163, // rust/consts.rs.mustache 944, // rust/errors.rs.mustache 855, // rust/lib/adapter/const_test.mustache 1247, // rust/lib/adapter/default_test.mustache 1486, // rust/lib/adapter/name.mustache 2749, // rust/lib/adapter/qualified.mustache 670, // rust/lib/annfieldread.mustache 787, // rust/lib/annfieldtype.mustache 2075, // rust/lib/annfieldwrite.mustache 787, // rust/lib/arg.mustache 670, // rust/lib/arg_inner.mustache 950, // rust/lib/arg_life.mustache 673, // rust/lib/block.mustache 610, // rust/lib/client.mustache 23590, // rust/lib/client_errors.mustache 785, // rust/lib/client_return_type.mustache 1360, // rust/lib/const.mustache 1662, // rust/lib/enum.mustache 4669, // rust/lib/errors.mustache 20596, // rust/lib/fieldtype.mustache 1256, // rust/lib/fieldvalue.mustache 939, // rust/lib/function_stream_elem_type.mustache 764, // rust/lib/function_stream_first_response_type.mustache 784, // rust/lib/metadata/struct.mustache 3640, // rust/lib/method_names.mustache 1391, // rust/lib/mod.adapted_types.mustache 896, // rust/lib/mod.adapters.mustache 1159, // rust/lib/mod.impl.mustache 11985, // rust/lib/mod.unadapted.mustache 814, // rust/lib/rawtype.mustache 3117, // rust/lib/read.mustache 763, // rust/lib/return_type.mustache 1410, // rust/lib/server.mustache 29285, // rust/lib/server_errors.mustache 789, // rust/lib/server_ok_type.mustache 1355, // rust/lib/server_return_type.mustache 1305, // rust/lib/service.mustache 13512, // rust/lib/struct.mustache 4296, // rust/lib/structimpl.mustache 9321, // rust/lib/structvalue_epilogue.mustache 888, // rust/lib/super.mustache 792, // rust/lib/ttype.mustache 1401, // rust/lib/type.mustache 899, // rust/lib/typedef.mustache 2239, // rust/lib/typedefimpl.mustache 2524, // rust/lib/unionimpl.mustache 4928, // rust/lib/value.mustache 7170, // rust/lib/write.mustache 763, // rust/mock.rs.mustache 13847, // rust/server.rs.mustache 1714, // rust/services.rs.mustache 845, // rust/types.rs.mustache 3026, // starlark/consts.mustache 326, // starlark/consts/value.mustache 1686, // starlark/definitions.star.mustache 25, // starlark/enums.mustache 424, }; char const* const templates_content_datas[] = { // cpp2/Autogen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}/** * Autogenerated by Thrift for {{program:autogen_path}}{{service:autogen_path}} * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @{{!}}generated @{{!}}nocommit */ {{! terminate with newline }} )__FBTHRIFT_TAG__", // cpp2/ServiceAsyncClient.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include "{{service:include_prefix}}{{service:name}}AsyncClient.h" #include {{ > service_cpp/async_client_cpp}} )__FBTHRIFT_TAG__", // cpp2/ServiceAsyncClient.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include "{{service:include_prefix}}{{service:program_name}}_types.h" {{#service:extends}} #if __has_include("{{service:include_prefix}}{{service:name}}AsyncClient.h") #include "{{service:include_prefix}}{{service:name}}AsyncClient.h" #else #include "{{service:include_prefix}}{{service:program_name}}_clients.h" #endif {{/service:extends}} {{#service:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{/service:thrift_includes}} {{#service:cpp_includes}} #include {{cpp_include}} {{/service:cpp_includes}} {{#service:sinks?}} #include #include {{/service:sinks?}} {{#service:streams?}} #include {{/service:streams?}} {{#service:interactions?}} #include #include #include {{/service:interactions?}} namespace apache { namespace thrift { class Cpp2RequestContext; namespace detail { namespace ac { struct ClientRequestContext; }} namespace transport { class THeader; } }} {{ > service_h/async_client}} )__FBTHRIFT_TAG__", // cpp2/common/colon_newline.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#first?}} : {{/first?}} )__FBTHRIFT_TAG__", // cpp2/common/comma_newline.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^last?}}, {{/last?}} )__FBTHRIFT_TAG__", // cpp2/common/const_type_recursive.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Base types: }}{{^type:container?}}{{type:cpp_type}}{{/type:container?}}{{! Containers: }}{{#type:list?}}{{#type:list_elem_type}}{{! }}{{ > common/const_type_recursive}}{{! }}{{/type:list_elem_type}}{{/type:list?}}{{! }}{{#type:set?}}{{#type:set_elem_type}}{{! }}{{ > common/const_type_recursive}}{{! }}{{/type:set_elem_type}}{{/type:set?}}{{! Map }}{{#type:map?}}<#type:cpp_type}}::value_type{{/type:map?}} )__FBTHRIFT_TAG__", // cpp2/common/const_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Base Constant Values }}{{#value:bool?}}{{value:bool_value}}{{/value:bool?}}{{! }}{{#value:integer?}}static_cast<{{type:cpp_standard_type}}>({{value:integer_value}}){{/value:integer?}}{{! }}{{#value:double?}}static_cast<{{type:cpp_standard_type}}>({{value:double_value}}){{/value:double?}}{{! }}{{#value:string?}}"{{value:string_value}}"{{/value:string?}}{{! }}{{#value:enum?}}{{! }}{{#value:enum_value?}}{{ > common/type_namespace_cpp2}}{{type:cpp_name}}::{{value:enum_value_cpp_name}}{{/value:enum_value?}}{{! }}{{^value:enum_value?}}static_cast<{{ > common/type_namespace_cpp2}}{{type:cpp_name}}>({{value:integer_value}}){{/value:enum_value?}}{{! }}{{/value:enum?}} )__FBTHRIFT_TAG__", // cpp2/common/field_suffix.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:terse?}}_REQ{{/field:terse?}}{{#field:required?}}_REQ{{/field:required?}}{{#field:cpp_ref?}}_REF{{/field:cpp_ref?}}{{#field:optional?}}{{^field:cpp_ref?}}_OPT{{/field:cpp_ref?}}{{/field:optional?}} )__FBTHRIFT_TAG__", // cpp2/common/field_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:lazy?}}__fbthrift_read_field_{{field:cpp_name}}(){{/field:lazy?}}{{^field:lazy?}}{{field:cpp_storage_name}}{{/field:lazy?}} )__FBTHRIFT_TAG__", // cpp2/common/frozen2_union_field_suffix.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:cpp_ref?}}_REF{{/field:cpp_ref?}} )__FBTHRIFT_TAG__", // cpp2/common/fun_docblock.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{! The glean annotation is used by Glean indexers to map generated functions to thrift definitions. It can be moved within the docblock, as long as it stays on a single line }} /** Glean {"file": "{{service:autogen_path}}", "service": "{{service:name}}", "function": "{{function:name}}"} */ {{! enforce new line }} )__FBTHRIFT_TAG__", // cpp2/common/function_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}} )__FBTHRIFT_TAG__", // cpp2/common/iterate_const_values.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Base Types: }}{{^value:container?}}{{! }}{{^type:struct?}}{{! }}{{#value:string?}}{{! }}apache::thrift::StringTraits<{{ > types/indirected_string_type}}>::fromStringLiteral({{ > common/const_value}}){{! }}{{/value:string?}}{{! }}{{^value:string?}}{{ > common/const_value}}{{/value:string?}}{{! }}{{/type:struct?}}{{! }}{{/value:container?}}{{! Reference other constants: }}{{#type:resolves_to_container_or_struct?}}{{! }}{{#value:enable_referencing?}}{{! }}{{#value:referenceable?}}{{! }}{{#value:owning_const}}{{! }}{{#constant:program}}{{! }}{{#program:namespace_cpp2}}::{{namespace:name}}{{#last?}}::{{/last?}}{{/program:namespace_cpp2}}{{program:name}}_constants::{{constant:name}}(){{! }}{{/constant:program}}{{! }}{{/value:owning_const}}{{! }}{{/value:referenceable?}}{{! }}{{/value:enable_referencing?}}{{! }}{{/type:resolves_to_container_or_struct?}}{{! }}{{^value:enable_referencing?}}{{! }}{{ > common/iterate_const_values_non_referenceable}}{{! }}{{/value:enable_referencing?}}{{! }}{{#value:enable_referencing?}}{{! }}{{^value:referenceable?}}{{! }}{{ > common/iterate_const_values_non_referenceable}}{{! }}{{/value:referenceable?}}{{! }}{{/value:enable_referencing?}} )__FBTHRIFT_TAG__", // cpp2/common/iterate_const_values_adapted.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:cpp_adapter}}{{type:cpp_adapter}}::fromThrift({{type:cpp_standard_type}}({{/type:cpp_adapter}}{{! }}{{ > common/iterate_const_values}}{{! }}{{#type:cpp_adapter}})){{/type:cpp_adapter}} )__FBTHRIFT_TAG__", // cpp2/common/iterate_const_values_non_referenceable.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Containers: List: }}{{^type:struct?}}{{! }}{{#value:list?}}{{#type:list?}}{{#type:list_elem_type}}{{! }}std::initializer_list<{{! }}{{type:cpp_type}}{{! }}>{ {{! }}{{#value:list_elements}}{{! }}{{ > common/iterate_const_values_adapted}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/value:list_elements}}{{! }} }{{! }}{{/type:list_elem_type}}{{/type:list?}}{{/value:list?}}{{! Set: }}{{#value:list?}}{{#type:set?}}{{#type:set_elem_type}}{{! }}std::initializer_list<{{! }}{{type:cpp_type}}{{! }}>{ {{! }}{{#value:list_elements}}{{! }}{{ > common/iterate_const_values_adapted}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/value:list_elements}}{{! }} }{{! }}{{/type:set_elem_type}}{{/type:set?}}{{/value:list?}}{{! Map: }}{{#value:map?}}{{#type:map?}}{{! }}std::initializer_list<{{type:cpp_type}}::value_type>{ {{! }}{{#value:map_elements}}{{! }}{ {{! }}{{#element:key}}{{#type:key_type}}{{! }}{{ > common/iterate_const_values_adapted}}{{! }}{{/type:key_type}}{{/element:key}}{{! }}, {{! }}{{#element:value}}{{#type:value_type}}{{! }}{{ > common/iterate_const_values_adapted}}{{! }}{{/type:value_type}}{{/element:value}}{{! }} }{{! }}{{^last?}}, {{/last?}}{{! }}{{/value:map_elements}}{{! }} }{{! }}{{/type:map?}}{{/value:map?}}{{! }}{{/type:struct?}}{{! Struct: }}{{#type:struct?}}{{! }}::apache::thrift::detail::make_structured_constant<{{type:cpp_standard_type}}>({{! }}{{#value:const_struct}}{{#constant:type}}{{#constant:value}}{{#constant:field}}{{! }}::apache::thrift::detail::wrap_struct_argument<::apache::thrift::ident::{{constant:cpp_name}}{{! }}{{#field:cpp_first_adapter}}, {{field:cpp_first_adapter}}, ::apache::thrift::FieldId{ {{field:key}} }{{/field:cpp_first_adapter}}>({{! }}{{ > common/iterate_const_values}}){{^last?}}, {{/last?}}{{! }}{{/constant:field}}{{/constant:value}}{{/constant:type}}{{/value:const_struct}}){{! }}{{/type:struct?}} )__FBTHRIFT_TAG__", // cpp2/common/namespace_cpp2.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}::{{#program:namespace_cpp2}}{{namespace:name}}{{^last?}}::{{/last?}}{{/program:namespace_cpp2}}{{ > common/service_namespace_cpp2}}:: )__FBTHRIFT_TAG__", // cpp2/common/namespace_cpp2_begin.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}namespace {{#program:namespace_cpp2}}{{! }}{{namespace:name}}{{^last?}}::{{/last?}}{{! }}{{/program:namespace_cpp2}}{{! }}{{#service:namespace_cpp2}}{{! }}{{namespace:name}}{{^last?}}::{{/last?}}{{! }}{{/service:namespace_cpp2}} { )__FBTHRIFT_TAG__", // cpp2/common/namespace_cpp2_end.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}} // namespace {{! }}{{#program:namespace_cpp2}}{{! }}{{namespace:name}}{{^last?}}::{{/last?}}{{! }}{{/program:namespace_cpp2}}{{! }}{{#service:namespace_cpp2}}{{! }}{{namespace:name}}{{^last?}}::{{/last?}}{{! }}{{/service:namespace_cpp2}} )__FBTHRIFT_TAG__", // cpp2/common/service_namespace_cpp2.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:namespace_cpp2}}{{namespace:name}}{{^last?}}::{{/last?}}{{/service:namespace_cpp2}} )__FBTHRIFT_TAG__", // cpp2/common/service_namespace_cpp2_begin.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:namespace_cpp2}} namespace {{namespace:name}} { {{/service:namespace_cpp2}} )__FBTHRIFT_TAG__", // cpp2/common/service_namespace_cpp2_end.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:namespace_cpp2}}}{{/service:namespace_cpp2}} // namespace {{ > common/service_namespace_cpp2 }} )__FBTHRIFT_TAG__", // cpp2/common/type_namespace_cpp2.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#type:namespace_cpp2}}::{{namespace:name}}{{#last?}}::{{/last?}}{{/type:namespace_cpp2}} )__FBTHRIFT_TAG__", // cpp2/fatal/fatal_using_string_declaration.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#fatal_strings:items}} using {{fatal_string:name}} = __fbthrift_strings::{{fatal_string:name}}; {{/fatal_strings:items}} )__FBTHRIFT_TAG__", // cpp2/field/default.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. // The default value for a field. // TODO(afuller): Merge with other impls and move to a shared location. }}{{#field:cpp_first_adapter}}{{! }}::apache::thrift::adapt_detail::fromThriftField<{{field:cpp_first_adapter}}, {{field:key}}>({{! }}{{^field:cpp_exactly_one_adapter?}}{{ > types/adapter_pre}}{{/field:cpp_exactly_one_adapter?}}{{! }}{{#field:cpp_exactly_one_adapter?}}{{type:cpp_standard_type}}({{/field:cpp_exactly_one_adapter?}}{{! }}{{/field:cpp_first_adapter}}{{! }}{{#field:value}}{{! }}{{ > common/iterate_const_values}}{{! }}{{/field:value}}{{! }}{{^field:value}}{{! }}{{#type:string_or_binary?}}{{! }}apache::thrift::StringTraits<{{ > types/indirected_string_type}}>::fromStringLiteral(""){{! }}{{/type:string_or_binary?}}{{! }}{{^type:string_or_binary?}}{{! }}{{#type:cpp_indirection?}}0{{/type:cpp_indirection?}}{{! }}{{^type:cpp_indirection?}}{{type:cpp_standard_type}}(){{/type:cpp_indirection?}}{{! }}{{/type:string_or_binary?}}{{! }}{{/field:value}}{{! }}{{#field:cpp_first_adapter}}{{! }}{{^field:cpp_exactly_one_adapter?}}{{ > types/adapter_post}}{{/field:cpp_exactly_one_adapter?}}{{! }}{{#field:cpp_exactly_one_adapter?}}){{/field:cpp_exactly_one_adapter?}}{{! }}, *this){{! }}{{/field:cpp_first_adapter}} )__FBTHRIFT_TAG__", // cpp2/field/intrinsic_default.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. // Returns the intrinsic default value for base or enum fields. }}{{#type:string_or_binary?}}{{! }}apache::thrift::StringTraits<{{ > types/indirected_string_type}}>::fromStringLiteral(""){{! }}{{/type:string_or_binary?}}{{! }}{{^type:string_or_binary?}}{{! }}{{#type:cpp_indirection?}}0{{/type:cpp_indirection?}}{{! }}{{^type:cpp_indirection?}}{{type:cpp_standard_type}}(){{/type:cpp_indirection?}}{{! }}{{/type:string_or_binary?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/field/member.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^struct:union?}}this->{{/struct:union?}}{{#struct:union?}}value_.{{/struct:union?}}{{field:cpp_storage_name}} )__FBTHRIFT_TAG__", // cpp2/field/tag.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. // Note: All adapted fields need to use field tag. }}{{^field:cpp_adapter}}{{field:type_tag}}{{/field:cpp_adapter}}{{! }}{{#field:cpp_adapter}}::apache::thrift::op::get_field_tag<{{struct:cpp_underlying_name}}, ::apache::thrift::field_id<{{field:key}}>>{{/field:cpp_adapter}} )__FBTHRIFT_TAG__", // cpp2/metadata/const_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}*{{#structured_annotation:const}}{{#constant:value}}{{ > metadata/const_value}}{{/constant:value}}{{/structured_annotation:const}}.cv_struct_ref() )__FBTHRIFT_TAG__", // cpp2/metadata/const_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#value:const_struct?}}cvStruct({{! }}{{#value:const_struct_type}}{{#type:struct}}"{{type:program_name}}.{{struct:name}}"{{/type:struct}}{{/value:const_struct_type}}, {{! }}{ {{#value:const_struct}}{"{{constant:name}}", {{#constant:value}}{{ > metadata/const_value}}{{/constant:value}} }{{^last?}}, {{/last?}}{{! }}{{/value:const_struct}} }{{! }}){{/value:const_struct?}}{{^value:const_struct?}}{{! }}{{#value:bool?}}cvBool({{value:bool_value}}){{/value:bool?}}{{! }}{{#value:integer?}}cvInteger({{value:integer_value}}){{/value:integer?}}{{! }}{{#value:enum?}}cvInteger({{value:integer_value}}){{/value:enum?}}{{! }}{{#value:double?}}cvDouble({{value:double_value}}){{/value:double?}}{{! }}{{#value:string?}}cvString("{{value:string_value}}"){{/value:string?}}{{! }}{{#value:map?}}cvMap({ {{#value:map_elements}}cvPair({{#element:key}}{{ > metadata/const_value}}{{/element:key}}, {{#element:value}}{{ > metadata/const_value}}{{/element:value}}){{^last?}}, {{/last?}}{{/value:map_elements}} }){{/value:map?}}{{! }}{{#value:list?}}cvList({ {{#value:list_elements}}{{ > metadata/const_value}}{{^last?}}, {{/last?}}{{/value:list_elements}} }){{/value:list?}}{{/value:const_struct?}} )__FBTHRIFT_TAG__", // cpp2/metadata/field_gen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{ {{field:key}}, "{{field:name}}", {{field:optional?}}, {{#field:type}}{{ > metadata/type_gen}}{{/field:type}}, {{! }}std::vector{ {{#field:structured_annotations}}{{#structured_annotation:const_struct?}}{{! }}{{ > metadata/const_struct}}, {{! }}{{/structured_annotation:const_struct?}}{{/field:structured_annotations}}}}, )__FBTHRIFT_TAG__", // cpp2/metadata/func_field_gen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}::apache::thrift::metadata::ThriftField {{ > metadata/func_field_name}}; {{ > metadata/func_field_name}}.id() = {{field:key}}; {{ > metadata/func_field_name}}.name() = "{{field:name}}"; {{ > metadata/func_field_name}}.is_optional() = false; {{#field:structured_annotations}} {{ > metadata/func_field_name}}.structured_annotations() = { {{#structured_annotation:const_struct?}} {{ > metadata/const_struct}}, {{/structured_annotation:const_struct?}} }; {{/field:structured_annotations}} {{#field:type}} auto {{ > metadata/func_field_name}}_type = {{ > metadata/type_gen}}; {{ > metadata/func_field_name}}_type->writeAndGenType(*{{ > metadata/func_field_name}}.type(), metadata); {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/metadata/func_field_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{service:metadata_name}}_{{function:name}}_{{field:metadata_name}} )__FBTHRIFT_TAG__", // cpp2/metadata/return_type_gen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:sink?}}{{ > metadata/type_gen }}{{/function:sink?}}{{! }}{{#function:sink?}}std::make_unique({{#function:sink_elem_type}}{{ > metadata/type_gen}}{{/function:sink_elem_type}}, {{#function:sink_final_response_type}}{{ > metadata/type_gen}}{{/function:sink_final_response_type}}{{#function:sink_has_first_response?}}, {{#function:sink_first_response_type}}{{ > metadata/type_gen}}{{/function:sink_first_response_type}}{{/function:sink_has_first_response?}}){{/function:sink?}}{{! }}{{#function:stream?}}{{! }}std::make_unique({{#function:stream_elem_type}}{{ > metadata/type_gen}}{{/function:stream_elem_type}}{{#type:streamFirstResponse?}}, {{#function:stream_first_response_type}}{{ > metadata/type_gen}}{{/function:stream_first_response_type}}{{/type:streamFirstResponse?}}){{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // cpp2/metadata/type_gen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}std::make_unique("{{type:program_name}}.{{type:cpp_name}}", {{#type:typedef_type}}{{ > metadata/type_gen}}{{/type:typedef_type}}, std::vector{ {{#type:typedef}}{{#typedef:structured_annotations}}{{#structured_annotation:const_struct?}}{{ > metadata/const_struct}}, {{/structured_annotation:const_struct?}}{{/typedef:structured_annotations}}{{/type:typedef}} }){{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:base?}}{{! }}std::make_unique({{! }}{{#type:bool?}}ThriftPrimitiveType::THRIFT_BOOL_TYPE{{/type:bool?}}{{! }}{{#type:byte?}}ThriftPrimitiveType::THRIFT_BYTE_TYPE{{/type:byte?}}{{! }}{{#type:i16?}}ThriftPrimitiveType::THRIFT_I16_TYPE{{/type:i16?}}{{! }}{{#type:i32?}}ThriftPrimitiveType::THRIFT_I32_TYPE{{/type:i32?}}{{! }}{{#type:i64?}}ThriftPrimitiveType::THRIFT_I64_TYPE{{/type:i64?}}{{! }}{{#type:float?}}ThriftPrimitiveType::THRIFT_FLOAT_TYPE{{/type:float?}}{{! }}{{#type:double?}}ThriftPrimitiveType::THRIFT_DOUBLE_TYPE{{/type:double?}}{{! }}{{#type:binary?}}ThriftPrimitiveType::THRIFT_BINARY_TYPE{{/type:binary?}}{{! }}{{#type:string?}}ThriftPrimitiveType::THRIFT_STRING_TYPE{{/type:string?}}{{! }}{{#type:void?}}ThriftPrimitiveType::THRIFT_VOID_TYPE{{/type:void?}}){{! }}{{/type:base?}}{{! }}{{^type:base?}}{{! }}{{#type:list?}}std::make_unique({{#type:list_elem_type}}{{ > metadata/type_gen}}{{/type:list_elem_type}}){{/type:list?}}{{! }}{{#type:set?}}std::make_unique({{#type:set_elem_type}}{{ > metadata/type_gen}}{{/type:set_elem_type}}){{/type:set?}}{{! }}{{#type:map?}}std::make_unique({{#type:key_type}}{{ > metadata/type_gen}}{{/type:key_type}}, {{#type:value_type}}{{ > metadata/type_gen}}{{/type:value_type}}){{/type:map?}}{{! }}{{#type:enum?}}std::make_unique>("{{type:program_name}}.{{#type:enum}}{{enum:name}}{{/type:enum}}"){{/type:enum?}}{{! }}{{#type:struct?}}{{! }}{{#type:union?}}std::make_unique>("{{type:program_name}}.{{type:name}}"){{/type:union?}}{{! }}{{^type:union?}}std::make_unique>("{{type:program_name}}.{{type:name}}"){{/type:union?}}{{! }}{{/type:struct?}}{{! }}{{/type:base?}}{{/type:typedef?}} )__FBTHRIFT_TAG__", // cpp2/metadata/unstructured_field_gen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}std::map{ {{#field:annotations}}{R"THRIFT_CODEGEN({{annotation:key}})THRIFT_CODEGEN", R"THRIFT_CODEGEN({{annotation:value}})THRIFT_CODEGEN"},{{/field:annotations}} } )__FBTHRIFT_TAG__", // cpp2/module_clients.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} {{#program}} #include "{{program:include_prefix}}{{program:name}}_clients.h" {{/program}} #include {{#services}} {{ > service_cpp/async_client_cpp}} {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_clients.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include {{#program}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_clients.h" {{/program:thrift_includes}} {{#program:cpp_includes}} // cpp_include's #include {{cpp_include}} {{/program:cpp_includes}} {{/program}} {{#any_sinks?}} // for sinks #include #include {{/any_sinks?}} {{#any_streams?}} // for streams #include {{/any_streams?}} {{#any_interactions?}} // for interactions #include #include #include {{/any_interactions?}} namespace apache { namespace thrift { class Cpp2RequestContext; namespace detail { namespace ac { struct ClientRequestContext; }} namespace transport { class THeader; } }} {{#services}} {{ > service_h/async_client}} {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_clients_out_of_line.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#services}} #include "{{service:include_prefix}}{{service:name}}AsyncClient.h" {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_constants.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} {{#program:constants?}} #include "{{program:include_prefix}}{{program:name}}_constants.h" #include {{#program:thrift_includes}} {{#program:constants?}} #include "{{program:include_prefix}}{{program:name}}_constants.h" {{/program:constants?}} {{/program:thrift_includes}} {{ > common/namespace_cpp2_begin}} {{#program:constants}}{{#constant:type}}{{#constant:value}} {{#constant:outline_init?}} {{#value:enable_referencing}} {{constant:cpp_type}} const& {{program:name}}_constants::{{constant:name}}() { {{^constant:cpp_adapter}} static folly::Indestructible<{{type:cpp_type}}> const instance{ {{ > common/iterate_const_values_adapted}} }; {{/constant:cpp_adapter}} {{#constant:cpp_adapter}} static folly::Indestructible<{{constant:cpp_type}}> const instance{ folly::factory_constructor, [](){ return {{constant:cpp_adapter}}::fromThrift({{type:cpp_type}}({{ > common/iterate_const_values}}){{#constant:has_extra_arg?}}, {{#constant:extra_arg}}{{#constant:extra_arg_type}}{{ > common/iterate_const_values}}{{/constant:extra_arg_type}}{{/constant:extra_arg}}, "{{constant:uri}}"{{/constant:has_extra_arg?}}); }}; {{/constant:cpp_adapter}} return *instance; } {{/value:enable_referencing}} {{/constant:outline_init?}} {{/constant:value}}{{/constant:type}}{{/program:constants}} {{#program:interning?}} const ::apache::thrift::type::AnyValue& {{program:name}}_constants::getValue(::apache::thrift::type::ValueId vid) { if (vid == ::apache::thrift::type::ValueId{}) { throw std::out_of_range("Invalid ValueId"); } auto pos = ::apache::thrift::type::toPosition(static_cast<::apache::thrift::type::Ordinal>(vid), {{program:num_interned_values}}); {{#program:interned_values?}} static const folly::Indestructible<::std::array<::apache::thrift::type::AnyValue, {{program:num_interned_values}}>> values { { { {{#program:interned_values}} {{#constant:type}} {{#constant:value}} ::apache::thrift::type::AnyValue::create<{{type:type_tag}}>({{ > common/iterate_const_values}}), {{/constant:value}} {{/constant:type}} {{/program:interned_values}} }}}; return (*values)[pos]; {{/program:interned_values?}} } {{/program:interning?}} {{ > common/namespace_cpp2_end}} {{/program:constants?}} )__FBTHRIFT_TAG__", // cpp2/module_constants.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include {{#program:interning?}} #include {{/program:interning?}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{ > common/namespace_cpp2_begin}} struct {{program:name}}_constants { {{#program:constants}}{{#constant:type}}{{#constant:value}} {{^constant:outline_init?}} static constexpr {{ > types/const_value_type}} const {{constant:name}}_ = {{ > common/const_value}}; static constexpr {{ > types/const_value_type}} {{constant:name}}() { return {{constant:name}}_; } {{/constant:outline_init?}} {{#constant:outline_init?}} static {{constant:cpp_type}} const& {{constant:name}}(); {{/constant:outline_init?}} {{/constant:value}}{{/constant:type}}{{/program:constants}} {{#program:interning?}} static const ::apache::thrift::type::AnyValue& getValue(::apache::thrift::type::ValueId id); {{/program:interning?}} }; {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_data.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include "{{program:include_prefix}}{{program:name}}_data.h" #include FOLLY_CLANG_DISABLE_WARNING("-Wunused-macros") #if defined(__GNUC__) && defined(__linux__) && !FOLLY_MOBILE // These attributes are applied to the static data members to ensure that they // are not stripped from the compiled binary, in order to keep them available // for use by debuggers at runtime. // // The "used" attribute is required to ensure the compiler always emits unused // data. // // The "section" attribute is required to stop the linker from stripping used // data. It works by forcing all of the data members (both used and unused ones) // into the same section. As the linker strips data on a per-section basis, it // is then unable to remove unused data without also removing used data. // This has a similar effect to the "retain" attribute, but works with older // toolchains. #define THRIFT_DATA_MEMBER [[gnu::used]] [[gnu::section(".rodata.thrift.data")]] #else #define THRIFT_DATA_MEMBER #endif namespace apache { namespace thrift { {{#program:structs}} THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<{{struct:cpp_fullname}}>::name = "{{struct:name}}"; THRIFT_DATA_MEMBER const std::array TStructDataStorage<{{struct:cpp_fullname}}>::fields_names = { { {{#struct:fields}} "{{field:name}}"sv, {{/struct:fields}} }}; THRIFT_DATA_MEMBER const std::array TStructDataStorage<{{struct:cpp_fullname}}>::fields_ids = { { {{#struct:fields}} {{field:key}}, {{/struct:fields}} }}; THRIFT_DATA_MEMBER const std::array TStructDataStorage<{{struct:cpp_fullname}}>::fields_types = { { {{#struct:fields}}{{#field:type}} TType::{{ > module_types_tcc/struct_type}}, {{/field:type}}{{/struct:fields}} }}; THRIFT_DATA_MEMBER const std::array TStructDataStorage<{{struct:cpp_fullname}}>::storage_names = { { {{#struct:fields}} "{{field:cpp_storage_name}}"sv, {{/struct:fields}} }}; THRIFT_DATA_MEMBER const std::array TStructDataStorage<{{struct:cpp_fullname}}>::isset_indexes = { { {{#struct:fields}} {{#field:has_isset?}}{{field:isset_index}}{{/field:has_isset?}}{{^field:has_isset?}}-1{{/field:has_isset?}}, {{/struct:fields}} }}; {{/program:structs}} } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_data.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include "{{program:include_prefix}}{{program:name}}_types.h" namespace apache { namespace thrift { {{#program:enums}} template <> struct TEnumDataStorage<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> { using type = {{ > common/namespace_cpp2}}{{enum:cpp_name}}; static constexpr const std::size_t size = {{enum:size}}; static constexpr std::array values = { { {{#enum:values}}{{! }} type::{{enum_value:cpp_name}}, {{/enum:values}} }}; static constexpr std::array names = { { {{#enum:values}}{{! }} "{{enum_value:name}}"sv, {{/enum:values}} }}; }; {{/program:enums}} {{#program:structs}} {{#struct:union?}} template <> struct TEnumDataStorage<{{struct:cpp_fullname}}::Type> { using type = {{struct:cpp_fullname}}::Type; static constexpr const std::size_t size = {{struct:num_union_members}}; static constexpr std::array values = { { {{#struct:fields}}{{! }} type::{{field:cpp_name}}, {{/struct:fields}} }}; static constexpr std::array names = { { {{#struct:fields}}{{! }} "{{field:name}}"sv, {{/struct:fields}} }}; }; {{/struct:union?}} {{/program:structs}} {{#program:structs}} template <> struct TStructDataStorage<{{struct:cpp_fullname}}> { static constexpr const std::size_t fields_size = {{struct:fields_size}}; static const std::string_view name; static const std::array fields_names; static const std::array fields_ids; static const std::array fields_types; private: // The following fields describe internal storage metadata, and are private to // prevent user logic from accessing them, but they can be inspected by // debuggers. static const std::array storage_names; // -1 if the field has no isset. static const std::array isset_indexes; }; {{/program:structs}} }} // apache::thrift )__FBTHRIFT_TAG__", // cpp2/module_fatal.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include #include #include #include "{{program:include_prefix}}{{program:name}}_types.h" {{ > common/namespace_cpp2_begin}} namespace __fbthrift_refl { struct __fbthrift_strings_{{program:name}} { {{#program:fatal_identifiers}} using {{identifier:name}} = {{identifier:fatal_string}}; {{/program:fatal_identifiers}} }; struct {{program:name}}_module_traits { using strings = __fbthrift_strings_{{program:name}}; using name = strings::{{program:name}}; using namespaces = ::fatal::list< {{#program:fatal_languages}}{{#fatal_languages:items}} ::fatal::pair{{^last?}},{{/last?}} {{/fatal_languages:items}}{{/program:fatal_languages}} >; using enums = ::fatal::list< {{#program:fatal_enums}}{{#fatal_strings:items}} ::fatal::pair<{{ > common/namespace_cpp2}}{{fatal_string:name}}, strings::{{fatal_string:name}}>{{^last?}},{{/last?}} {{/fatal_strings:items}}{{/program:fatal_enums}} >; using unions = ::fatal::list< {{#program:fatal_unions}}{{#fatal_strings:items}} ::fatal::pair<{{ > common/namespace_cpp2}}{{fatal_string:name}}, strings::{{fatal_string:name}}>{{^last?}},{{/last?}} {{/fatal_strings:items}}{{/program:fatal_unions}} >; using structs = ::fatal::list< {{#program:fatal_structs}}{{#fatal_strings:items}} ::fatal::pair<{{ > common/namespace_cpp2}}{{fatal_string:name}}, strings::{{fatal_string:name}}>{{^last?}},{{/last?}} {{/fatal_strings:items}}{{/program:fatal_structs}} >; using constants = ::fatal::list< {{#program:fatal_constants}}{{#fatal_strings:items}} strings::{{fatal_string:name}}{{^last?}},{{/last?}} {{/fatal_strings:items}}{{/program:fatal_constants}} >; using services = ::fatal::list< {{#program:fatal_services}}{{#fatal_strings:items}} strings::{{fatal_string:name}}{{^last?}},{{/last?}} {{/fatal_strings:items}}{{/program:fatal_services}} >; }; } // __fbthrift_refl class {{program:name}}_tags { using __fbthrift_strings = __fbthrift_refl::__fbthrift_strings_{{program:name}}; struct __fbthrift_languages { {{#program:fatal_languages}}{{#fatal_languages:items}} using {{language:safe_name}} = __fbthrift_strings::{{language:safe_name}}; {{/fatal_languages:items}}{{/program:fatal_languages}} }; struct __fbthrift_enums { {{#program:fatal_enums}}{{ > fatal/fatal_using_string_declaration}}{{/program:fatal_enums}} }; struct __fbthrift_unions { {{#program:fatal_unions}}{{ > fatal/fatal_using_string_declaration}}{{/program:fatal_unions}} }; struct __fbthrift_structs { {{#program:fatal_structs}}{{ > fatal/fatal_using_string_declaration}}{{/program:fatal_structs}} }; struct __fbthrift_constants { {{#program:fatal_constants}}{{ > fatal/fatal_using_string_declaration}}{{/program:fatal_constants}} }; struct __fbthrift_services { {{#program:fatal_services}}{{ > fatal/fatal_using_string_declaration}}{{/program:fatal_services}} }; public: struct module {}; using strings = __fbthrift_strings; using languages = __fbthrift_languages; using enums = __fbthrift_enums; using unions = __fbthrift_unions; using structs = __fbthrift_structs; using constants = __fbthrift_constants; using services = __fbthrift_services; }; THRIFT_REGISTER_REFLECTION_METADATA({{program:name}}_tags::module, __fbthrift_refl::{{program:name}}_module_traits); {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_fatal_all.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_fatal_all.h" {{/program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" #include "{{program:include_prefix}}{{program:name}}_fatal_types.h" #include "{{program:include_prefix}}{{program:name}}_fatal_constant.h" #include "{{program:include_prefix}}{{program:name}}_fatal_service.h" )__FBTHRIFT_TAG__", // cpp2/module_fatal_constant.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_fatal_types.h" {{ > common/namespace_cpp2_begin}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_fatal_enum.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_types.h" #include "{{program:include_prefix}}{{program:name}}_fatal.h" #include #include {{ > common/namespace_cpp2_begin}} namespace __fbthrift_refl { namespace __fbthrift_refl_impl = ::apache::thrift::detail::reflection_impl; {{#program:enums}} class {{enum:cpp_name}}_enum_traits { public: using type = {{ > common/namespace_cpp2}}{{enum:cpp_name}}; private: {{#enum:values}} struct __fbthrift_value_{{enum_value:cpp_name}} { using name = __fbthrift_strings_{{program:name}}::{{enum_value:name_hash}}; using value = std::integral_constant; {{#enum_value:fatal_annotations?}} class annotations { struct __fbthrift_keys { {{#enum_value:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/enum_value:fatal_annotations}} }; struct __fbthrift_values { {{#enum_value:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/enum_value:fatal_annotations}} }; public: using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#enum_value:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/enum_value:fatal_annotations}} >; }; {{/enum_value:fatal_annotations?}} {{^enum_value:fatal_annotations?}} using annotations = __fbthrift_refl_impl::no_annotations; {{/enum_value:fatal_annotations?}} }; {{/enum:values}} struct __fbthrift_member { {{#enum:values}} using {{enum_value:cpp_name}} = __fbthrift_value_{{enum_value:cpp_name}}; {{/enum:values}} }; public: using name = __fbthrift_strings_{{program:name}}::{{enum:name}}; using member = __fbthrift_member; using fields = ::fatal::list< {{#enum:values}} member::{{enum_value:cpp_name}}{{^last?}},{{/last?}} {{/enum:values}} >; {{#enum:fatal_annotations?}} class annotations { struct __fbthrift_keys { {{#enum:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/enum:fatal_annotations}} }; {{! Declared with __fbthrift_ prefix, so C++ name will not conflict with IDL names. }} struct __fbthrift_values { {{#enum:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/enum:fatal_annotations}} }; public: using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#enum:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/enum:fatal_annotations}} >; }; {{/enum:fatal_annotations?}} {{^enum:fatal_annotations?}} using annotations = __fbthrift_refl_impl::no_annotations; {{/enum:fatal_annotations?}} static char const *to_string(type e, char const *fallback) { switch (e) { {{#enum:values}} case type::{{enum_value:cpp_name}}: return "{{enum_value:cpp_name}}"; {{/enum:values}} default: return fallback; } } }; {{/program:enums}} } // __fbthrift_refl {{#program:enums}} FATAL_REGISTER_ENUM_TRAITS( __fbthrift_refl::{{enum:cpp_name}}_enum_traits, ::apache::thrift::detail::type_common_metadata_impl< {{program:name}}_tags::module, ::apache::thrift::reflected_annotations<__fbthrift_refl::{{enum:cpp_name}}_enum_traits::annotations>, static_cast<::apache::thrift::legacy_type_id_t>({{enum:legacy_type_id}}ull) > ); {{/program:enums}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_fatal_service.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_types.h" {{ > common/namespace_cpp2_begin}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_fatal_struct.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > Autogen}} #pragma once {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_fatal_types.h" {{/program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" #include "{{program:include_prefix}}{{program:name}}_fatal.h" #include #include {{ > common/namespace_cpp2_begin}} namespace __fbthrift_refl { namespace __fbthrift_refl_impl = ::apache::thrift::detail::reflection_impl; {{#program:structs}}{{^struct:union?}} class {{struct:cpp_name}}_struct_traits { class __fbthrift_annotations{{^field:fatal_annotations?}} : public __fbthrift_refl_impl::no_annotations{{/field:fatal_annotations?}} { class __fbthrift_members { {{#struct:fields}} {{#field:fatal_annotations?}} class __fbthrift_field_{{field:cpp_name}} { struct __fbthrift_keys { {{#field:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/field:fatal_annotations}} }; struct __fbthrift_values { {{#field:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/field:fatal_annotations}} }; public: using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#field:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/field:fatal_annotations}} >; }; {{/field:fatal_annotations?}} {{/struct:fields}} public: {{#struct:fields}} {{#field:fatal_annotations?}} using {{field:cpp_name}} = ::apache::thrift::reflected_annotations<__fbthrift_field_{{field:cpp_name}}>; {{/field:fatal_annotations?}} {{^field:fatal_annotations?}} using {{field:cpp_name}} = __fbthrift_refl_impl::reflected_no_annotations; {{/field:fatal_annotations?}} {{/struct:fields}} }; {{#struct:fatal_annotations?}} struct __fbthrift_keys { {{#struct:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/struct:fatal_annotations}} }; struct __fbthrift_values { {{#struct:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/struct:fatal_annotations}} }; {{/struct:fatal_annotations?}} public: {{#struct:fatal_annotations?}} using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#struct:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/struct:fatal_annotations}} >; {{/struct:fatal_annotations?}} using members = __fbthrift_members; }; {{#struct:fields}} struct __fbthrift_member_{{field:cpp_name}} { using owner = {{struct:cpp_fullname}}; using name = __fbthrift_strings_{{program:name}}::{{field:name_hash}}; using type = {{field:cpp_type}}; using tag = ::apache::thrift::ident::{{field:cpp_name}}; static constexpr ::apache::thrift::field_id_t id = {{field:key}}; static constexpr auto optional = ::apache::thrift::optionality::{{field:fatal_required_qualifier}}; {{#field:type}}{{#type:cpp_indirection?}} using getter = __fbthrift_refl_impl::chained_data_member_accessor< __fbthrift_refl_impl::data_member_accessor<::apache::thrift::ident::{{field:cpp_name}}>, ::apache::thrift::detail::apply_indirection_fn >; using field_ref_getter = ::apache::thrift::access_field_fn<::apache::thrift::ident::{{field:cpp_name}}>; {{/type:cpp_indirection?}}{{/field:type}} {{#field:type}}{{^type:cpp_indirection?}} using getter = __fbthrift_refl_impl::data_member_accessor<::apache::thrift::ident::{{field:cpp_name}}>; using field_ref_getter = ::apache::thrift::access_field_fn<::apache::thrift::ident::{{field:cpp_name}}>; {{/type:cpp_indirection?}}{{/field:type}} using type_class = {{#field:type}}{{type:type_class}}{{/field:type}}; using annotations = ::apache::thrift::reflected_annotations<__fbthrift_annotations::members::{{field:cpp_name}}>; }; {{/struct:fields}} struct __fbthrift_member { {{#struct:fields}} using {{field:cpp_name}} = ::apache::thrift::reflected_struct_data_member<__fbthrift_member_{{field:cpp_name}}>; {{/struct:fields}} }; public: using type = {{struct:cpp_fullname}}; using name = __fbthrift_strings_{{program:name}}::{{struct:cpp_name}}; using member = __fbthrift_member; using members = ::fatal::list< {{#struct:fields}} member::{{field:cpp_name}}{{^last?}},{{/last?}} {{/struct:fields}} >; using members_annotations = __fbthrift_annotations::members; using metadata = ::apache::thrift::detail::type_common_metadata_impl< {{program:name}}_tags::module, ::apache::thrift::reflected_annotations<__fbthrift_annotations>, static_cast<::apache::thrift::legacy_type_id_t>({{struct:legacy_type_id}}ull) >; }; {{/struct:union?}}{{/program:structs}} } // __fbthrift_refl {{#program:structs}}{{^struct:union?}} THRIFT_REGISTER_STRUCT_TRAITS({{#struct:extra_namespace}}{{struct:extra_namespace}}::{{/struct:extra_namespace}}{{struct:cpp_name}}, __fbthrift_refl::{{struct:cpp_name}}_struct_traits); {{/struct:union?}}{{/program:structs}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_fatal_types.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_fatal_types.h" {{/program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_fatal.h" #include "{{program:include_prefix}}{{program:name}}_fatal_enum.h" #include "{{program:include_prefix}}{{program:name}}_fatal_union.h" #include "{{program:include_prefix}}{{program:name}}_fatal_struct.h" )__FBTHRIFT_TAG__", // cpp2/module_fatal_union.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_fatal_types.h" {{/program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" #include "{{program:include_prefix}}{{program:name}}_fatal.h" #include #include #include {{ > common/namespace_cpp2_begin}} namespace __fbthrift_refl { namespace __fbthrift_refl_impl = ::apache::thrift::detail::reflection_impl; {{#program:structs}}{{#struct:union?}} class {{struct:cpp_name}}_tenum_traits { public: using type = {{struct:cpp_fullname}}::Type; private: {{#struct:fields}} struct __fbthrift_value_{{field:cpp_name}} { using name = __fbthrift_strings_{{program:name}}::{{field:name_hash}}; using value = std::integral_constant; {{#field:fatal_annotations?}} class annotations { struct __fbthrift_keys { {{#field:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/field:fatal_annotations}} }; struct __fbthrift_values { {{#field:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/field:fatal_annotations}} }; public: using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#field:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/field:fatal_annotations}} >; }; {{/field:fatal_annotations?}} {{^field:fatal_annotations?}} using annotations = __fbthrift_refl_impl::no_annotations; {{/field:fatal_annotations?}} }; {{/struct:fields}} struct __fbthrift_member { {{#struct:fields}} using {{field:cpp_name}} = __fbthrift_value_{{field:cpp_name}}; {{/struct:fields}} }; public: using name = __fbthrift_strings_{{program:name}}::Type; using member = __fbthrift_member; using fields = ::fatal::list< {{#struct:fields}} member::{{field:cpp_name}}{{^last?}},{{/last?}} {{/struct:fields}} >; using annotations = __fbthrift_refl_impl::no_annotations; static char const *to_string(type e, char const *fallback) { switch (e) { {{#struct:fields}} case type::{{field:cpp_name}}: return "{{field:cpp_name}}"; {{/struct:fields}} default: return fallback; } } }; class {{struct:cpp_name}}_variant_traits { private: struct __fbthrift_ids { {{#struct:fields}} using {{field:cpp_name}} = std::integral_constant<{{struct:cpp_fullname}}::Type, {{struct:cpp_fullname}}::Type::{{field:cpp_name}}>; {{/struct:fields}} }; {{#struct:fields}} struct __fbthrift_member_{{field:cpp_name}} { using name = __fbthrift_strings_{{program:name}}::{{field:name_hash}}; using tag = ::apache::thrift::ident::{{field:cpp_name}}; static constexpr ::apache::thrift::field_id_t id = {{field:key}}; using type_class = {{#field:type}}{{type:type_class}}{{/field:type}}; struct setter { template decltype(auto) operator ()({{struct:cpp_fullname}} &variant, Args &&...args) const { return variant.set_{{field:cpp_name}}(std::forward(args)...); } }; struct getter { decltype(auto) operator ()({{struct:cpp_fullname}} const &variant) const { return variant.get_{{field:cpp_name}}(); } decltype(auto) operator ()({{struct:cpp_fullname}} &variant) const { return variant.mutable_{{field:cpp_name}}(); } decltype(auto) operator ()({{struct:cpp_fullname}} &&variant) const { return std::move(variant).move_{{field:cpp_name}}(); } }; }; {{/struct:fields}} public: using type = {{struct:cpp_fullname}}; using name = __fbthrift_strings_{{program:name}}::{{struct:cpp_name}}; using id = type::Type; using ids = __fbthrift_ids; using descriptors = ::fatal::list< {{#struct:fields}} ::fatal::variant_member_descriptor< {{#field:type}}{{type:cpp_type}}{{/field:type}}, __fbthrift_ids::{{field:cpp_name}}, __fbthrift_member_{{field:cpp_name}}::getter, __fbthrift_member_{{field:cpp_name}}::setter, ::apache::thrift::reflected_variant_member_metadata<__fbthrift_member_{{field:cpp_name}}>>{{^last?}},{{/last?}} {{/struct:fields}} >; {{#struct:fatal_annotations?}} class annotations { struct __fbthrift_keys { {{#struct:fatal_annotations}} using {{annotation:safe_key}} = __fbthrift_strings_{{program:name}}::{{annotation:safe_key}}; {{/struct:fatal_annotations}} }; struct __fbthrift_values { {{#struct:fatal_annotations}} using {{annotation:safe_key}} = {{annotation:fatal_string}}; {{/struct:fatal_annotations}} }; public: using keys = __fbthrift_keys; using values = __fbthrift_values; using map = ::fatal::list< {{#struct:fatal_annotations}} ::apache::thrift::annotation{{^last?}},{{/last?}} {{/struct:fatal_annotations}} >; }; {{/struct:fatal_annotations?}} {{^struct:fatal_annotations?}} using annotations = __fbthrift_refl_impl::no_annotations; {{/struct:fatal_annotations?}} static id get_id(type const &variant) { return variant.getType(); } static bool empty(type const &variant) { return variant.getType() == id::__EMPTY__; } static void clear(type &variant) { return apache::thrift::clear(variant); } }; {{/struct:union?}}{{/program:structs}} } // __fbthrift_refl {{#program:structs}}{{#struct:union?}} FATAL_REGISTER_ENUM_TRAITS( __fbthrift_refl::{{struct:cpp_name}}_tenum_traits, ::apache::thrift::detail::type_common_metadata_impl< {{program:name}}_tags::module, ::apache::thrift::reflected_annotations<__fbthrift_refl::{{struct:cpp_name}}_tenum_traits::annotations>, static_cast<::apache::thrift::legacy_type_id_t>(0ull) > ); FATAL_REGISTER_VARIANT_TRAITS( __fbthrift_refl::{{struct:cpp_name}}_variant_traits, ::apache::thrift::detail::type_common_metadata_impl< {{program:name}}_tags::module, ::apache::thrift::reflected_annotations<__fbthrift_refl::{{struct:cpp_name}}_variant_traits::annotations>, static_cast<::apache::thrift::legacy_type_id_t>({{struct:legacy_type_id}}ull) > ); {{/struct:union?}}{{/program:structs}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_for_each_field.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_metadata.h" #include namespace apache { namespace thrift { namespace detail { {{#program:structs}} template <> struct ForEachField<{{struct:cpp_fullname}}> { template void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const { {{#struct:fields}} f({{field:index}}, static_cast(t).{{field:cpp_name}}_ref()...); {{/struct:fields}} } }; {{/program:structs}} } // namespace detail } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_handlers-inl.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program}} #include "{{program:include_prefix}}{{program:name}}_handlers.h" {{/program}} #include {{#services}} {{ > service_cpp/service_inl}} {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_handlers.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} {{#program}} #include "{{program:include_prefix}}{{program:name}}_handlers.h" #include "{{program:include_prefix}}{{program:name}}_handlers-inl.h" #include "{{program:include_prefix}}{{program:name}}_metadata.h" {{#program:constants?}} #include "{{program:include_prefix}}{{program:name}}_constants.h" {{/program:constants?}} {{/program}} #include {{#services}} {{ > service_cpp/handlers_cpp}} {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_handlers.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include {{#program}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_handlers.h" {{/program:thrift_includes}} {{#program:cpp_includes}} // cpp_include's #include {{cpp_include}} {{/program:cpp_includes}} {{/program}} {{#any_sinks?}} // for sinks #include {{/any_sinks?}} {{#any_streams?}} // for streams #include {{/any_streams?}} {{#any_interactions?}} // for interactions #include #include {{/any_interactions?}} namespace folly { class IOBuf; class IOBufQueue; } namespace apache { namespace thrift { class Cpp2RequestContext; class BinaryProtocolReader; class CompactProtocolReader; namespace transport { class THeader; } }} {{#services}} {{ > service_h/handlers_h}} {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_handlers_out_of_line.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#services}} #include "{{service:include_prefix}}{{service:name}}.h" {{/services}} )__FBTHRIFT_TAG__", // cpp2/module_layouts.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > Autogen}} #include "{{program:include_prefix}}{{program:name}}_layouts.h" namespace apache { namespace thrift { namespace frozen { {{#program:structs_and_typedefs}}{{#is_struct?}} {{^struct:cpp_frozen2_exclude?}} {{^struct:union?}} FROZEN_CTOR({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_CTOR_FIELD{{ > common/field_suffix}}({{field:cpp_name}}, {{field:key}}){{! }}{{/struct:fields}}) FROZEN_MAXIMIZE({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_MAXIMIZE_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_LAYOUT({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_LAYOUT_FIELD{{ > common/field_suffix}}({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_FREEZE({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_FREEZE_FIELD{{ > common/field_suffix}}({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_THAW({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_THAW_FIELD{{ > common/field_suffix}}({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_DEBUG({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_DEBUG_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_CLEAR({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_CLEAR_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) {{/struct:union?}} {{#struct:union?}} FROZEN_CTOR({{struct:cpp_fullname}},{{! }} FROZEN_CTOR_FIELD(type_, 0){{! }}{{#struct:fields}} FROZEN_CTOR_FIELD{{ > common/frozen2_union_field_suffix}}({{field:cpp_name}}, {{field:key}}){{! }}{{/struct:fields}}) FROZEN_MAXIMIZE({{struct:cpp_fullname}},{{! }} FROZEN_MAXIMIZE_FIELD(type_){{! }}{{#struct:fields}} FROZEN_MAXIMIZE_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) {{ > module_layouts_cpp/frozen_layout_union}} {{ > module_layouts_cpp/frozen_freeze_union}} {{ > module_layouts_cpp/frozen_thaw_union}} FROZEN_DEBUG({{struct:cpp_fullname}},{{! }} FROZEN_DEBUG_FIELD(type_){{! }}{{#struct:fields}} FROZEN_DEBUG_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_CLEAR({{struct:cpp_fullname}},{{! }} FROZEN_CLEAR_FIELD(type_){{! }}{{#struct:fields}} FROZEN_CLEAR_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) {{/struct:union?}} {{/struct:cpp_frozen2_exclude?}} {{/is_struct?}}{{/program:structs_and_typedefs}} }}} // apache::thrift::frozen {{!}} )__FBTHRIFT_TAG__", // cpp2/module_layouts.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > Autogen}} #pragma once #include #include "{{program:include_prefix}}{{program:name}}_types.h" {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_layouts.h" {{/program:thrift_includes}} namespace apache { namespace thrift { namespace frozen { {{#program:structs_and_typedefs}}{{#is_struct?}} {{#struct:cpp_frozen2_exclude?}} FROZEN_EXCLUDE_TYPE({{struct:cpp_fullname}}) {{/struct:cpp_frozen2_exclude?}} {{/is_struct?}}{{/program:structs_and_typedefs}} {{#program:structs_and_typedefs}}{{#is_struct?}} {{^struct:cpp_frozen2_exclude?}} {{^struct:union?}} FROZEN_TYPE({{struct:cpp_fullname}},{{! }}{{#struct:fields}} FROZEN_FIELD{{ > common/field_suffix}}({{field:cpp_name}}, {{field:key}}, {{#field:type}}{{field:cpp_storage_type}}{{/field:type}}){{! }}{{/struct:fields}} FROZEN_VIEW({{! }}{{#struct:fields}} FROZEN_VIEW_FIELD{{ > common/field_suffix}}({{field:cpp_name}}, {{#field:type}}{{field:cpp_storage_type}}{{/field:type}}){{! }}{{/struct:fields}}) FROZEN_SAVE_INLINE({{! }}{{#struct:fields}} FROZEN_SAVE_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_LOAD_INLINE({{! }}{{#struct:fields}} FROZEN_LOAD_FIELD({{field:cpp_name}}, {{field:key}}){{! }}{{/struct:fields}})); {{/struct:union?}} {{#struct:union?}} FROZEN_TYPE({{struct:cpp_fullname}},{{! }} FROZEN_FIELD(type_, 0, {{struct:cpp_fullname}}::Type){{! }}{{#struct:fields}} FROZEN_FIELD{{ > common/frozen2_union_field_suffix}}({{field:cpp_name}}, {{field:key}}, {{#field:type}}{{field:cpp_storage_type}}{{/field:type}}){{! }}{{/struct:fields}} {{ > module_layouts_h/frozen_view_union}} FROZEN_SAVE_INLINE({{! }} FROZEN_SAVE_FIELD(type_){{! }}{{#struct:fields}} FROZEN_SAVE_FIELD({{field:cpp_name}}){{! }}{{/struct:fields}}) FROZEN_LOAD_INLINE({{! }} FROZEN_LOAD_FIELD(type_, 0){{! }}{{#struct:fields}} FROZEN_LOAD_FIELD({{field:cpp_name}}, {{field:key}}){{! }}{{/struct:fields}})); {{/struct:union?}} {{/struct:cpp_frozen2_exclude?}} {{/is_struct?}}{{/program:structs_and_typedefs}} }}} // apache::thrift::frozen {{!}} )__FBTHRIFT_TAG__", // cpp2/module_layouts_cpp/frozen_freeze_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} void Layout<{{struct:cpp_fullname}}>::freeze( FreezeRoot& root, const T& x, FreezePosition self) const { auto type = x.getType(); root.freezeField(self, this->type_Field, type); switch (type) { {{#struct:fields}} case {{struct:cpp_fullname}}::Type::{{field:cpp_name}}: { root.freezeField(self, this->{{field:cpp_name}}Field, x.get_{{field:cpp_name}}()); break; } {{/struct:fields}} default: { assert(false); break; } } } )__FBTHRIFT_TAG__", // cpp2/module_layouts_cpp/frozen_layout_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} FieldPosition Layout<{{struct:cpp_fullname}}>::layout( LayoutRoot& root, const T& x, LayoutPosition self) { auto type = x.getType(); FieldPosition pos = startFieldPosition(); pos = root.layoutField(self, pos, this->type_Field, type); switch (type) { {{#struct:fields}} case {{struct:cpp_fullname}}::Type::{{field:cpp_name}}: { pos = root.layoutField(self, pos, this->{{field:cpp_name}}Field, x.get_{{field:cpp_name}}()); break; } {{/struct:fields}} default: { assert(false); break; } } return pos; } )__FBTHRIFT_TAG__", // cpp2/module_layouts_cpp/frozen_thaw_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} void Layout<{{struct:cpp_fullname}}>::thaw( ViewPosition self, T& out) const { auto type = this->type_Field.layout.view(self(this->type_Field.pos)); switch (type) { {{#struct:fields}}{{#field:type}} case {{struct:cpp_fullname}}::Type::{{field:cpp_name}}: { {{#field:cpp_ref?}} {{! Since the ref fields are relative huge, if call set_field() directly, there will be some expensive object copies. So we want to engage the "mutable_field() = smart_pointer" style setter instead, which will only do a pointer copy}} {{! Use an empty value to set "type_" via the set_field() setter}} {{type:cpp_type}} emptyValue; out.set_{{field:cpp_name}}(std::move(emptyValue)); {{! Now use "mutable_field() = smart_pointer" setter to pass the real smart pointer}} auto ref = {{ > module_types_h/smart_ptr_constructor}}; thawField(self, this->{{field:cpp_name}}Field, ref); out.mutable_{{field:cpp_name}}() = std::move(ref); {{/field:cpp_ref?}} {{^field:cpp_ref?}} {{type:cpp_type}} fieldValue; thawField(self, this->{{field:cpp_name}}Field, fieldValue); out.set_{{field:cpp_name}}(std::move(fieldValue)); {{/field:cpp_ref?}} break; } {{/field:type}}{{/struct:fields}} default: { {{! The field has been removed during schema evolution, set the "type_" to __EMPTY__ }} apache::thrift::clear(out); break; } } } )__FBTHRIFT_TAG__", // cpp2/module_layouts_h/frozen_view_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} struct View : public ViewBase { {{struct:cpp_fullname}}::Type type_; View() : type_({{struct:cpp_fullname}}::Type::__EMPTY__) {} View(const LayoutSelf* layout, ViewPosition position) : ViewBase(layout, position) { type_ = this->layout_->type_Field.layout.view(this->position_(this->layout_->type_Field.pos)); switch (type_) { {{#struct:fields}} case {{struct:cpp_fullname}}::Type::{{field:cpp_name}}: { break; } {{/struct:fields}} default: { type_ = {{struct:cpp_fullname}}::Type::__EMPTY__; } } } {{struct:cpp_fullname}}::Type getType() {return type_;} {{#struct:fields}}{{#field:type}} auto get_{{field:cpp_name}}() const { assert(type_ == {{struct:cpp_fullname}}::Type::{{field:cpp_name}}); return this->layout_->{{field:cpp_name}}Field.layout.view( this->position_(this->layout_->{{field:cpp_name}}Field.pos)); } {{/field:type}}{{/struct:fields}} }; View view(ViewPosition self) const { return View(this, self); } )__FBTHRIFT_TAG__", // cpp2/module_metadata.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include #include "{{program:include_prefix}}{{program:name}}_metadata.h" // some of these functions can be so large that the compiler gives up optimizing // them - and issues a warning which may be treated as an error! // // these functions are so rarely called that it is probably okay for them not to // be optimized in practice FOLLY_CLANG_DISABLE_WARNING("-Wignored-optimization-argument") namespace apache { namespace thrift { namespace detail { namespace md { using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata; using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType; using ThriftType = ::apache::thrift::metadata::ThriftType; using ThriftService = ::apache::thrift::metadata::ThriftService; using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext; using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&); {{#program:enums}} void EnumMetadata<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::gen(ThriftMetadata& metadata) { auto res = metadata.enums()->emplace("{{program:name}}.{{enum:name}}", ::apache::thrift::metadata::ThriftEnum{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second; enum_metadata.name() = "{{program:name}}.{{enum:name}}"; using EnumTraits = TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>; for (std::size_t i = 0; i != EnumTraits::size; ++i) { enum_metadata.elements()->emplace(static_cast(EnumTraits::values[i]), EnumTraits::names[i]); } {{#enum:structured_annotations}} {{#structured_annotation:const_struct?}} enum_metadata.structured_annotations()->push_back({{ > metadata/const_struct}}); {{/structured_annotation:const_struct?}} {{/enum:structured_annotations}} } {{/program:enums}} {{#program:structs}} {{#program:unstructured_annotations_in_metadata?}} void StructMetadata<{{struct:cpp_fullname}}>::unstructured_annotations([[maybe_unused]] ::apache::thrift::metadata::ThriftStruct& thriftStruct){ {{#struct:fields}} thriftStruct.fields()[{{field:index}}].unstructured_annotations() = {{ > metadata/unstructured_field_gen}}; {{/struct:fields}} } {{/program:unstructured_annotations_in_metadata?}} const ::apache::thrift::metadata::ThriftStruct& StructMetadata<{{struct:cpp_fullname}}>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("{{program:name}}.{{struct:name}}", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& {{struct:metadata_name}} = res.first->second; {{struct:metadata_name}}.name() = "{{program:name}}.{{struct:name}}"; {{struct:metadata_name}}.is_union() = {{struct:union?}}; {{#struct:fields?}} static const auto* const {{struct:metadata_name}}_fields = new std::array{ { {{#struct:fields}} {{ > metadata/field_gen}} {{/struct:fields}} }}; for (const auto& f : *{{struct:metadata_name}}_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; field.name() = f.name; field.is_optional() = f.is_optional; f.metadata_type_interface->writeAndGenType(*field.type(), metadata); field.structured_annotations() = f.structured_annotations; {{struct:metadata_name}}.fields()->push_back(std::move(field)); } {{#program:unstructured_annotations_in_metadata?}} StructMetadata::unstructured_annotations({{struct:metadata_name}}); {{/program:unstructured_annotations_in_metadata?}} {{/struct:fields?}} {{#struct:structured_annotations}} {{#structured_annotation:const_struct?}} {{struct:metadata_name}}.structured_annotations()->push_back({{ > metadata/const_struct}}); {{/structured_annotation:const_struct?}} {{/struct:structured_annotations}} return res.first->second; } {{/program:structs}} {{#program:structs}} {{#struct:exception?}} void ExceptionMetadata<{{struct:cpp_fullname}}>::gen(ThriftMetadata& metadata) { auto res = metadata.exceptions()->emplace("{{program:name}}.{{struct:name}}", ::apache::thrift::metadata::ThriftException{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftException& {{struct:metadata_name}} = res.first->second; {{struct:metadata_name}}.name() = "{{program:name}}.{{struct:name}}"; {{#struct:fields?}} static const auto* const {{struct:metadata_name}}_fields = new std::array{ { {{#struct:fields}} {{ > metadata/field_gen}} {{/struct:fields}} }}; for (const auto& f : *{{struct:metadata_name}}_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; field.name() = f.name; field.is_optional() = f.is_optional; f.metadata_type_interface->writeAndGenType(*field.type(), metadata); {{struct:metadata_name}}.fields()->push_back(std::move(field)); } {{/struct:fields?}} {{#struct:structured_annotations}} {{#structured_annotation:const_struct?}} {{struct:metadata_name}}.structured_annotations()->push_back({{ > metadata/const_struct}}); {{/structured_annotation:const_struct?}} {{/struct:structured_annotations}} } {{/struct:exception?}} {{/program:structs}} {{#program:services}} {{#service:functions}}{{^function:starts_interaction?}} void ServiceMetadata<::{{ > service_common/service_class_name}}>::gen_{{function:cpp_name}}([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) { ::apache::thrift::metadata::ThriftFunction func; func.name() = "{{function:name}}"; {{#function:return_type}} auto func_ret_type = {{ > metadata/return_type_gen}}; func_ret_type->writeAndGenType(*func.return_type(), metadata); {{/function:return_type}} {{#function:args}} {{ > metadata/func_field_gen}} func.arguments()->push_back(std::move({{ > metadata/func_field_name}})); {{/function:args}} {{#function:exceptions}} {{ > metadata/func_field_gen}} func.exceptions()->push_back(std::move({{ > metadata/func_field_name}})); {{#field:type}} {{#type:struct?}} ExceptionMetadata<{{type:cpp_fullname}}>::gen(metadata); {{/type:struct?}} {{/field:type}} {{/function:exceptions}} func.is_oneway() = {{function:oneway?}}; {{#function:structured_annotations}} {{#structured_annotation:const_struct?}} func.structured_annotations()->push_back({{ > metadata/const_struct}}); {{/structured_annotation:const_struct?}} {{/function:structured_annotations}} service.functions()->push_back(std::move(func)); } {{/function:starts_interaction?}}{{/service:functions}} void ServiceMetadata<::{{ > service_common/service_class_name}}>::gen(::apache::thrift::metadata::ThriftServiceMetadataResponse& response) { const ::apache::thrift::metadata::ThriftServiceContextRef* self = genRecurse(*response.metadata(), *response.services()); DCHECK(self != nullptr); // TODO(praihan): Remove ThriftServiceContext from response. But in the meantime, we need to fill the field with the result of looking up in ThriftMetadata. ::apache::thrift::metadata::ThriftServiceContext context; context.module() = *self->module(); context.service_info() = response.metadata()->services()->at(*self->service_name()); response.context() = std::move(context); } const ThriftServiceContextRef* ServiceMetadata<::{{ > service_common/service_class_name}}>::genRecurse([[maybe_unused]] ThriftMetadata& metadata, std::vector& services) { ::apache::thrift::metadata::ThriftService {{service:metadata_name}}; {{service:metadata_name}}.name() = "{{program:name}}.{{service:name}}"; {{#service:functions?}} static const ThriftFunctionGenerator functions[] = { {{#service:functions}}{{^function:starts_interaction?}} ServiceMetadata<::{{ > service_common/service_class_name}}>::gen_{{function:cpp_name}}, {{/function:starts_interaction?}}{{/service:functions}} }; for (auto& function_gen : functions) { function_gen(metadata, {{service:metadata_name}}); } {{/service:functions?}} // We need to keep the index around because a reference or iterator could be invalidated. auto selfIndex = services.size(); services.emplace_back(); {{#service:extends?}} {{service:metadata_name}}.parent() = "{{#service:extends}}{{service:program_name}}.{{service:name}}{{/service:extends}}"; {{#service:extends}} ServiceMetadata<::{{ > service_common/service_class_name}}>::genRecurse(metadata, services); {{/service:extends}} {{/service:extends?}} {{#service:structured_annotations}} {{#structured_annotation:const_struct?}} {{service:metadata_name}}.structured_annotations()->push_back({{ > metadata/const_struct}}); {{/structured_annotation:const_struct?}} {{/service:structured_annotations}} ThriftServiceContextRef& context = services[selfIndex]; metadata.services()->emplace("{{program:name}}.{{service:name}}", std::move({{service:metadata_name}})); context.service_name() = "{{program:name}}.{{service:name}}"; ::apache::thrift::metadata::ThriftModuleContext module; module.name() = "{{program:name}}"; context.module() = std::move(module); return &context; } {{/program:services}} } // namespace md } // namespace detail } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_metadata.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include #include "{{program:include_prefix}}{{program:name}}_types.h" {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_metadata.h" {{/program:thrift_includes}} {{#program:services}} {{ > common/service_namespace_cpp2_begin }} class {{service:cpp_name}}; {{ > common/service_namespace_cpp2_end }} {{/program:services}} namespace apache { namespace thrift { namespace detail { namespace md { {{#program:enums}} {{^program:no_metadata?}} template <> class EnumMetadata<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> { public: static void gen(ThriftMetadata& metadata); }; {{/program:no_metadata?}} {{#program:no_metadata?}} template <> class EnumMetadata<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> : private EmptyMetadata { public: using EmptyMetadata::gen; }; {{/program:no_metadata?}} {{/program:enums}} {{#program:structs}} {{^program:no_metadata?}} template <> class StructMetadata<{{struct:cpp_fullname}}> { public: static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata); {{#program:unstructured_annotations_in_metadata?}} private: static void unstructured_annotations(::apache::thrift::metadata::ThriftStruct& thriftStruct); {{/program:unstructured_annotations_in_metadata?}} }; {{/program:no_metadata?}} {{#program:no_metadata?}} template <> class StructMetadata<{{struct:cpp_fullname}}> : private EmptyMetadata { public: using EmptyMetadata::gen; }; {{/program:no_metadata?}} {{/program:structs}} {{#program:structs}} {{#struct:exception?}} {{^program:no_metadata?}} template <> class ExceptionMetadata<{{struct:cpp_fullname}}> { public: static void gen(ThriftMetadata& metadata); }; {{/program:no_metadata?}} {{#program:no_metadata?}} template <> class ExceptionMetadata<{{struct:cpp_fullname}}> : private EmptyMetadata { public: using EmptyMetadata::gen; }; {{/program:no_metadata?}} {{/struct:exception?}} {{/program:structs}} {{#program:services}} {{^program:no_metadata?}} template <> class ServiceMetadata<::{{ > service_common/service_class_name}}> { public: static void gen(ThriftServiceMetadataResponse& response); private: static const ThriftServiceContextRef* genRecurse(ThriftMetadata& metadata, std::vector& services); template friend class ServiceMetadata; {{#service:functions}}{{^function:starts_interaction?}} static void gen_{{function:cpp_name}}(ThriftMetadata& metadata, ThriftService& context); {{/function:starts_interaction?}}{{/service:functions}} }; {{/program:no_metadata?}} {{#program:no_metadata?}} template <> class ServiceMetadata<::{{ > service_common/service_class_name}}> : private EmptyServiceMetadata { public: using EmptyServiceMetadata::gen; private: using EmptyServiceMetadata::genRecurse; template friend class ServiceMetadata; }; {{/program:no_metadata?}} {{/program:services}} } // namespace md } // namespace detail } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_sinit.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} {{ > common/namespace_cpp2_begin}} {{#program:any?}} // Call all static init functions. // // If this file is always linked (e.g. link_whole), it will force // static linking to include the intialization logic. {{#program:structs}} {{#struct:any?}} void __fbthrift_static_init_{{struct:cpp_underlying_name}}(); {{/struct:any?}} {{/program:structs}} namespace { struct StaticInit { StaticInit() { {{#program:structs}} {{#struct:any?}} __fbthrift_static_init_{{struct:cpp_underlying_name}}(); {{/struct:any?}} {{/program:structs}} } }; StaticInit staticInit; } {{/program:any?}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_types.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include "{{program:include_prefix}}{{program:name}}_types.h" #include "{{program:include_prefix}}{{program:name}}_types.tcc" #include {{#program:any?}} #include {{/program:any?}} #include "{{program:include_prefix}}{{program:name}}_data.h" {{#program:any?}} {{ > common/namespace_cpp2_begin}} // Static-init time registration for dynamically-linked libraries. // // To include in statically-linked libraries, link whole (e.g. --whole-archive) // `{{program:name}}_sinit.cpp`. {{#program:split_structs}} {{#struct:any?}} void __fbthrift_static_init_{{struct:cpp_underlying_name}}() { [[maybe_unused]] static bool init = ( apache::thrift::conformance::detail::registerGeneratedStruct< {{struct:cpp_underlying_name}}, {{#program:json?}} apache::thrift::conformance::StandardProtocol::SimpleJson, {{/program:json?}} apache::thrift::conformance::StandardProtocol::Compact, apache::thrift::conformance::StandardProtocol::Binary>(), false); } {{/struct:any?}} {{/program:split_structs}} {{ > common/namespace_cpp2_end}} {{/program:any?}} {{ > module_types_cpp/declare_enums}} {{#program:tablebased?}} namespace apache { namespace thrift { namespace detail { FOLLY_PUSH_WARNING FOLLY_GNU_DISABLE_WARNING("-Winvalid-offsetof") {{#program:split_structs}} {{^struct:union?}} template<> constexpr ptrdiff_t fieldOffset<{{struct:cpp_fullname}}>(std::int16_t fieldIndex) { constexpr ptrdiff_t offsets[] = { {{#struct:fields_in_key_order}} offsetof({{struct:cpp_fullname}}, {{field:cpp_storage_name}}){{! }}{{ > common/comma_newline}}{{/struct:fields_in_key_order}}}; return offsets[fieldIndex]; } template<> constexpr ptrdiff_t issetOffset<{{struct:cpp_fullname}}>(std::int16_t fieldIndex) { constexpr ptrdiff_t offsets[] = { {{#struct:fields_in_key_order}} {{#field:has_isset?}}{{! }}offsetof({{struct:cpp_fullname}}, __isset) + isset_bitset<{{struct:isset_fields_size}}>::get_offset() + {{field:isset_index}}{{! }}{{/field:has_isset?}}{{! }}{{^field:has_isset?}}{{! }}0{{/field:has_isset?}}{{ > common/comma_newline}}{{/struct:fields_in_key_order}}}; return offsets[fieldIndex]; } {{/struct:union?}} {{#struct:union?}} template<> constexpr ptrdiff_t unionTypeOffset<{{struct:cpp_fullname}}>() { return offsetof({{struct:cpp_fullname}}, type_); } {{/struct:union?}} {{/program:split_structs}} FOLLY_POP_WARNING }}} // apache::thrift::detail {{/program:tablebased?}} {{#program:split_structs}}{{! }}{{^program:tablebased?}} {{ > module_types_cpp/tcc_struct_traits}} {{/program:tablebased?}} {{ > module_types_cpp/frozen}} {{#struct:union?}} {{ > module_types_cpp/declare_union_types}} {{/struct:union?}} {{ > common/namespace_cpp2_begin}} {{#struct:extra_namespace}} namespace {{struct:extra_namespace}} { {{/struct:extra_namespace}} {{#struct:thrift_uri}} const char* {{struct:cpp_underlying_name}}::__fbthrift_thrift_uri() { return "{{struct:thrift_uri}}"; } {{/struct:thrift_uri}} std::string_view {{struct:cpp_underlying_name}}::__fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord) { if (ord == ::apache::thrift::FieldOrdinal{0}) { return {}; } return apache::thrift::TStructDataStorage<{{struct:cpp_underlying_name}}>::fields_names[folly::to_underlying(ord) - 1]; } std::string_view {{struct:cpp_underlying_name}}::__fbthrift_get_class_name() { return apache::thrift::TStructDataStorage<{{struct:cpp_underlying_name}}>::name; } {{^struct:union?}} {{^struct:cpp_noncopyable}} {{^struct:nondefault_copy_ctor_and_assignment?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}&) = default; {{struct:cpp_underlying_name}}& {{struct:cpp_underlying_name}}::operator=(const {{struct:cpp_underlying_name}}&) = default; {{/struct:is_eligible_for_constexpr?}} {{/struct:nondefault_copy_ctor_and_assignment?}} {{#struct:nondefault_copy_ctor_and_assignment?}} {{ > module_types_cpp/copy_ctor}} {{ > module_types_cpp/assign_overload}} {{/struct:nondefault_copy_ctor_and_assignment?}} {{/struct:cpp_noncopyable}} {{ > module_types_cpp/declare_members}} {{^struct:cpp_noncomparable}} {{ > module_types_cpp/eq_overload}} {{#struct:is_struct_orderable?}} {{ > module_types_cpp/struct_operator_less}} {{/struct:is_struct_orderable?}} {{/struct:cpp_noncomparable}} {{#struct:legacy_api?}} {{ > module_types_cpp/getters_setters}} {{/struct:legacy_api?}} {{ > module_types_cpp/swap}} {{/struct:union?}} {{#struct:union?}} {{ > module_types_cpp/union_declare_members}} {{ > module_types_cpp/union_copy_ctor}} {{^struct:cpp_noncomparable}} {{ > module_types_cpp/union_eq_overload}} {{#struct:is_struct_orderable?}} {{ > module_types_cpp/union_operator_less}} {{/struct:is_struct_orderable?}} {{/struct:cpp_noncomparable}} {{ > module_types_cpp/union_setters}} {{ > module_types_cpp/union_swap}} {{/struct:union?}} template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::BinaryProtocolReader*); template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::BinaryProtocolWriter*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::CompactProtocolReader*); template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::CompactProtocolWriter*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; {{#program:json?}} template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::SimpleJSONProtocolReader*); template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::SimpleJSONProtocolWriter*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::SimpleJSONProtocolWriter const*) const; template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::SimpleJSONProtocolWriter const*) const; {{/program:json?}} {{#program:tablebased?}} {{#struct:union?}} constexpr ::apache::thrift::detail::UnionExtN<{{struct:fields_size}}> {{struct:cpp_underlying_name}}_unionExt = { /* .clear */ ::apache::thrift::detail::clearUnion<{{struct:cpp_fullname}}>, /* .unionTypeOffset */ ::apache::thrift::detail::unionTypeOffset<{{struct:cpp_fullname}}>(), /* .getActiveId */ nullptr, /* .setActiveId */ nullptr, /* .initMember */ { {{#struct:fields_in_key_order}}{{#field:type}}::apache::thrift::detail::placementNewUnionValue<{{field:cpp_storage_type}}>{{ > common/comma_newline}}{{! }}{{/field:type}}{{/struct:fields_in_key_order}}}, }; {{/struct:union?}} constexpr ::apache::thrift::detail::StructInfoN<{{struct:fields_size}}> __fbthrift_struct_info_{{struct:cpp_underlying_name}} = { /* .numFields */ {{struct:fields_size}}, /* .name */ "{{struct:name}}",{{! }}{{#struct:union?}} /* .unionExt */ &{{struct:name}}_unionExt,{{! }}{{/struct:union?}}{{! }}{{^struct:union?}} /* .unionExt */ nullptr,{{! }}{{/struct:union?}} /* .getIsset */ nullptr, /* .setIsset */ nullptr, /* .customExt */ nullptr, /* .fieldInfos */ { {{#struct:fields_in_key_order}} { /* .id */ {{field:key}}, /* .qualifier */ {{field:tablebased_qualifier}}, /* .name */ "{{field:name}}", /* .memberOffset */ {{! }}{{#struct:union?}}0{{/struct:union?}}{{! }}{{^struct:union?}}::apache::thrift::detail::fieldOffset<{{struct:cpp_fullname}}>({{field:index}}){{/struct:union?}},{{! }}{{^struct:union?}} /* .issetOffset */ ::apache::thrift::detail::issetOffset<{{struct:cpp_fullname}}>({{field:index}}),{{! }}{{/struct:union?}}{{! }}{{#struct:union?}} /* .issetOffset */ 0,{{! }}{{/struct:union?}}{{#field:type}} /* .typeInfo */ &::apache::thrift::detail::TypeToInfo<{{type:type_class_with_indirection}}, {{field:cpp_storage_type}}>::typeInfo,{{! }}{{/field:type}} }{{ > common/comma_newline}}{{! }}{{/struct:fields_in_key_order}}} }; {{/program:tablebased?}} {{! Enforce that if this thrift file is generated with extern template instances for simple-json protocol then all its dependencies are too. }} {{#struct:fields}} {{#field:type}} {{#type:transitively_refers_to_struct?}} static_assert( ::apache::thrift::detail::st::gen_check_json< {{struct:cpp_underlying_name}}, {{type:type_class}}, {{type:cpp_type}}>, "inconsistent use of json option"); {{/type:transitively_refers_to_struct?}} {{/field:type}} {{/struct:fields}} {{#struct:extra_namespace}} } // namespace {{struct:extra_namespace}} {{/struct:extra_namespace}} {{ > common/namespace_cpp2_end}} {{/program:split_structs}}{{! }}{{! Validate adapters in typedefs and fields. }} {{ > common/namespace_cpp2_begin}} namespace { [[maybe_unused]] FOLLY_ERASE void validateAdapters() { {{#program:split_structs}}{{#struct:fields}} {{#field:cpp_first_adapter}}{{#field:type}} ::apache::thrift::adapt_detail::validateFieldAdapter<{{! }}{{field:cpp_first_adapter}}, {{field:key}}, {{type:cpp_standard_type}}, {{struct:cpp_fullname}}>(); {{/field:type}}{{/field:cpp_first_adapter}} {{/struct:fields}}{{/program:split_structs}} {{#program:typedefs}}{{#typedef:type}} {{#type:cpp_adapter}} ::apache::thrift::adapt_detail::validateAdapter<{{type:cpp_adapter}}, {{type:cpp_standard_type}}>(); {{/type:cpp_adapter}} {{/typedef:type}}{{/program:typedefs}} } }{{ > common/namespace_cpp2_end}} {{! }}{{#program:tablebased?}} namespace apache { namespace thrift { namespace detail { {{#program:split_enums}} const ::apache::thrift::detail::TypeInfo TypeToInfo< apache::thrift::type_class::enumeration, {{ > common/namespace_cpp2}}{{enum:cpp_name}}>::typeInfo = { /* .type */ apache::thrift::protocol::TType::T_I32, /* .get */ get common/namespace_cpp2}}{{enum:cpp_name}}>, /* .set */ reinterpret_cast(set<{{ > common/namespace_cpp2}}{{enum:cpp_name}}, std::int32_t>), /* .typeExt */ nullptr, }; {{/program:split_enums}} {{#program:split_structs}} const ::apache::thrift::detail::TypeInfo TypeToInfo< ::apache::thrift::type_class::{{#struct:union?}}variant{{/struct:union?}}{{^struct:union?}}structure{{/struct:union?}}, {{struct:cpp_fullname}}>::typeInfo = { /* .type */ ::apache::thrift::protocol::TType::T_STRUCT, /* .get */ nullptr, /* .set */ nullptr, /* .typeExt */ &{{ > common/namespace_cpp2 }}__fbthrift_struct_info_{{struct:cpp_underlying_name}}, }; {{/program:split_structs}} }}} // namespace apache::thrift::detail {{/program:tablebased?}} namespace apache::thrift::detail::annotation { {{#program:split_structs}} {{#struct:has_field_with_runtime_annotation?}} template<> const std::vector& field_annotation_values<{{struct:cpp_fullname}}>(FieldId id) { switch (static_cast(id)) { {{#struct:fields}} case {{field:key}}: { static const folly::Indestructible> ret = [] { std::vector values; {{#field:structured_annotations}} {{#structured_annotation:const}} {{#constant:cpp_runtime_annotation?}} {{#constant:type}}{{#constant:value}}{{#constant:field}} values.emplace_back({{ > common/iterate_const_values}}); {{/constant:field}}{{/constant:value}}{{/constant:type}} {{/constant:cpp_runtime_annotation?}} {{/structured_annotation:const}} {{/field:structured_annotations}} return values; }(); return *ret; } {{/struct:fields}} }; folly::assume_unreachable(); } {{/struct:has_field_with_runtime_annotation?}} {{/program:split_structs}} } )__FBTHRIFT_TAG__", // cpp2/module_types.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include {{#program:frozen?}} #include {{/program:frozen?}} {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{/program:thrift_includes}} {{#program:cpp_includes}} #include {{cpp_include}} {{/program:cpp_includes}} {{#program:structs?}} namespace apache { namespace thrift { namespace ident { {{#program:structs}} {{#struct:fields}} struct {{field:cpp_name}}; {{/struct:fields}} {{/program:structs}} } // namespace ident namespace detail { {{#program:structs}} {{#struct:fields}} #ifndef APACHE_THRIFT_ACCESSOR_{{field:cpp_name}} #define APACHE_THRIFT_ACCESSOR_{{field:cpp_name}} APACHE_THRIFT_DEFINE_ACCESSOR({{field:cpp_name}}); #endif {{/struct:fields}} {{/program:structs}} } // namespace detail } // namespace thrift } // namespace apache {{/program:structs?}} {{ > module_types_h/declare_enums}} {{ > module_types_h/forward_declare}} namespace apache::thrift::detail::annotation { {{#program:structs}} {{#struct:has_field_with_runtime_annotation?}} template<> const std::vector& field_annotation_values<{{struct:cpp_fullname}}>(FieldId); {{/struct:has_field_with_runtime_annotation?}} {{/program:structs}} } // namespace apache::thrift::detail::annotation namespace apache::thrift::detail::qualifier { {{#program:structs}} {{#struct:fields}} {{#field:opt_cpp_ref?}} template<> struct is_cpp_ref_field_optional<{{struct:cpp_fullname}},::apache::thrift::type::field_id<{{field:key}}>> : std::true_type{}; {{/field:opt_cpp_ref?}} {{#field:terse_cpp_ref?}} template<> struct is_cpp_ref_field_terse<{{struct:cpp_fullname}},::apache::thrift::type::field_id<{{field:key}}>> : std::true_type{}; {{/field:terse_cpp_ref?}} {{/struct:fields}} {{/program:structs}} } // namespace apache::thrift::detail::qualifier {{ > module_types_h/hash_and_equal_to}} {{ > common/namespace_cpp2_begin}} {{#program:structs}} {{#struct:is_directly_adapted?}} {{^struct:dependent_direct_adapter?}} using {{struct:cpp_name}} = {{struct:cpp_underlying_type}}; {{/struct:dependent_direct_adapter?}} {{/struct:is_directly_adapted?}} {{/program:structs}} using ::apache::thrift::detail::operator!=; using ::apache::thrift::detail::operator>; using ::apache::thrift::detail::operator<=; using ::apache::thrift::detail::operator>=; {{#program:structs_and_typedefs}} {{^is_struct?}} typedef {{typedef:cpp_type}} {{typedef:name}}; {{/is_struct?}} {{#is_struct?}} {{#struct:extra_namespace}} namespace {{struct:extra_namespace}} { {{/struct:extra_namespace}} class {{#struct:exception?}}FOLLY_EXPORT {{/struct:exception?}}{{struct:cpp_underlying_name}} {{! }}{{^struct:exception?}}{{^struct:virtual}}final {{/struct:virtual}}{{/struct:exception?}}{{! }}{{#struct:exception?}}: public virtual apache::thrift::TException{{/struct:exception?}} { private: friend struct ::apache::thrift::detail::st::struct_private_access; template friend struct ::apache::thrift::detail::invoke_reffer; // used by a static_assert in the corresponding source static constexpr bool __fbthrift_cpp2_gen_json = {{program:json?}}; static constexpr bool __fbthrift_cpp2_is_runtime_annotation = {{struct:cpp_runtime_annotation?}}; {{#struct:thrift_uri}} static const char* __fbthrift_thrift_uri(); {{/struct:thrift_uri}} {{#struct:patch?}} using __fbthrift_safe_patch = {{struct:cpp_underlying_name}}SafePatch; using __fbthrift_patch_struct = {{struct:cpp_underlying_name}}PatchStruct; {{/struct:patch?}} static std::string_view __fbthrift_get_field_name(::apache::thrift::FieldOrdinal ord); static std::string_view __fbthrift_get_class_name(); {{ > module_types_h/reflection}} void __fbthrift_clear(); {{^struct:union?}} void __fbthrift_clear_terse_fields(); {{/struct:union?}} {{#struct:union?}} void __fbthrift_destruct(); {{/struct:union?}} bool __fbthrift_is_empty() const; {{#struct:exception?}} static constexpr ::apache::thrift::ExceptionKind __fbthrift_cpp2_gen_exception_kind = ::apache::thrift::ExceptionKind::{{struct:exception_kind}}; static constexpr ::apache::thrift::ExceptionSafety __fbthrift_cpp2_gen_exception_safety = ::apache::thrift::ExceptionSafety::{{struct:exception_safety}}; static constexpr ::apache::thrift::ExceptionBlame __fbthrift_cpp2_gen_exception_blame = ::apache::thrift::ExceptionBlame::{{struct:exception_blame}}; {{/struct:exception?}} public: {{#struct:cpp_trivially_relocatable}} using IsRelocatable = std::true_type; {{/struct:cpp_trivially_relocatable}} using __fbthrift_cpp2_type = {{struct:cpp_underlying_name}}; static constexpr bool __fbthrift_cpp2_is_union = {{#struct:union?}}true{{/struct:union?}}{{^struct:union?}}false{{/struct:union?}}; {{#struct:cpp_allocator}} public: using allocator_type = {{struct:cpp_allocator}}; allocator_type get_allocator() const { {{#struct:cpp_allocator_via}} return this->{{struct:cpp_allocator_via}}.get_allocator(); {{/struct:cpp_allocator_via}} {{^struct:cpp_allocator_via}} return __fbthrift_alloc; {{/struct:cpp_allocator_via}} } {{^struct:cpp_allocator_via}} private: FOLLY_ATTR_NO_UNIQUE_ADDRESS allocator_type __fbthrift_alloc; {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} public: {{#struct:union?}} {{ > module_types_h/union_enum}} {{struct:cpp_underlying_name}}() : type_(folly::to_underlying(Type::__EMPTY__)) {} {{ > module_types_h/union_copy_ctor}} {{ > module_types_h/union_assign_overload}} {{^struct:is_trivially_destructible?}} {{#struct:virtual}}virtual {{/struct:virtual}}~{{struct:cpp_underlying_name}}(); {{/struct:is_trivially_destructible?}} {{ > module_types_h/union_storage}} {{^struct:cpp_noncomparable}} bool operator==(const {{struct:cpp_underlying_name}}&) const; bool operator<(const {{struct:cpp_underlying_name}}&) const; {{/struct:cpp_noncomparable}} {{ > module_types_h/union_setters}} {{ > module_types_h/union_getters}} {{ > module_types_h/union_mutables}} {{ > module_types_h/union_moves}} {{ > module_types_h/union_field_ref}} Type getType() const { return static_cast(type_); } template unsigned long read(Protocol_* iprot); template uint32_t serializedSize(Protocol_ const* prot_) const; template uint32_t serializedSizeZC(Protocol_ const* prot_) const; template uint32_t write(Protocol_* prot_) const; protected: storage_type value_; std::underlying_type_t type_; {{/struct:union?}} {{^struct:union?}} {{#struct:is_large?}} {{struct:cpp_underlying_name}}(); {{#struct:message}} explicit {{struct:cpp_underlying_name}}(std::string __message); {{/struct:message}} {{/struct:is_large?}} {{^struct:is_large?}} {{ > module_types_h/base_ctor}} {{/struct:is_large?}} {{#struct:legacy_api?}} // FragileConstructor for use in initialization lists only. [[deprecated("This constructor is deprecated")]] {{struct:cpp_underlying_name}}(apache::thrift::FragileConstructor{{ > module_types_h/fragile_ctor_param_list}}); {{/struct:legacy_api?}} {{#struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}({{struct:cpp_underlying_name}}&&) = default; {{/struct:is_eligible_for_constexpr?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}({{struct:cpp_underlying_name}}&&) noexcept; {{/struct:is_eligible_for_constexpr?}} {{^struct:cpp_noncopyable}} {{^struct:nondefault_copy_ctor_and_assignment?}} {{#struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}&) = default; {{/struct:is_eligible_for_constexpr?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& src); {{/struct:is_eligible_for_constexpr?}} {{/struct:nondefault_copy_ctor_and_assignment?}} {{#struct:nondefault_copy_ctor_and_assignment?}} {{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& src); {{/struct:nondefault_copy_ctor_and_assignment?}} {{/struct:cpp_noncopyable}} {{#struct:cpp_allocator}} {{ > module_types_h/alloc_extended_ctors}} {{/struct:cpp_allocator}} {{#struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}& operator=({{struct:cpp_underlying_name}}&&) = default; {{/struct:is_eligible_for_constexpr?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}& operator=({{struct:cpp_underlying_name}}&&) noexcept; {{/struct:is_eligible_for_constexpr?}} {{^struct:cpp_noncopyable}} {{^struct:nondefault_copy_ctor_and_assignment?}} {{#struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}& operator=(const {{struct:cpp_underlying_name}}&) = default; {{/struct:is_eligible_for_constexpr?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}& operator=(const {{struct:cpp_underlying_name}}& src); {{/struct:is_eligible_for_constexpr?}} {{/struct:nondefault_copy_ctor_and_assignment?}} {{#struct:nondefault_copy_ctor_and_assignment?}} {{struct:cpp_underlying_name}}& operator=(const {{struct:cpp_underlying_name}}& src); {{/struct:nondefault_copy_ctor_and_assignment?}} {{/struct:cpp_noncopyable}} {{^struct:virtual}} {{#struct:is_large?}} ~{{struct:cpp_underlying_name}}(){{#struct:exception?}} override{{/struct:exception?}}; {{/struct:is_large?}} {{/struct:virtual}} {{#struct:virtual}} {{^struct:is_large?}} {{^struct:exception?}}virtual{{/struct:exception?}} ~{{struct:cpp_underlying_name}}() {{#struct:exception?}} override{{/struct:exception?}}{} {{/struct:is_large?}} {{#struct:is_large?}} {{^struct:exception?}}virtual{{/struct:exception?}} ~{{struct:cpp_underlying_name}}() {{#struct:exception?}} override{{/struct:exception?}}; {{/struct:is_large?}} {{/struct:virtual}} {{#struct:fields?}} {{ > module_types_h/declare_members}} {{/struct:fields?}} public: {{^struct:cpp_noncomparable}} bool operator==(const {{struct:cpp_underlying_name}}&) const; bool operator<(const {{struct:cpp_underlying_name}}&) const; {{/struct:cpp_noncomparable}} {{#struct:fields?}} {{ > module_types_h/field_ref}} {{#struct:legacy_api?}} {{ > module_types_h/getters_setters}} {{/struct:legacy_api?}} {{/struct:fields?}} template unsigned long read(Protocol_* iprot); template uint32_t serializedSize(Protocol_ const* prot_) const; template uint32_t serializedSizeZC(Protocol_ const* prot_) const; template uint32_t write(Protocol_* prot_) const; {{#struct:exception?}} const char* what() const noexcept override { {{#struct:message}} return {{struct:message}}.c_str(); {{/struct:message}} {{^struct:message}} return "{{struct:cpp_fullname}}"; {{/struct:message}} } {{/struct:exception?}} {{/struct:union?}} {{#struct:cpp_methods}} // user defined code (cpp2.methods = ...) {{struct:cpp_methods}} {{/struct:cpp_methods}} private: {{ > module_types_h/lazy_deserialization}} template void readNoXfer(Protocol_* iprot); friend class ::apache::thrift::Cpp2Ops<{{struct:cpp_underlying_name}}>; friend void swap({{struct:cpp_underlying_name}}& a, {{struct:cpp_underlying_name}}& b); {{#program:tablebased?}} {{^struct:union?}} friend constexpr ptrdiff_t (::apache::thrift::detail::fieldOffset<{{struct:cpp_underlying_name}}>)(std::int16_t fieldIndex); friend constexpr ptrdiff_t (::apache::thrift::detail::issetOffset<{{struct:cpp_underlying_name}}>)(std::int16_t fieldIndex); {{/struct:union?}} {{#struct:union?}} friend constexpr ptrdiff_t (::apache::thrift::detail::unionTypeOffset<{{struct:cpp_underlying_name}}>)(); {{/struct:union?}} {{/program:tablebased?}} }; template unsigned long {{struct:cpp_underlying_name}}::read(Protocol_* iprot) { auto _xferStart = iprot->getCursorPosition(); readNoXfer(iprot); return iprot->getCursorPosition() - _xferStart; } {{#struct:extra_namespace}} } // namespace {{struct:extra_namespace}} {{/struct:extra_namespace}} {{#struct:is_directly_adapted?}} {{#struct:dependent_direct_adapter?}} using {{struct:cpp_name}} = {{struct:cpp_underlying_type}}; {{/struct:dependent_direct_adapter?}} {{/struct:is_directly_adapted?}} {{/is_struct?}} {{/program:structs_and_typedefs}} {{ > common/namespace_cpp2_end}} {{#program:frozen?}}{{#program:structs}} {{ > module_types_h/frozen}} {{/program:structs}}{{/program:frozen?}} {{ > module_types_h/declare_union_types}}{{! }}{{#program:tablebased?}} namespace apache { namespace thrift { namespace detail { {{#program:structs}} template <> struct TypeToInfo< ::apache::thrift::type_class::{{#struct:union?}}variant{{/struct:union?}}{{^struct:union?}}structure{{/struct:union?}}, {{struct:cpp_fullname}}> { static const ::apache::thrift::detail::TypeInfo typeInfo; }; {{/program:structs}} {{#program:enums}} template <> struct TypeToInfo< ::apache::thrift::type_class::enumeration, {{ > common/namespace_cpp2}}{{enum:cpp_name}}> { static const ::apache::thrift::detail::TypeInfo typeInfo; }; {{/program:enums}} }}} // namespace apache::thrift::detail {{/program:tablebased?}} )__FBTHRIFT_TAG__", // cpp2/module_types.tcc.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_types.h" #include {{^program:tablebased?}} {{ > module_types_tcc/tcc_struct_traits}} {{/program:tablebased?}} {{ > common/namespace_cpp2_begin}} {{#program:structs}} {{#struct:extra_namespace}} namespace {{struct:extra_namespace}} { {{/struct:extra_namespace}} {{#program:tablebased?}} extern const ::apache::thrift::detail::StructInfoN<{{struct:fields_size}}> __fbthrift_struct_info_{{struct:cpp_underlying_name}}; {{/program:tablebased?}} {{^struct:union?}} {{ > module_types_tcc/deserialize_struct}} {{ > module_types_tcc/serialize_struct}} {{/struct:union?}} {{#struct:union?}} {{ > module_types_tcc/union_setters}} {{ > module_types_tcc/deserialize_union}} {{ > module_types_tcc/serialize_union}} {{/struct:union?}} extern template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::BinaryProtocolReader*); extern template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::BinaryProtocolWriter*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; extern template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::CompactProtocolReader*); extern template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::CompactProtocolWriter*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; {{#program:json?}} extern template void {{struct:cpp_underlying_name}}::readNoXfer<>(apache::thrift::SimpleJSONProtocolReader*); extern template uint32_t {{struct:cpp_underlying_name}}::write<>(apache::thrift::SimpleJSONProtocolWriter*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSize<>(apache::thrift::SimpleJSONProtocolWriter const*) const; extern template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC<>(apache::thrift::SimpleJSONProtocolWriter const*) const; {{/program:json?}} {{#struct:extra_namespace}} } // namespace {{struct:extra_namespace}} {{/struct:extra_namespace}} {{/program:structs}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/assign_overload.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}static void __fbthrift_swap({{struct:cpp_underlying_name}}& lhs, {{struct:cpp_underlying_name}}& rhs) { swap(lhs, rhs); } {{struct:cpp_underlying_name}}& {{struct:cpp_underlying_name}}::operator=(const {{struct:cpp_underlying_name}}& other) { {{struct:cpp_underlying_name}} tmp(other{{#struct:cpp_allocator}}, get_allocator(){{/struct:cpp_allocator}}); __fbthrift_swap(*this, tmp); {{#struct:cpp_allocator}} {{^struct:cpp_allocator_via}} ::apache::thrift::detail::copy_allocator(__fbthrift_alloc, other.__fbthrift_alloc); {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} return *this; } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/clear_fields.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type}}{{#type:resolves_to_base_or_enum?}}{{! }}{{^field:cpp_ref?}}{{! }}{{#field:cpp_first_adapter}}{{! }} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>({{field:cpp_storage_name}}, *this);{{! }}{{/field:cpp_first_adapter}}{{! }}{{^field:cpp_first_adapter}}{{! TODO(dokwon): Replace special cases after replacing StringTraits and cpp.indirection with cpp.adapter. }} {{ > types/apply_indirection_pre}}{{ > field/member}}{{ > types/apply_indirection_post}} = {{! }}{{#field:deprecated_clear?}}{{ > field/default}};{{/field:deprecated_clear?}}{{! }}{{^field:deprecated_clear?}}{{ > field/intrinsic_default}};{{/field:deprecated_clear?}}{{! }}{{/field:cpp_first_adapter}}{{! }}{{/field:cpp_ref?}}{{! }}{{#field:cpp_ref?}}{{! }}{{^field:optional?}}{{! }}{{#field:cpp_ref_not_boxed?}}{{! }} {{ > field/member}} = ::apache::thrift::detail::make_mutable_smart_ptr<{{field:cpp_storage_type}}>({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}});{{! }}{{/field:cpp_ref_not_boxed?}}{{! }}{{#field:boxed_ref?}}{{! }}{{#field:cpp_first_adapter}}{{! }} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>(*{{field:cpp_storage_name}}, *this);{{! }}{{/field:cpp_first_adapter}}{{! }}{{^field:cpp_first_adapter}}{{! }} {{ > field/member}} = {{ > field/default}};{{! }}{{/field:cpp_first_adapter}}{{! }}{{/field:boxed_ref?}}{{! }}{{#field:intern_boxed_ref?}}{{! }} {{ > field/member}} = {{field:cpp_storage_type}}::fromStaticConstant(&::apache::thrift::op::getIntrinsicDefault<{{ > field/tag}}>());{{! }}{{/field:intern_boxed_ref?}}{{! }}{{/field:optional?}}{{! }}{{#field:optional?}}{{! }} {{ > field/member}}.reset();{{! }}{{/field:optional?}}{{! }}{{/field:cpp_ref?}} {{/type:resolves_to_base_or_enum?}} {{#type:resolves_to_container?}} {{#field:cpp_first_adapter}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>({{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} {{#field:cpp_ref?}} {{^field:optional?}} {{#field:cpp_ref_not_boxed?}} {{ > field/member}} = ::apache::thrift::detail::make_mutable_smart_ptr<{{field:cpp_storage_type}}>({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}}); {{/field:cpp_ref_not_boxed?}} {{#field:boxed_ref?}} {{#field:cpp_first_adapter}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>(*{{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} {{ > field/member}} = {{ > field/default}}; {{/field:cpp_first_adapter}} {{/field:boxed_ref?}} {{#field:intern_boxed_ref?}} {{ > field/member}} = {{field:cpp_storage_type}}::fromStaticConstant(&::apache::thrift::op::getIntrinsicDefault<{{ > field/tag}}>()); {{/field:intern_boxed_ref?}} {{/field:optional?}} {{#field:optional?}} {{ > field/member}}.reset(); {{/field:optional?}} {{/field:cpp_ref?}} {{^field:cpp_ref?}} {{ > field/member}}.clear(); {{/field:cpp_ref?}} {{/field:cpp_first_adapter}} {{/type:resolves_to_container?}} {{#type:non_empty_struct?}} {{^field:cpp_ref?}} {{#field:cpp_first_adapter}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>({{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} ::apache::thrift::clear({{ > field/member}}); {{/field:cpp_first_adapter}} {{/field:cpp_ref?}} {{#field:cpp_ref?}} {{^field:optional?}} {{#field:cpp_ref_unique?}} if ({{ > field/member}}) ::apache::thrift::clear(*{{ > field/member}}); {{/field:cpp_ref_unique?}} {{^field:cpp_ref_unique?}} {{#field:cpp_ref_not_boxed?}} if ({{ > field/member}}) {{ > field/member}} = ::apache::thrift::detail::make_mutable_smart_ptr<{{field:cpp_storage_type}}>({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}}); {{/field:cpp_ref_not_boxed?}} {{#field:boxed_ref?}} {{#field:cpp_first_adapter}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>(*{{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} {{ > field/member}} = {{ > field/default}}; {{/field:cpp_first_adapter}} {{/field:boxed_ref?}} {{#field:intern_boxed_ref?}} {{ > field/member}} = {{field:cpp_storage_type}}::fromStaticConstant(&::apache::thrift::op::getIntrinsicDefault<{{ > field/tag}}>()); {{/field:intern_boxed_ref?}} {{/field:cpp_ref_unique?}} {{/field:optional?}} {{#field:optional?}} {{ > field/member}}.reset(); {{/field:optional?}} {{/field:cpp_ref?}} {{/type:non_empty_struct?}} {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/clear_terse_fields.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! For all terse fields except for a terse struct field, they are cleared to their intrinsic default values. For a terse struct fields, only nested terse fields are cleared to their instrinic default values. }}{{#field:type}} {{#type:resolves_to_base_or_enum?}} {{ > module_types_cpp/clear_fields}} {{/type:resolves_to_base_or_enum?}} {{#type:resolves_to_container?}} {{ > module_types_cpp/clear_fields}} {{/type:resolves_to_container?}} {{#type:non_empty_struct?}} {{^field:cpp_ref?}} {{#field:cpp_first_adapter}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>({{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} {{#type:union?}} {{ > module_types_cpp/clear_fields}} {{/type:union?}} {{^type:union?}} ::apache::thrift::detail::st::clear_terse_fields({{ > field/member}}); {{/type:union?}} {{/field:cpp_first_adapter}} {{/field:cpp_ref?}} {{#field:cpp_ref?}} {{#field:cpp_ref_unique?}} if ({{ > field/member}}) ::apache::thrift::detail::st::clear_terse_fields(*{{ > field/member}}); {{/field:cpp_ref_unique?}} {{^field:cpp_ref_unique?}} {{#field:cpp_ref_not_boxed?}} if ({{ > field/member}}) {{ > field/member}} = ::apache::thrift::detail::make_mutable_smart_ptr<{{field:cpp_storage_type}}>({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}}); {{/field:cpp_ref_not_boxed?}} {{^field:cpp_ref_not_boxed?}} {{ > module_types_cpp/clear_fields}} {{/field:cpp_ref_not_boxed?}} {{/field:cpp_ref_unique?}} {{/field:cpp_ref?}} {{/type:non_empty_struct?}} {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/copy_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& srcObj){{! }}{{^struct:fields?}}{}{{/struct:fields?}}{{! }}{{#struct:fields?}} : {{#struct:cpp_allocator}} {{^struct:cpp_allocator_via}} __fbthrift_alloc(srcObj.__fbthrift_alloc), {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} {{#struct:fields_in_layout_order}} {{^field:transitively_refers_to_unique?}} {{field:cpp_storage_name}}(srcObj.{{field:cpp_storage_name}}){{^last?}}, {{/last?}}{{! }}{{/field:transitively_refers_to_unique?}} {{#field:transitively_refers_to_unique?}} {{field:cpp_storage_name}}(::apache::thrift::detail::st::copy_field< {{#field:type}}{{type:type_class}}{{/field:type}}>(srcObj.{{field:cpp_storage_name}})){{^last?}}, {{/last?}}{{! }}{{/field:transitively_refers_to_unique?}}{{! }}{{#last?}}{{#struct:isset_fields?}},{{/struct:isset_fields?}}{{/last?}}{{! }}{{/struct:fields_in_layout_order}}{{! }}{{#struct:isset_fields?}} __isset(srcObj.__isset){{! }}{{/struct:isset_fields?}} { {{#struct:lazy_fields?}} const auto relaxed = std::memory_order_relaxed; auto lock = folly::make_shared_lock(srcObj.__fbthrift_deserializationMutex_); __fbthrift_protocol_ = srcObj.__fbthrift_protocol_; {{/struct:lazy_fields?}} {{#struct:fields}} {{#field:lazy?}} { const auto isDeserialized = srcObj.__fbthrift_isDeserialized_.{{field:cpp_name}}.load(relaxed); __fbthrift_isDeserialized_.{{field:cpp_name}}.store(isDeserialized, relaxed); {{^field:lazy_ref?}} __fbthrift_serializedData_.{{field:cpp_name}} = srcObj.__fbthrift_serializedData_.{{field:cpp_name}}; {{/field:lazy_ref?}} {{#field:lazy_ref?}} if (const auto& src = srcObj.__fbthrift_serializedData_.{{field:cpp_name}}) { __fbthrift_serializedData_.{{field:cpp_name}} = src->clone(); } {{/field:lazy_ref?}} } {{/field:lazy?}} {{/struct:fields}} {{#struct:fields}} {{#field:cpp_first_adapter}} {{#field:opt_cpp_ref?}}if ({{field:cpp_storage_name}}) {{/field:opt_cpp_ref?}}::apache::thrift::adapt_detail::construct<{{field:cpp_first_adapter}}, {{field:key}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{/struct:fields}} }{{/struct:fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/declare_enums.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#program:split_enums}} namespace apache { namespace thrift { folly::Range<{{ > common/namespace_cpp2}}{{enum:cpp_name}} const*> const TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::values = {{! }}{{#enum:empty?}}{{! }}{};{{! }}{{/enum:empty?}}{{! }}{{^enum:empty?}}{{! }}folly::range(TEnumDataStorage<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::values);{{! }}{{/enum:empty?}} folly::Range const TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::names = {{! }}{{#enum:empty?}}{{! }}{};{{! }}{{/enum:empty?}}{{! }}{{^enum:empty?}}{{! }}folly::range(TEnumDataStorage<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::names);{{! }}{{/enum:empty?}} bool TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::findName(type value, std::string_view* out) noexcept { return ::apache::thrift::detail::st::enum_find_name(value, out); } bool TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>::findValue(std::string_view name, type* out) noexcept { return ::apache::thrift::detail::st::enum_find_value(name, out); } }} // apache::thrift {{/program:split_enums}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/declare_members.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:is_large?}} {{struct:cpp_underlying_name}}::{{ > module_types_h/base_ctor}} {{#struct:message}} {{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(std::string __message) : {{struct:cpp_underlying_name}}() { {{struct:message}} = std::move(__message); } {{/struct:message}} {{struct:cpp_underlying_name}}::~{{struct:cpp_underlying_name}}() {} {{/struct:is_large?}} {{^struct:is_eligible_for_constexpr?}} {{struct:cpp_underlying_name}}::{{ > module_types_cpp/move_ctor}} {{struct:cpp_underlying_name}}& {{struct:cpp_underlying_name}}::operator=([[maybe_unused]] {{struct:cpp_underlying_name}}&& other) noexcept { {{#struct:lazy_fields?}} const auto relaxed = std::memory_order_relaxed; __fbthrift_protocol_ = other.__fbthrift_protocol_; __fbthrift_serializedData_ = std::move(other.__fbthrift_serializedData_); {{/struct:lazy_fields?}} {{#struct:fields_in_layout_order}} this->{{field:cpp_storage_name}} = std::move(other.{{field:cpp_storage_name}}); {{#field:lazy?}} { const auto isDeserialized = other.__fbthrift_isDeserialized_.{{field:cpp_name}}.load(relaxed); __fbthrift_isDeserialized_.{{field:cpp_name}}.store(isDeserialized, relaxed); other.__fbthrift_isDeserialized_.{{field:cpp_name}}.store(isDeserialized | ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED, relaxed); } {{/field:lazy?}} {{/struct:fields_in_layout_order}} {{#struct:isset_fields?}} __isset = other.__isset; {{/struct:isset_fields?}} {{#struct:cpp_allocator}} {{^struct:cpp_allocator_via}} ::apache::thrift::detail::move_allocator(__fbthrift_alloc, other.__fbthrift_alloc); {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} return *this; } {{/struct:is_eligible_for_constexpr?}} {{#struct:legacy_api?}} {{ > module_types_cpp/fragile_ctor}} {{/struct:legacy_api?}} {{ > module_types_cpp/lazy_deserialization}} void {{struct:cpp_underlying_name}}::__fbthrift_clear() { // clear all fields {{#struct:fields}}{{ > module_types_cpp/clear_fields}}{{/struct:fields}} {{#struct:lazy_fields?}} __fbthrift_serializedData_ = {}; __fbthrift_isDeserialized_.~__fbthrift_IsDeserialized(); new (&__fbthrift_isDeserialized_) __fbthrift_IsDeserialized(); {{/struct:lazy_fields?}} {{#struct:isset_fields?}} __isset = {}; {{/struct:isset_fields?}} } void {{struct:cpp_underlying_name}}::__fbthrift_clear_terse_fields() { {{#struct:fields}}{{#field:terse?}}{{ > module_types_cpp/clear_terse_fields}}{{/field:terse?}}{{/struct:fields}} } bool {{struct:cpp_underlying_name}}::__fbthrift_is_empty() const { {{^struct:has_non_optional_and_non_terse_field?}} {{#struct:fields?}} return{{#struct:fields}}{{#field:type}}{{! }}{{#field:optional?}} !({{ > module_types_tcc/optional_has_value}}){{^last?}} &&{{/last?}}{{/field:optional?}}{{! }}{{#field:deprecated_terse_writes?}} !({{ > module_types_tcc/deprecated_terse_has_value }}){{^last?}} &&{{/last?}}{{/field:deprecated_terse_writes?}}{{! }}{{#field:terse?}} {{ > module_types_tcc/terse_has_no_value }}{{^last?}} &&{{/last?}}{{/field:terse?}}{{! }}{{#last?}};{{/last?}} {{/field:type}}{{/struct:fields}} {{/struct:fields?}} {{^struct:fields?}} return true; {{/struct:fields?}} {{/struct:has_non_optional_and_non_terse_field?}} {{#struct:has_non_optional_and_non_terse_field?}} return false; {{/struct:has_non_optional_and_non_terse_field?}} } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/declare_union_types.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} namespace apache { namespace thrift { folly::Range<{{struct:cpp_fullname}}::Type const*> const TEnumTraits<{{struct:cpp_fullname}}::Type>::values = {{! }}folly::range(TEnumDataStorage<{{struct:cpp_fullname}}::Type>::values); folly::Range const TEnumTraits<{{struct:cpp_fullname}}::Type>::names = {{! }}folly::range(TEnumDataStorage<{{struct:cpp_fullname}}::Type>::names); bool TEnumTraits<{{struct:cpp_fullname}}::Type>::findName(type value, std::string_view* out) noexcept { return ::apache::thrift::detail::st::enum_find_name(value, out); } bool TEnumTraits<{{struct:cpp_fullname}}::Type>::findValue(std::string_view name, type* out) noexcept { return ::apache::thrift::detail::st::enum_find_value(name, out); } }} // apache::thrift )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/eq_overload.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} bool {{struct:cpp_underlying_name}}::operator==([[maybe_unused]] const {{struct:cpp_underlying_name}}& rhs) const { return ::apache::thrift::op::detail::StructEquality{}(*this, rhs); } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/field_value_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! For the Thrift field foo this generates: foo().value() if it's non-optional and foo().value_unchecked() otherwise. }}{{! }}{{^field:cpp_ref?}}{{! }}{{#field:optional?}}{{! }}{{field:cpp_name}}_ref().value_unchecked(){{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{! }}{{field:cpp_name}}_ref().value(){{! }}{{/field:optional?}}{{! }}{{/field:cpp_ref?}}{{! }}{{#field:cpp_ref?}}{{! }}{{field:cpp_storage_name}}{{! }}{{/field:cpp_ref?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/fragile_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^struct:fields?}} {{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(apache::thrift::FragileConstructor) {} {{/struct:fields?}} {{#struct:fields?}} {{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(apache::thrift::FragileConstructor{{ > module_types_h/fragile_ctor_param_list}}) : {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}(std::move({{field:cpp_name}}__arg)){{#last?}} { {{/last?}}{{^last?}},{{/last?}} {{/struct:fields_in_layout_order}} {{#struct:fields}} {{#field:cpp_first_adapter}} {{#field:opt_cpp_ref?}}if ({{field:cpp_storage_name}}) {{/field:opt_cpp_ref?}}::apache::thrift::adapt_detail::construct<{{field:cpp_first_adapter}}, {{field:key}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{/struct:fields}} {{#struct:isset_fields}} __isset.set(folly::index_constant<{{field:index}}>(), true); {{/struct:isset_fields}} } {{/struct:fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/frozen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#program:frozen?}} namespace apache { namespace thrift { template<> size_t Freezer<{{struct:cpp_fullname}}, void>::extraSizeImpl( [[maybe_unused]] const Freezer<{{struct:cpp_fullname}}, void>::ThawedType& src) { return 0{{! }}{{#struct:fields}}{{! }}{{#field:type}}{{! }}{{^type:bool?}} + extraSize(src.{{ > module_types_cpp/field_value_ref}}){{! }}{{/type:bool?}}{{! }}{{/field:type}}{{! }}{{/struct:fields}}; } template<> void Freezer<{{struct:cpp_fullname}}, void>::freezeImpl( [[maybe_unused]] const Freezer<{{struct:cpp_fullname}}, void>::ThawedType& src, [[maybe_unused]] Freezer<{{struct:cpp_fullname}}, void>::FrozenType& dst, [[maybe_unused]] byte*& buffer) { {{#struct:fields}} {{#field:type}} {{#type:bool?}} dst.{{field:cpp_name}} = src.{{ > module_types_cpp/field_value_ref}}; {{/type:bool?}} {{^type:bool?}} freeze(src.{{ > module_types_cpp/field_value_ref}}, dst.{{field:cpp_name}}, buffer); {{/type:bool?}} {{^field:required?}} {{^field:cpp_ref?}} dst.__isset.{{field:cpp_name}} = src.{{field:cpp_name}}_ref().has_value(); {{/field:cpp_ref?}} {{/field:required?}} {{/field:type}} {{/struct:fields}} } template<> void Freezer<{{struct:cpp_fullname}}, void>::thawImpl( [[maybe_unused]] const Freezer<{{struct:cpp_fullname}}, void>::FrozenType& src, [[maybe_unused]] Freezer<{{struct:cpp_fullname}}, void>::ThawedType& dst) { {{#struct:fields}} {{#field:type}} {{#type:bool?}} dst.{{field:cpp_name}}_ref() = src.{{field:cpp_name}}; {{/type:bool?}} {{^type:bool?}} thaw(src.{{field:cpp_name}}, dst.{{field:cpp_name}}_ref(){{^field:cpp_ref?}}.ensure(){{/field:cpp_ref?}}); {{/type:bool?}} {{^field:required?}} {{^field:cpp_ref?}} if (!src.__isset.{{field:cpp_name}}) { ::apache::thrift::unset_unsafe_deprecated(dst.{{field:cpp_name}}_ref()); } {{/field:cpp_ref?}} {{/field:required?}} {{/field:type}} {{/struct:fields}} } }} // apache::thrift {{/program:frozen?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/getters_setters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields?}}{{#struct:fields}}{{#field:type}}{{#type:resolves_to_container_or_struct?}} {{#field:has_deprecated_accessors?}} {{#field:optional?}} const {{type:cpp_type}}* {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() const& { return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{type:cpp_type}}* {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() & { return {{field:cpp_name}}_ref().has_value() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{/field:optional?}} {{^field:optional?}} const {{type:cpp_type}}& {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() const& { return {{field:cpp_storage_name}}; } {{type:cpp_type}} {{struct:cpp_underlying_name}}::get_{{field:cpp_name}}() && { return std::move({{field:cpp_storage_name}}); } {{/field:optional?}} {{/field:has_deprecated_accessors?}} {{/type:resolves_to_container_or_struct?}}{{/field:type}}{{/struct:fields}}{{/struct:fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/lazy_deserialization.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:lazy_fields?}} {{#struct:fields}} {{#field:type}} {{#field:lazy?}} const {{field:cpp_storage_type}}& {{struct:cpp_underlying_name}}::__fbthrift_read_field_{{field:cpp_name}}() const { const auto isDeserialized = __fbthrift_isDeserialized_.{{field:cpp_name}}.load(std::memory_order_relaxed); if (!(isDeserialized & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED)) { __fbthrift_read_field_{{field:cpp_name}}_slow(); } return {{field:cpp_storage_name}}; } {{field:cpp_storage_type}}& {{struct:cpp_underlying_name}}::__fbthrift_read_field_{{field:cpp_name}}() { const auto isDeserialized = __fbthrift_isDeserialized_.{{field:cpp_name}}.load(std::memory_order_relaxed); if (!(isDeserialized & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED)) { __fbthrift_read_field_{{field:cpp_name}}_slow(); } else if (isDeserialized & ::apache::thrift::detail::LazyDeserializationState::UNTAINTED) { __fbthrift_isDeserialized_.{{field:cpp_name}} = ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED; } return {{field:cpp_storage_name}}; } void {{struct:cpp_underlying_name}}::__fbthrift_read_field_{{field:cpp_name}}_slow() const { auto lock = folly::make_unique_lock(__fbthrift_deserializationMutex_); if (__fbthrift_isDeserialized_.{{field:cpp_name}} & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED) { return; } switch (__fbthrift_protocol_) { case ::apache::thrift::protocol::T_COMPACT_PROTOCOL: __fbthrift_read_field_{{field:cpp_name}}_impl<::apache::thrift::CompactProtocolReader>(); break; case ::apache::thrift::protocol::T_BINARY_PROTOCOL: __fbthrift_read_field_{{field:cpp_name}}_impl<::apache::thrift::BinaryProtocolReader>(); break; default: CHECK(false) << int(__fbthrift_protocol_); } __fbthrift_serializedData_.{{field:cpp_name}} = {}; __fbthrift_isDeserialized_.{{field:cpp_name}} = ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED; } {{/field:lazy?}} {{/field:type}} {{/struct:fields}} {{/struct:lazy_fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/move_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{struct:cpp_underlying_name}}([[maybe_unused]] {{struct:cpp_underlying_name}}&& other) noexcept{{! }}{{^struct:fields?}}{}{{/struct:fields?}}{{! }}{{#struct:fields?}} : {{#struct:cpp_allocator}} {{^struct:cpp_allocator_via}} __fbthrift_alloc(std::move(other.__fbthrift_alloc)), {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}(std::move(other.{{field:cpp_storage_name}})){{^last?}}, {{/last?}}{{! }}{{#last?}}{{#struct:isset_fields?}},{{/struct:isset_fields?}}{{! }}{{^struct:isset_fields?}}{{#struct:lazy_fields?}},{{/struct:lazy_fields?}}{{! }}{{/struct:isset_fields?}}{{! }}{{/last?}}{{! }}{{/struct:fields_in_layout_order}}{{! }}{{#struct:isset_fields?}} __isset(other.__isset){{#struct:lazy_fields?}},{{/struct:lazy_fields?}}{{! }}{{/struct:isset_fields?}}{{! }}{{#struct:lazy_fields?}} __fbthrift_serializedData_(std::move(other.__fbthrift_serializedData_)), __fbthrift_protocol_(other.__fbthrift_protocol_){{! }}{{/struct:lazy_fields?}} { {{#struct:fields}} {{#field:cpp_first_adapter}} {{#field:opt_cpp_ref?}}if ({{field:cpp_storage_name}}) {{/field:opt_cpp_ref?}}::apache::thrift::adapt_detail::construct<{{field:cpp_first_adapter}}, {{field:key}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{field:cpp_storage_name}}, *this); {{/field:cpp_first_adapter}} {{/struct:fields}} {{#struct:lazy_fields?}} const auto relaxed = std::memory_order_relaxed; {{#struct:fields}}{{#field:lazy?}} { const auto isDeserialized = other.__fbthrift_isDeserialized_.{{field:cpp_name}}.load(relaxed); __fbthrift_isDeserialized_.{{field:cpp_name}}.store(isDeserialized, relaxed); other.__fbthrift_isDeserialized_.{{field:cpp_name}}.store(isDeserialized | ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED, relaxed); } {{/field:lazy?}}{{/struct:fields}} {{/struct:lazy_fields?}} } {{/struct:fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/struct_operator_less.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} bool {{struct:cpp_underlying_name}}::operator<([[maybe_unused]] const {{struct:cpp_underlying_name}}& rhs) const { return ::apache::thrift::op::detail::StructLessThan{}(*this, rhs); } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/swap.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Form: void swap(Struct& a, Struct& b) { using ::std::swap; ...; swap(a.element, b.element); } }}void swap([[maybe_unused]] {{struct:cpp_underlying_name}}& a, [[maybe_unused]] {{struct:cpp_underlying_name}}& b) { using ::std::swap; {{#struct:lazy_fields?}} const auto relaxed = std::memory_order_relaxed; swap(a.__fbthrift_protocol_, b.__fbthrift_protocol_); swap(a.__fbthrift_serializedData_, b.__fbthrift_serializedData_); {{/struct:lazy_fields?}} {{#struct:fields_in_layout_order}} swap(a.{{field:cpp_storage_name}}, b.{{field:cpp_storage_name}}); {{#field:lazy?}} a.__fbthrift_isDeserialized_.{{field:cpp_name}}.store(b.__fbthrift_isDeserialized_.{{field:cpp_name}}.exchange(a.__fbthrift_isDeserialized_.{{field:cpp_name}}.load(relaxed), relaxed), relaxed); {{/field:lazy?}} {{/struct:fields_in_layout_order}} {{#struct:isset_fields?}} swap(a.__isset, b.__isset); {{/struct:isset_fields?}} {{#struct:cpp_allocator}} {{^struct:cpp_allocator_via}} ::apache::thrift::detail::swap_allocators(a.__fbthrift_alloc, b.__fbthrift_alloc); {{/struct:cpp_allocator_via}} {{/struct:cpp_allocator}} } {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/tcc_struct_traits.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} namespace apache { namespace thrift { namespace detail { void TccStructTraits<{{struct:cpp_fullname}}>::translateFieldName( std::string_view _fname, int16_t& fid, apache::thrift::protocol::TType& _ftype) noexcept { using data = apache::thrift::TStructDataStorage<{{struct:cpp_fullname}}>; static const st::translate_field_name_table table{ data::fields_size, data::fields_names.data(), data::fields_ids.data(), data::fields_types.data()}; st::translate_field_name(_fname, fid, _ftype, table); } } // namespace detail } // namespace thrift } // namespace apache {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_copy_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{^struct:cpp_noncopyable}} {{struct:cpp_underlying_name}}::{{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& rhs) : type_(folly::to_underlying(Type::__EMPTY__)) { switch (rhs.getType()) { case Type::__EMPTY__: return; {{#struct:fields}} case Type::{{field:cpp_name}}: {{^field:transitively_refers_to_unique?}} {{#field:cpp_ref?}} set_{{field:cpp_name}}(*rhs.value_.{{field:cpp_name}}); {{/field:cpp_ref?}} {{^field:cpp_ref?}} set_{{field:cpp_name}}(rhs.value_.{{field:cpp_name}}); {{/field:cpp_ref?}} {{/field:transitively_refers_to_unique?}} {{#field:transitively_refers_to_unique?}} set_{{field:cpp_name}}(::apache::thrift::detail::st::copy_field< {{#field:type}}{{type:type_class}}{{/field:type}}>(rhs.value_.{{field:cpp_name}})); {{/field:transitively_refers_to_unique?}} break; {{/struct:fields}} default: assert(false); } } {{struct:cpp_underlying_name}}&{{struct:cpp_underlying_name}}::operator=(const {{struct:cpp_underlying_name}}& rhs) { {{! a bunch of code relies on the self-assignment check even though it should not be needed }} if (this == &rhs) { return *this; } switch (rhs.getType()) { case Type::__EMPTY__: __fbthrift_clear(); return *this; {{#struct:fields}} case Type::{{field:cpp_name}}: {{^field:transitively_refers_to_unique?}} {{#field:cpp_ref?}} set_{{field:cpp_name}}(*rhs.value_.{{field:cpp_name}}); {{/field:cpp_ref?}} {{^field:cpp_ref?}} set_{{field:cpp_name}}(rhs.value_.{{field:cpp_name}}); {{/field:cpp_ref?}} {{/field:transitively_refers_to_unique?}} {{#field:transitively_refers_to_unique?}} set_{{field:cpp_name}}(::apache::thrift::detail::st::copy_field< {{#field:type}}{{type:type_class}}{{/field:type}}>(rhs.value_.{{field:cpp_name}})); {{/field:transitively_refers_to_unique?}} break; {{/struct:fields}} default: __fbthrift_clear(); assert(false); } return *this; } {{/struct:cpp_noncopyable}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_declare_members.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}void {{struct:cpp_underlying_name}}::__fbthrift_destruct() { switch(getType()) { case Type::__EMPTY__: break; {{#struct:fields}} case Type::{{field:cpp_name}}: ::std::destroy_at(::std::addressof(value_.{{field:cpp_name}})); break; {{/struct:fields}} default: assert(false); break; } } void {{struct:cpp_underlying_name}}::__fbthrift_clear() { __fbthrift_destruct(); type_ = folly::to_underlying(Type::__EMPTY__); } {{^struct:is_trivially_destructible?}} {{struct:cpp_underlying_name}}::~{{struct:cpp_underlying_name}}() { __fbthrift_destruct(); } {{/struct:is_trivially_destructible?}} bool {{struct:cpp_underlying_name}}::__fbthrift_is_empty() const { return getType() == Type::__EMPTY__; } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_eq_overload.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} bool {{struct:cpp_underlying_name}}::operator==(const {{struct:cpp_underlying_name}}& rhs) const { return ::apache::thrift::op::detail::UnionEquality{}(*this, rhs); } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_operator_less.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} bool {{struct:cpp_underlying_name}}::operator<([[maybe_unused]] const {{struct:cpp_underlying_name}}& rhs) const { return ::apache::thrift::op::detail::UnionLessThan{}(*this, rhs); } )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_setters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}{{#field:type}}{{#type:resolves_to_container_or_struct?}}{{#field:cpp_ref?}} {{!deprecated}}{{field:cpp_storage_type}}& {{struct:cpp_underlying_name}}::set_{{field:cpp_name}}({{field:cpp_storage_type}} t) { __fbthrift_destruct(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_storage_type}}(std::move(t)); return value_.{{field:cpp_name}}; } {{!deprecated}}{{field:cpp_storage_type}}& {{struct:cpp_underlying_name}}::set_{{field:cpp_name}}({{field:cpp_type}} const &t) { return set_{{field:cpp_name}}({{field:cpp_storage_type}}({{^field:boxed_ref?}}new {{/field:boxed_ref?}}{{field:cpp_storage_type}}::element_type(t))); } {{!deprecated}}{{field:cpp_storage_type}}& {{struct:cpp_underlying_name}}::set_{{field:cpp_name}}({{field:cpp_type}}&& t) { return set_{{field:cpp_name}}({{field:cpp_storage_type}}({{^field:boxed_ref?}}new {{/field:boxed_ref?}}{{field:cpp_storage_type}}::element_type(std::move(t)))); } {{/field:cpp_ref?}}{{/type:resolves_to_container_or_struct?}}{{/field:type}}{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_cpp/union_swap.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} void swap({{struct:cpp_underlying_name}}& a, {{struct:cpp_underlying_name}}& b) { {{struct:cpp_underlying_name}} temp(std::move(a)); a = std::move(b); b = std::move(temp); } )__FBTHRIFT_TAG__", // cpp2/module_types_custom_protocol.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > Autogen}} #pragma once /** * This header file includes the tcc files of the corresponding header file * and the header files of its dependent types. Include this header file * only when you need to use custom protocols (e.g. DebugProtocol, * VirtualProtocol) to read/write thrift structs. */ #include "{{program:include_prefix}}{{program:name}}_types.tcc" {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types_custom_protocol.h" {{/program:thrift_includes}} )__FBTHRIFT_TAG__", // cpp2/module_types_fwd.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program:enums?}} #include {{/program:enums?}} {{ > module_types_h/forward_declare}} {{#program:enums?}} // BEGIN forward_declare_enums {{ > common/namespace_cpp2_begin}} {{#program:enums}} enum {{^enum:cpp_is_unscoped}}class {{/enum:cpp_is_unscoped}}{{enum:cpp_name}}{{#enum:cpp_enum_type}} : {{enum:cpp_enum_type}}{{/enum:cpp_enum_type}}; {{/program:enums}} {{ > common/namespace_cpp2_end}} // END forward_declare_enums {{/program:enums?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/alloc_extended_ctors.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} explicit {{struct:cpp_underlying_name}}(const allocator_type& alloc) noexcept : {{^struct:cpp_allocator_via}} __fbthrift_alloc(alloc), {{/struct:cpp_allocator_via}} {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}({{! }}{{#field:type}}{{! }}{{#field:cpp_ref_not_boxed?}}{{! }}{{#field:cpp_ref_unique?}}{{#type:cpp_use_allocator?}}folly::allocate_unique{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_unique{{/type:cpp_use_allocator?}}{{/field:cpp_ref_unique?}}{{! }}{{#field:cpp_ref_shared?}}{{#type:cpp_use_allocator?}}std::allocate_shared{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_shared{{/type:cpp_use_allocator?}}{{/field:cpp_ref_shared?}}{{! }}<{{type:cpp_type}}>({{#field:value}}{{ > field/default}}{{/field:value}}{{#type:cpp_use_allocator?}}alloc{{/type:cpp_use_allocator?}}){{/field:cpp_ref_not_boxed?}}{{! }}{{^field:cpp_ref?}}{{#type:cpp_use_allocator?}}alloc{{/type:cpp_use_allocator?}}{{/field:cpp_ref?}}{{! }}){{/field:type}}{{^last?}},{{/last?}}{{#last?}} {}{{/last?}} {{/struct:fields_in_layout_order}} explicit {{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& other, const allocator_type& alloc) : {{^struct:cpp_allocator_via}} __fbthrift_alloc(alloc), {{/struct:cpp_allocator_via}} {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}({{! }}{{#field:type}}{{! }}{{#field:cpp_ref_not_boxed?}}{{! }}{{#field:cpp_ref_unique?}}{{#type:cpp_use_allocator?}}folly::allocate_unique{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_unique{{/type:cpp_use_allocator?}}{{/field:cpp_ref_unique?}}{{! }}{{#field:cpp_ref_shared?}}{{#type:cpp_use_allocator?}}std::allocate_shared{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_shared{{/type:cpp_use_allocator?}}{{/field:cpp_ref_shared?}}{{! }}<{{type:cpp_type}}>({{#type:cpp_use_allocator?}}alloc, {{/type:cpp_use_allocator?}}*other.{{field:cpp_storage_name}}){{/field:cpp_ref_not_boxed?}}{{! }}{{^field:cpp_ref?}}other.{{field:cpp_storage_name}}{{#type:cpp_use_allocator?}}, alloc{{/type:cpp_use_allocator?}}{{/field:cpp_ref?}}{{! }}){{/field:type}}{{^last?}},{{/last?}}{{#last?}}{{#struct:isset_fields?}},{{/struct:isset_fields?}}{{/last?}} {{/struct:fields_in_layout_order}} {{^struct:isset_fields?}} {} {{/struct:isset_fields?}} {{#struct:isset_fields?}} __isset(other.__isset) {} {{/struct:isset_fields?}} explicit {{struct:cpp_underlying_name}}({{struct:cpp_underlying_name}}&& other, const allocator_type& alloc) : {{^struct:cpp_allocator_via}} __fbthrift_alloc(alloc), {{/struct:cpp_allocator_via}} {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}({{! }}{{#field:type}}{{! }}{{#field:cpp_ref_not_boxed?}}{{! }}{{#field:cpp_ref_unique?}}{{#type:cpp_use_allocator?}}folly::allocate_unique{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_unique{{/type:cpp_use_allocator?}}{{/field:cpp_ref_unique?}}{{! }}{{#field:cpp_ref_shared?}}{{#type:cpp_use_allocator?}}std::allocate_shared{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_shared{{/type:cpp_use_allocator?}}{{/field:cpp_ref_shared?}}{{! }}<{{type:cpp_type}}>({{#type:cpp_use_allocator?}}alloc, {{/type:cpp_use_allocator?}}std::move(*other.{{field:cpp_storage_name}})){{/field:cpp_ref_not_boxed?}}{{! }}{{^field:cpp_ref?}}std::move(other.{{field:cpp_storage_name}}){{#type:cpp_use_allocator?}}, alloc{{/type:cpp_use_allocator?}}{{/field:cpp_ref?}}{{! }}){{/field:type}}{{^last?}},{{/last?}}{{#last?}}{{#struct:isset_fields?}},{{/struct:isset_fields?}}{{/last?}} {{/struct:fields_in_layout_order}} {{^struct:isset_fields?}} {} {{/struct:isset_fields?}} {{#struct:isset_fields?}} __isset(other.__isset) {} {{/struct:isset_fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/base_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:cpp_allocator}}{{^struct:cpp_allocator_via}}{{! }}{{ > module_types_h/base_ctor_with_alloc_init_list}}{{! }}{{/struct:cpp_allocator_via}}{{/struct:cpp_allocator}}{{! --------------- Empty constractor, else to the condition above (!alloc || alloc_via) }}{{^struct:cpp_allocator}}{{! }}{{ > module_types_h/base_ctor_no_alloc_init_list}}{{! }}{{/struct:cpp_allocator}}{{! }}{{#struct:cpp_allocator_via}}{{! }}{{ > module_types_h/base_ctor_no_alloc_init_list}}{{! }}{{/struct:cpp_allocator_via}}{{! }} { {{#struct:fields}}{{#field:cpp_first_adapter}}{{^field:opt_cpp_ref?}}{{^field:intern_boxed_ref?}} ::apache::thrift::adapt_detail::construct<{{field:cpp_first_adapter}}, {{field:key}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{field:cpp_storage_name}}, *this); {{/field:intern_boxed_ref?}}{{/field:opt_cpp_ref?}}{{/field:cpp_first_adapter}}{{/struct:fields}} } )__FBTHRIFT_TAG__", // cpp2/module_types_h/base_ctor_no_alloc_init_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! --------------- Empty constractor, no allocator, init list }}{{struct:cpp_underlying_name}}(){{! }}{{#struct:explicitly_constructed_fields}}{{ > common/colon_newline}}{{! }}{{#field:type}}{{! }} {{field:cpp_storage_name}}({{! }}{{#field:cpp_ref_not_boxed?}}{{ > module_types_h/smart_ptr_constructor}}{{/field:cpp_ref_not_boxed?}}{{! }}{{#field:boxed_ref?}}{{ > field/default}}{{/field:boxed_ref?}}{{! TODO(dokwon): Support custom default for intern boxed field. }}{{#field:intern_boxed_ref?}}{{field:cpp_storage_type}}::fromStaticConstant(&::apache::thrift::op::getDefault<{{ > field/tag}}>()){{/field:intern_boxed_ref?}}{{! }}{{^field:cpp_ref?}}{{#field:value}}{{! Use value initialization when no custom default is provided. }}{{ > field/default}}{{/field:value}}{{! }}{{/field:cpp_ref?}}{{! }}){{ > common/comma_newline}}{{! }}{{/field:type}}{{! }}{{/struct:explicitly_constructed_fields}}{{!}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/base_ctor_with_alloc_init_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! --------------- Empty constructor, with 1 allocator, copied from alloc_extended_ctors.mustache ctor(const allocator_type& alloc) }}{{struct:cpp_underlying_name}}() : __fbthrift_alloc(allocator_type()), {{#struct:fields_in_layout_order}} {{field:cpp_storage_name}}({{! }}{{#field:type}}{{! }}{{#field:cpp_ref_not_boxed?}}{{! }}{{ > module_types_h/smart_ptr_constructor}}{{! }}{{/field:cpp_ref_not_boxed?}}{{! }}{{#field:boxed_ref?}}{{ > field/default}}{{/field:boxed_ref?}}{{! }}{{#field:intern_boxed_ref?}}{{field:cpp_storage_type}}::fromStaticConstant(&::apache::thrift::op::getDefault<{{ > field/tag}}>()){{/field:intern_boxed_ref?}}{{! }}{{^field:cpp_ref?}}{{! }}{{#type:cpp_use_allocator?}}__fbthrift_alloc{{/type:cpp_use_allocator?}}{{! }}{{/field:cpp_ref?}}{{! }}){{/field:type}}{{ > common/comma_newline}}{{! }}{{/struct:fields_in_layout_order}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/declare_enums.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// BEGIN declare_enums {{#program:enums?}} {{ > common/namespace_cpp2_begin}} {{#program:enums}} enum {{^enum:cpp_is_unscoped}}class {{/enum:cpp_is_unscoped}}{{enum:cpp_name}}{{#enum:cpp_enum_type}} : {{enum:cpp_enum_type}}{{/enum:cpp_enum_type}} { {{#enum:values}} {{enum_value:cpp_name}} = {{enum_value:value}}, {{/enum:values}} }; {{#enum:cpp_declare_bitwise_ops}} {{ > module_types_h/enum_bitwise_ops}} {{/enum:cpp_declare_bitwise_ops}} {{/program:enums}} {{ > common/namespace_cpp2_end}} namespace std { {{#program:enums}} template<> struct hash<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> : ::apache::thrift::detail::enum_hash<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> {}; {{/program:enums}} } // std namespace apache { namespace thrift { {{#program:enums}} template <> struct TEnumDataStorage<{{ > common/namespace_cpp2}}{{enum:cpp_name}}>; template <> struct TEnumTraits<{{ > common/namespace_cpp2}}{{enum:cpp_name}}> { using type = {{ > common/namespace_cpp2}}{{enum:cpp_name}}; static constexpr std::size_t const size = {{enum:size}}; static folly::Range const values; static folly::Range const names; static bool findName(type value, std::string_view* out) noexcept; static bool findValue(std::string_view name, type* out) noexcept; static char const* findName(type value) noexcept { std::string_view ret; (void)findName(value, &ret); return ret.data(); } {{^enum:empty?}} static constexpr type min() { return type::{{enum:min}}; } static constexpr type max() { return type::{{enum:max}}; } {{/enum:empty?}} }; {{/program:enums}} }} // apache::thrift {{/program:enums?}} // END declare_enums )__FBTHRIFT_TAG__", // cpp2/module_types_h/declare_members.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields_in_layout_order}}{{#field:type}} {{field:visibility}}: {{#field:lazy?}}mutable {{/field:lazy?}}{{field:cpp_storage_type}} {{field:cpp_storage_name}}; {{/field:type}}{{/struct:fields_in_layout_order}} {{#struct:isset_fields?}} private: apache::thrift::detail::isset_bitset<{{struct:isset_fields_size}}, {{struct:isset_bitset_option}}> __isset; {{/struct:isset_fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/declare_union_types.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#program:unions?}} namespace apache { namespace thrift { {{#program:structs}}{{#struct:union?}} template <> struct TEnumDataStorage<{{struct:cpp_fullname}}::Type>; template <> struct TEnumTraits<{{struct:cpp_fullname}}::Type> { using type = {{struct:cpp_fullname}}::Type; static constexpr std::size_t const size = {{struct:num_union_members}}; static folly::Range const values; static folly::Range const names; static bool findName(type value, std::string_view* out) noexcept; static bool findValue(std::string_view name, type* out) noexcept; static char const* findName(type value) noexcept { std::string_view ret; (void)findName(value, &ret); return ret.data(); } }; {{/struct:union?}}{{/program:structs}} }} // apache::thrift {{/program:unions?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/enum_bitwise_ops.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}inline constexpr {{enum:cpp_name}} operator&({{enum:cpp_name}} a, {{enum:cpp_name}} b) { using E = {{enum:cpp_name}}; using U = std::underlying_type_t; return static_cast(static_cast(a) & static_cast(b)); } inline constexpr {{enum:cpp_name}}& operator&=({{enum:cpp_name}}& a, {{enum:cpp_name}} b) { return a = a & b; } inline constexpr {{enum:cpp_name}} operator|({{enum:cpp_name}} a, {{enum:cpp_name}} b) { using E = {{enum:cpp_name}}; using U = std::underlying_type_t; return static_cast(static_cast(a) | static_cast(b)); } inline constexpr {{enum:cpp_name}}& operator|=({{enum:cpp_name}}& a, {{enum:cpp_name}} b) { return a = a | b; } inline constexpr {{enum:cpp_name}} operator^({{enum:cpp_name}} a, {{enum:cpp_name}} b) { using E = {{enum:cpp_name}}; using U = std::underlying_type_t; return static_cast(static_cast(a) ^ static_cast(b)); } inline constexpr {{enum:cpp_name}}& operator^=({{enum:cpp_name}}& a, {{enum:cpp_name}} b) { return a = a ^ b; } inline constexpr {{enum:cpp_name}} operator~({{enum:cpp_name}} a) { using E = {{enum:cpp_name}}; using U = std::underlying_type_t; return static_cast(~static_cast(a)); } )__FBTHRIFT_TAG__", // cpp2/module_types_h/field_interceptor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:cpp_field_interceptor}} {{field:cpp_field_interceptor}}::interceptThriftFieldAccess({{! }}this->{{ > common/field_value}}, {{! }}::apache::thrift::FieldContext::type, {{field:key}}>{*this}); {{/field:cpp_field_interceptor}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/field_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}} {{#field:use_field_ref?}} {{^struct:legacy_api?}} private: {{/struct:legacy_api?}} template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}_ref() const& { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{this->{{ > common/field_value}}{{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}_ref() const&& { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{static_cast(this->{{ > common/field_value}}){{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}_ref() & { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{this->{{ > common/field_value}}{{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}_ref() && { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{static_cast(this->{{ > common/field_value}}){{ > module_types_h/field_ref_args}}}; } {{^struct:legacy_api?}} public: {{/struct:legacy_api?}} {{#field:eligible_for_storage_name_mangling?}} template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}() const& { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{this->{{ > common/field_value}}{{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}() const&& { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{static_cast(this->{{ > common/field_value}}){{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}() & { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{this->{{ > common/field_value}}{{ > module_types_h/field_ref_args}}}; } template {{field:cpp_accessor_attribute}} {{field:field_ref_type}} {{field:cpp_name}}() && { {{ > module_types_h/field_interceptor}} return {{^field:has_isset?}}{{field:field_ref_type}}{{/field:has_isset?}}{static_cast(this->{{ > common/field_value}}){{ > module_types_h/field_ref_args}}}; } {{/field:eligible_for_storage_name_mangling?}} {{/field:use_field_ref?}} {{^field:use_field_ref?}} {{^struct:legacy_api?}} private: {{/struct:legacy_api?}} template {{field:cpp_accessor_attribute}} T& {{field:cpp_name}}_ref() & { {{ > module_types_h/field_interceptor}} return {{ > common/field_value}}; } template {{field:cpp_accessor_attribute}} const T& {{field:cpp_name}}_ref() const& { {{ > module_types_h/field_interceptor}} return {{ > common/field_value}}; } template {{field:cpp_accessor_attribute}} T&& {{field:cpp_name}}_ref() && { {{ > module_types_h/field_interceptor}} return static_cast({{ > common/field_value}}); } template {{field:cpp_accessor_attribute}} const T&& {{field:cpp_name}}_ref() const&& { {{ > module_types_h/field_interceptor}} return static_cast({{ > common/field_value}}); } {{^struct:legacy_api?}} public: {{/struct:legacy_api?}} {{#field:eligible_for_storage_name_mangling?}} template FOLLY_ERASE T& {{field:cpp_name}}() & { {{ > module_types_h/field_interceptor}} return {{ > common/field_value}}; } template FOLLY_ERASE const T& {{field:cpp_name}}() const& { {{ > module_types_h/field_interceptor}} return {{ > common/field_value}}; } template FOLLY_ERASE T&& {{field:cpp_name}}() && { {{ > module_types_h/field_interceptor}} return static_cast({{ > common/field_value}}); } template FOLLY_ERASE const T&& {{field:cpp_name}}() const&& { {{ > module_types_h/field_interceptor}} return static_cast({{ > common/field_value}}); } {{/field:eligible_for_storage_name_mangling?}} {{/field:use_field_ref?}} {{/struct:fields}} {{#struct:mixin_fields}} {{^struct:legacy_api?}} private: {{/struct:legacy_api?}} FOLLY_ERASE auto {{mixin:field_name}}_ref() & { return {{mixin:name}}_ref()->{{mixin:accessor}}(); } FOLLY_ERASE auto {{mixin:field_name}}_ref() const& { return {{mixin:name}}_ref()->{{mixin:accessor}}(); } FOLLY_ERASE auto {{mixin:field_name}}_ref() && { return std::move(*{{mixin:name}}_ref()).{{mixin:accessor}}(); } FOLLY_ERASE auto {{mixin:field_name}}_ref() const&& { return std::move(*{{mixin:name}}_ref()).{{mixin:accessor}}(); } {{^struct:legacy_api?}} public: {{/struct:legacy_api?}} FOLLY_ERASE auto {{mixin:field_name}}() & { return {{mixin:field_name}}_ref(); } FOLLY_ERASE auto {{mixin:field_name}}() const& { return {{mixin:field_name}}_ref(); } FOLLY_ERASE auto {{mixin:field_name}}() && { return std::move(*this).{{mixin:field_name}}_ref(); } FOLLY_ERASE auto {{mixin:field_name}}() const&& { return std::move(*this).{{mixin:field_name}}_ref(); } {{/struct:mixin_fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/field_ref_args.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:intern_boxed_ref?}}, ::apache::thrift::op::getDefault<{{ > field/tag}}>{{/field:intern_boxed_ref?}}{{#field:has_isset?}}, __isset.at({{field:isset_index}}), __isset.bit({{field:isset_index}}){{/field:has_isset?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/forward_declare.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// BEGIN forward_declare {{#program:structs?}} {{ > common/namespace_cpp2_begin}} {{#program:structs}} {{#struct:extra_namespace}} namespace {{struct:extra_namespace}} { {{/struct:extra_namespace}} class {{struct:cpp_underlying_name}}; {{#struct:extra_namespace}} } // namespace {{struct:extra_namespace}} {{/struct:extra_namespace}} {{/program:structs}} {{ > common/namespace_cpp2_end}} {{/program:structs?}} // END forward_declare )__FBTHRIFT_TAG__", // cpp2/module_types_h/fragile_ctor_param_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}, {{field:cpp_storage_type}} {{field:cpp_name}}__arg{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/frozen.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#program:frozen?}} namespace apache { namespace thrift { {{#program:frozen_packed?}}#pragma pack(push, 1){{/program:frozen_packed?}} template<> struct Frozen<{{struct:cpp_fullname}}, void> { {{#struct:fields}} {{#field:type}} {{#type:bool?}} bool {{field:cpp_name}} : 1; {{/type:bool?}} {{^type:bool?}} typename Freezer<{{type:cpp_type}}>::FrozenType {{field:cpp_name}}; {{/type:bool?}} {{/field:type}} {{/struct:fields}} {{#struct:isset_fields?}} struct __isset { {{#struct:isset_fields}} bool {{field:cpp_name}} : 1; {{/struct:isset_fields}} } __isset = {}; {{/struct:isset_fields?}} }; {{#program:frozen_packed?}}#pragma pack(pop){{/program:frozen_packed?}} }} // apache::thrift {{/program:frozen?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/getters_setters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}{{#field:type}}{{#field:has_deprecated_accessors?}} {{#type:resolves_to_base_or_enum?}} {{^type:string_or_binary?}} {{#field:optional?}} const {{type:cpp_type}}* get_{{field:cpp_name}}() const& { return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{type:cpp_type}}* get_{{field:cpp_name}}() & { return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{type:cpp_type}}* get_{{field:cpp_name}}() && = delete; {{/field:optional?}} {{^field:optional?}} {{type:cpp_type}} get_{{field:cpp_name}}() const { return {{field:cpp_storage_name}}; } {{/field:optional?}} [[deprecated("Use `FOO.{{field:cpp_name}}_ref() = BAR;` instead of `FOO.set_{{field:cpp_name}}(BAR);`")]] {{type:cpp_type}}& set_{{field:cpp_name}}({{type:cpp_type}} {{field:cpp_name}}_) { {{field:cpp_name}}_ref() = {{field:cpp_name}}_; return {{field:cpp_storage_name}}; } {{/type:string_or_binary?}} {{#type:string_or_binary?}} {{#field:optional?}} const {{type:cpp_type}}* get_{{field:cpp_name}}() const& { return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{type:cpp_type}}* get_{{field:cpp_name}}() & { return {{field:cpp_name}}_ref() ? std::addressof({{field:cpp_storage_name}}) : nullptr; } {{type:cpp_type}}* get_{{field:cpp_name}}() && = delete; {{/field:optional?}} {{^field:optional?}} const {{type:cpp_type}}& get_{{field:cpp_name}}() const& { return {{field:cpp_storage_name}}; } {{type:cpp_type}} get_{{field:cpp_name}}() && { return std::move({{field:cpp_storage_name}}); } {{/field:optional?}} template [[deprecated("Use `FOO.{{field:cpp_name}}_ref() = BAR;` instead of `FOO.set_{{field:cpp_name}}(BAR);`")]] {{type:cpp_type}}& set_{{field:cpp_name}}(T_{{struct:cpp_underlying_name}}_{{field:cpp_name}}_struct_setter&& {{field:cpp_name}}_) { {{field:cpp_name}}_ref() = std::forward({{field:cpp_name}}_); return {{field:cpp_storage_name}}; } {{/type:string_or_binary?}} {{/type:resolves_to_base_or_enum?}} {{#type:resolves_to_container_or_struct?}} {{#field:optional?}} const {{type:cpp_type}}* get_{{field:cpp_name}}() const&; {{type:cpp_type}}* get_{{field:cpp_name}}() &; {{type:cpp_type}}* get_{{field:cpp_name}}() && = delete; {{/field:optional?}} {{^field:optional?}} const {{type:cpp_type}}& get_{{field:cpp_name}}() const&; {{type:cpp_type}} get_{{field:cpp_name}}() &&; {{/field:optional?}} template [[deprecated("Use `FOO.{{field:cpp_name}}_ref() = BAR;` instead of `FOO.set_{{field:cpp_name}}(BAR);`")]] {{type:cpp_type}}& set_{{field:cpp_name}}(T_{{struct:cpp_underlying_name}}_{{field:cpp_name}}_struct_setter&& {{field:cpp_name}}_) { {{field:cpp_name}}_ref() = std::forward({{field:cpp_name}}_); return {{field:cpp_storage_name}}; } {{/type:resolves_to_container_or_struct?}} {{/field:has_deprecated_accessors?}}{{/field:type}}{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/hash_and_equal_to.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// BEGIN hash_and_equal_to {{#program:cpp_declare_hash?}} namespace std { {{#program:structs}} {{#struct:cpp_declare_hash}} template<> struct hash { size_t operator()(const {{struct:cpp_fullname}}&) const; }; {{#struct:cpp_declare_equal_to}} template<> struct equal_to { bool operator()(const {{struct:cpp_fullname}}&,const {{struct:cpp_fullname}}&) const; }; {{/struct:cpp_declare_equal_to}} {{/struct:cpp_declare_hash}} {{/program:structs}} } // std {{/program:cpp_declare_hash?}} // END hash_and_equal_to )__FBTHRIFT_TAG__", // cpp2/module_types_h/lazy_deserialization.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:lazy_fields?}} private: {{! Stores serialized data of each lazy field }} mutable struct __fbthrift_SerializedData { {{#struct:fields}}{{#field:lazy?}} {{^field:lazy_ref?}}folly::IOBuf{{/field:lazy_ref?}}{{! }}{{#field:lazy_ref?}}std::unique_ptr{{/field:lazy_ref?}}{{! }} {{field:cpp_name}}; {{/field:lazy?}}{{/struct:fields}} } __fbthrift_serializedData_; mutable ::apache::thrift::detail::st::DeserializationMutex __fbthrift_deserializationMutex_; ::apache::thrift::ProtocolType __fbthrift_protocol_{}; {{! Use double checked locking pattern to deserialize }} mutable struct __fbthrift_IsDeserialized { {{#struct:fields}}{{#field:lazy?}} std::atomic {{field:cpp_name}}{::apache::thrift::detail::LazyDeserializationState::UNTAINTED | ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED}; {{/field:lazy?}}{{/struct:fields}} } __fbthrift_isDeserialized_; {{#struct:fields}}{{#field:lazy?}} const {{field:cpp_storage_type}}& __fbthrift_read_field_{{field:cpp_name}}() const; {{field:cpp_storage_type}}& __fbthrift_read_field_{{field:cpp_name}}(); void __fbthrift_read_field_{{field:cpp_name}}_slow() const; template void __fbthrift_read_field_{{field:cpp_name}}_impl() const; {{/field:lazy?}}{{/struct:fields}} {{/struct:lazy_fields?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/reflection.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} using __fbthrift_reflection_ident_list = folly::tag_t<{{#struct:fields}} ::apache::thrift::ident::{{field:cpp_name}}{{^last?}},{{/last?}}{{/struct:fields}} >; static constexpr std::int16_t __fbthrift_reflection_field_id_list[] = {0{{#struct:fields}},{{field:key}}{{/struct:fields}}}; using __fbthrift_reflection_type_tags = folly::tag_t<{{#struct:fields}} {{field:type_tag}}{{^last?}},{{/last?}}{{/struct:fields}} >; static constexpr std::size_t __fbthrift_field_size_v = {{struct:fields_size}}; template using __fbthrift_id = ::apache::thrift::type::field_id<__fbthrift_reflection_field_id_list[folly::to_underlying(T::value)]>; template using __fbthrift_type_tag = ::apache::thrift::detail::at<__fbthrift_reflection_type_tags, T::value>; template using __fbthrift_ident = ::apache::thrift::detail::at<__fbthrift_reflection_ident_list, T::value>; template using __fbthrift_ordinal = ::apache::thrift::type::ordinal_tag< ::apache::thrift::detail::getFieldOrdinal( __fbthrift_reflection_field_id_list ) >; )__FBTHRIFT_TAG__", // cpp2/module_types_h/smart_ptr_constructor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:cpp_ref_unique?}}{{#type:cpp_use_allocator?}}folly::allocate_unique{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_unique{{/type:cpp_use_allocator?}}{{/field:cpp_ref_unique?}}{{! }}{{^field:cpp_ref_unique?}}{{#type:cpp_use_allocator?}}std::allocate_shared{{/type:cpp_use_allocator?}}{{^type:cpp_use_allocator?}}std::make_shared{{/type:cpp_use_allocator?}}{{/field:cpp_ref_unique?}}{{! }}<{{field:cpp_type}}>({{#type:cpp_use_allocator?}}__fbthrift_alloc{{/type:cpp_use_allocator?}}{{#field:value}}{{ > field/default}}{{/field:value}}) )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_assign_overload.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{struct:cpp_underlying_name}}& operator=({{struct:cpp_underlying_name}}&& rhs) noexcept { if (this == &rhs) { return *this; } switch (rhs.getType()) { case Type::__EMPTY__: { __fbthrift_clear(); return *this; } {{#struct:fields}} case Type::{{field:cpp_name}}: { {{#field:cpp_ref?}} set_{{field:cpp_name}}(std::move(*rhs.value_.{{field:cpp_name}})); {{/field:cpp_ref?}} {{^field:cpp_ref?}} set_{{field:cpp_name}}(std::move(rhs.value_.{{field:cpp_name}})); {{/field:cpp_ref?}} break; } {{/struct:fields}} default: { assert(false); __fbthrift_clear(); } } apache::thrift::clear(rhs); return *this; } {{^struct:cpp_noncopyable}} {{struct:cpp_underlying_name}}& operator=(const {{struct:cpp_underlying_name}}& rhs); {{/struct:cpp_noncopyable}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_copy_ctor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{struct:cpp_underlying_name}}({{struct:cpp_underlying_name}}&& rhs) noexcept : type_(folly::to_underlying(Type::__EMPTY__)) { if (this == &rhs) { return; } switch (rhs.getType()) { case Type::__EMPTY__: { return; } {{#struct:fields}} case Type::{{field:cpp_name}}: { {{#field:cpp_ref?}} set_{{field:cpp_name}}(std::move(*rhs.value_.{{field:cpp_name}})); {{/field:cpp_ref?}} {{^field:cpp_ref?}} set_{{field:cpp_name}}(std::move(rhs.value_.{{field:cpp_name}})); {{/field:cpp_ref?}} break; } {{/struct:fields}} default: { assert(false); break; } } apache::thrift::clear(rhs); } {{^struct:cpp_noncopyable}} {{struct:cpp_underlying_name}}(const {{struct:cpp_underlying_name}}& rhs); {{/struct:cpp_noncopyable}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} enum {{#struct:scoped_enum_as_union_type?}}class {{/struct:scoped_enum_as_union_type?}}Type : int { __EMPTY__ = 0, {{#struct:fields}} {{field:cpp_name}} = {{field:key}}, {{/struct:fields}} } ; )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_field_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}{{#field:type}} template FOLLY_ERASE ::apache::thrift::union_field_ref {{field:cpp_name}}_ref() const& { return {value_.{{field:cpp_name}}, type_, folly::to_underlying(Type::{{field:cpp_name}}), this, ::apache::thrift::detail::union_field_ref_owner_vtable_for}; } template FOLLY_ERASE ::apache::thrift::union_field_ref {{field:cpp_name}}_ref() const&& { return {std::move(value_.{{field:cpp_name}}), type_, folly::to_underlying(Type::{{field:cpp_name}}), this, ::apache::thrift::detail::union_field_ref_owner_vtable_for}; } template FOLLY_ERASE ::apache::thrift::union_field_ref {{field:cpp_name}}_ref() & { return {value_.{{field:cpp_name}}, type_, folly::to_underlying(Type::{{field:cpp_name}}), this, ::apache::thrift::detail::union_field_ref_owner_vtable_for}; } template FOLLY_ERASE ::apache::thrift::union_field_ref {{field:cpp_name}}_ref() && { return {std::move(value_.{{field:cpp_name}}), type_, folly::to_underlying(Type::{{field:cpp_name}}), this, ::apache::thrift::detail::union_field_ref_owner_vtable_for}; } {{/field:type}}{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_getters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}{{#field:type}} {{^struct:legacy_api?}} private: {{/struct:legacy_api?}} {{!deprecated}}{{^field:boxed_ref?}}{{field:cpp_storage_type}}{{/field:boxed_ref?}}{{#field:boxed_ref?}}{{type:cpp_type}}{{/field:boxed_ref?}} const& get_{{field:cpp_name}}() const { if (getType() != Type::{{field:cpp_name}}) { ::apache::thrift::detail::throw_on_bad_union_field_access(); } {{^field:boxed_ref?}} return value_.{{field:cpp_name}}; {{/field:boxed_ref?}} {{#field:boxed_ref?}} return *value_.{{field:cpp_name}}; {{/field:boxed_ref?}} } {{^struct:legacy_api?}} public: {{/struct:legacy_api?}} {{/field:type}}{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_moves.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:legacy_api?}}{{#struct:fields}} {{!deprecated}}{{field:cpp_storage_type}} move_{{field:cpp_name}}() { assert(getType() == Type::{{field:cpp_name}}); return std::move(value_.{{field:cpp_name}}); } {{/struct:fields}}{{/struct:legacy_api?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_mutables.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:legacy_api?}}{{#struct:fields}} {{!deprecated}}{{field:cpp_storage_type}}& mutable_{{field:cpp_name}}() { assert(getType() == Type::{{field:cpp_name}}); return value_.{{field:cpp_name}}; } {{/struct:fields}}{{/struct:legacy_api?}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_setters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:fields}}{{#field:type}} {{#field:boxed_ref?}} private: {{/field:boxed_ref?}} {{^field:boxed_ref?}}{{^struct:legacy_api?}} private: {{/struct:legacy_api?}}{{/field:boxed_ref?}} {{#type:resolves_to_base_or_enum?}} {{^type:string_or_binary?}} template = 0> {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}} t = {{field:cpp_type}}()) { using T0 = {{field:cpp_storage_type}}; using T = folly::type_t; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); {{#field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T({{^field:boxed_ref?}}new {{/field:boxed_ref?}}typename T::element_type(t)); {{/field:cpp_ref?}} {{^field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T(t); {{/field:cpp_ref?}} return value_.{{field:cpp_name}}; } {{/type:string_or_binary?}} {{#type:string_or_binary?}} template = 0> {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}} const &t) { using T0 = {{field:cpp_storage_type}}; using T = folly::type_t; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); {{#field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T({{^field:boxed_ref?}}new {{/field:boxed_ref?}}typename T::element_type(t)); {{/field:cpp_ref?}} {{^field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T(t); {{/field:cpp_ref?}} return value_.{{field:cpp_name}}; } template = 0> {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}}&& t) { using T0 = {{field:cpp_storage_type}}; using T = folly::type_t; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); {{#field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T({{^field:boxed_ref?}}new {{/field:boxed_ref?}}typename T::element_type(std::move(t))); {{/field:cpp_ref?}} {{^field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) T(std::move(t)); {{/field:cpp_ref?}} return value_.{{field:cpp_name}}; } {{!deprecated}} template> {{field:cpp_storage_type}}& set_{{field:cpp_name}}(T&&... t) { __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); {{#field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_storage_type}}({{^field:boxed_ref?}}new {{/field:boxed_ref?}}{{field:cpp_storage_type}}::element_type(std::forward(t)...)); {{/field:cpp_ref?}} {{^field:cpp_ref?}} ::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_type}}(std::forward(t)...); {{/field:cpp_ref?}} return value_.{{field:cpp_name}}; } {{/type:string_or_binary?}} {{#field:cpp_ref?}} {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_storage_type}} t) { __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_storage_type}}(std::move(t)); return value_.{{field:cpp_name}}; } {{/field:cpp_ref?}} {{/type:resolves_to_base_or_enum?}} {{#type:resolves_to_container_or_struct?}} {{^field:cpp_ref?}} {{^field:cpp_noncopyable?}} template = 0> {{!deprecated}} {{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}} const &t) { using T0 = {{field:cpp_storage_type}}; using T = folly::type_t; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) T(t); return value_.{{field:cpp_name}}; } {{/field:cpp_noncopyable?}} template = 0> {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}}&& t) { using T0 = {{field:cpp_storage_type}}; using T = folly::type_t; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) T(std::move(t)); return value_.{{field:cpp_name}}; } {{!deprecated}} template> {{field:cpp_storage_type}}& set_{{field:cpp_name}}(T&&... t) { __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) {{field:cpp_type}}(std::forward(t)...); return value_.{{field:cpp_name}}; } {{/field:cpp_ref?}} {{#field:cpp_ref?}} {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_storage_type}} t); {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}} const &t); {{!deprecated}}{{field:cpp_storage_type}}& set_{{field:cpp_name}}({{field:cpp_type}}&& t); {{!deprecated}} template> {{field:cpp_storage_type}}& set_{{field:cpp_name}}(T&&... t) { // defer resolution of ref_ in case ref_::element_type would here be incomplete using ref_ = folly::conditional_t<(sizeof...(T) < size_t(-1)), {{field:cpp_storage_type}}, void>; __fbthrift_clear(); type_ = folly::to_underlying(Type::{{field:cpp_name}}); ::new (std::addressof(value_.{{field:cpp_name}})) ref_({{^field:boxed_ref?}}new {{/field:boxed_ref?}}typename ref_::element_type(std::forward(t)...)); return value_.{{field:cpp_name}}; } {{/field:cpp_ref?}} {{/type:resolves_to_container_or_struct?}} {{#field:boxed_ref?}} public: {{/field:boxed_ref?}} {{^field:boxed_ref?}}{{^struct:legacy_api?}} public: {{/struct:legacy_api?}}{{/field:boxed_ref?}} {{/field:type}}{{/struct:fields}} )__FBTHRIFT_TAG__", // cpp2/module_types_h/union_storage.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} union storage_type { {{#struct:fields}} {{field:cpp_storage_type}} {{field:cpp_name}}; {{/struct:fields}} {{^struct:is_trivially_destructible?}} storage_type() {} ~storage_type() {} {{/struct:is_trivially_destructible?}} } ; )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/container_struct_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:map?}}{{! }}{{#type:key_type}}apache::thrift::protocol::{{ > module_types_tcc/struct_type}}{{/type:key_type}}, {{#type:value_type}}apache::thrift::protocol::{{ > module_types_tcc/struct_type}}{{/type:value_type}}{{! }}{{/type:map?}}{{! }}{{#type:list?}}{{! }}{{#type:list_elem_type}}apache::thrift::protocol::{{ > module_types_tcc/struct_type}}{{/type:list_elem_type}}{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}{{#type:set_elem_type}}apache::thrift::protocol::{{ > module_types_tcc/struct_type}}{{/type:set_elem_type}}{{! }}{{/type:set?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/deprecated_terse_has_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! // Must not be null. }}{{#field:cpp_ref?}}{{! }}{{ > field/member}}{{! }}{{/field:cpp_ref?}}{{! // Must not be empty. }}{{#type:resolves_to_container?}}{{! }}{{#field:cpp_ref?}} && {{/field:cpp_ref?}}!::apache::thrift::op::isEmpty<{{ > field/tag}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}){{! }}{{/type:resolves_to_container?}}{{! }}{{#field:raw_string_or_binary?}}{{! }}{{#field:cpp_ref?}} && {{/field:cpp_ref?}}!::apache::thrift::op::isEmpty<{{ > field/tag}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}){{! }}{{/field:raw_string_or_binary?}}{{! }}{{^field:cpp_ref?}}{{^type:resolves_to_container?}}{{^field:raw_string_or_binary?}}{{! }}{{#field:cpp_first_adapter}}{{! // Must use == operator, and check against the default constructor (ignoring any IDL-specified default). }}!({{ > module_types_tcc/field_ref }} == {{type:cpp_type}}()){{! }}{{/field:cpp_first_adapter}}{{! }}{{^field:cpp_first_adapter}}{{! // For all other cases, must not equal the default. // TODO(afuller): As with containers, binary, and string above, this should check for // the 'intrinsic' default so the behavior does not change when IDL-specified defaults // change. }}{{ > module_types_tcc/field_ref }} != {{ > field/default}}{{! }}{{/field:cpp_first_adapter}}{{! }}{{/field:raw_string_or_binary?}}{{/type:resolves_to_container?}}{{/field:cpp_ref?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/deserialize_field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#type:resolves_to_container_or_struct?}} _readState.beforeSubobject(iprot); {{/type:resolves_to_container_or_struct?}} {{#field:cpp_ref?}} auto ptr = ::apache::thrift::detail::make_mutable_smart_ptr<{{field:cpp_storage_type}}>({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}}); {{/field:cpp_ref?}} {{#field:use_op_encode?}} ::apache::thrift::op::decode<{{ > field/tag}}>(*iprot, {{ > module_types_tcc/member_or_ptr}}{{#field:cpp_adapter}}, *this{{/field:cpp_adapter}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{#field:cpp_first_adapter}} {{#field:cpp_exactly_one_adapter?}} if constexpr(::apache::thrift::adapt_detail::has_inplace_toThrift<{{field:cpp_first_adapter}}, {{field:cpp_type}}>::value) { {{^field:cpp_ref?}}{{#type:resolves_to_container?}} ::apache::thrift::adapt_detail::clear<{{field:cpp_first_adapter}}, {{field:key}}>({{ > module_types_tcc/member_or_ptr}}, *this); {{/type:resolves_to_container?}}{{/field:cpp_ref?}} {{ > module_types_tcc/pm}}::readWithContext(*iprot, {{field:cpp_first_adapter}}::toThrift({{ > module_types_tcc/member_or_ptr}}), _readState); } else { {{/field:cpp_exactly_one_adapter?}} {{#field:cpp_exactly_one_adapter?}} {{/field:cpp_exactly_one_adapter?}}{{type:cpp_standard_type}} tvalue{{#type:resolves_to_container?}}{{#type:cpp_use_allocator?}}(this->get_allocator()){{/type:cpp_use_allocator?}}{{/type:resolves_to_container?}}; {{#field:cpp_exactly_one_adapter?}} {{/field:cpp_exactly_one_adapter?}}{{ > module_types_tcc/pm}}::readWithContext(*iprot, tvalue, _readState); {{#field:cpp_exactly_one_adapter?}} {{ > module_types_tcc/member_or_ptr}} = ::apache::thrift::adapt_detail::fromThriftField<{{field:cpp_first_adapter}}, {{field:key}}>(::std::move(tvalue), *this); } {{/field:cpp_exactly_one_adapter?}} {{^field:cpp_exactly_one_adapter?}} {{ > module_types_tcc/member_or_ptr}} = ::apache::thrift::adapt_detail::fromThriftField<{{field:cpp_first_adapter}}, {{field:key}}>({{ > types/adapter_pre}}::std::move(tvalue){{ > types/adapter_post}}, *this); {{/field:cpp_exactly_one_adapter?}} {{/field:cpp_first_adapter}} {{^field:cpp_first_adapter}} {{^field:cpp_ref?}}{{#type:resolves_to_container?}} {{ > field/member}} = {{type:cpp_type}}({{#type:cpp_use_allocator?}}this->get_allocator(){{/type:cpp_use_allocator?}}); {{/type:resolves_to_container?}}{{/field:cpp_ref?}} {{ > module_types_tcc/pm}}::readWithContext(*iprot, {{ > module_types_tcc/member_or_ptr}}, _readState); {{/field:cpp_first_adapter}} {{/field:use_op_encode?}} {{#field:cpp_ref?}} {{ > field/member}} = std::move(ptr); {{/field:cpp_ref?}} {{#type:resolves_to_container_or_struct?}} _readState.afterSubobject(iprot); {{/type:resolves_to_container_or_struct?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/deserialize_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^program:tablebased?}} template void {{struct:cpp_underlying_name}}::readNoXfer(Protocol_* iprot) { {{! Terse fields are cleared to their intrinsic default values so that when fields are missing during deserialization, it will be still set to intrinsic default even if the field has the custom default in IDL. }} __fbthrift_clear_terse_fields(); apache::thrift::detail::ProtocolReaderStructReadState{{#struct:indexing?}}WithIndex{{/struct:indexing?}} _readState; _readState.readStructBegin(iprot); using apache::thrift::TProtocolException; {{#program:enforce_required?}}{{#struct:fields_in_serialization_order}}{{#field:required?}} bool isset_{{field:cpp_name}} = false; {{/field:required?}}{{/struct:fields_in_serialization_order}}{{/program:enforce_required?}} {{#struct:lazy_fields?}} if (__fbthrift_protocol_ != iprot->protocolType()) { {{! Deserialize all lazy fields if new protocol is different that last deserialization protocol }} {{#struct:fields_in_serialization_order}}{{#field:lazy?}} std::as_const(*this).__fbthrift_read_field_{{field:cpp_name}}(); {{/field:lazy?}}{{/struct:fields_in_serialization_order}} __fbthrift_protocol_ = iprot->protocolType(); } {{/struct:lazy_fields?}} {{#struct:fields?}} {{#struct:fields_in_serialization_order}} {{#field:type}} {{#first?}} if (UNLIKELY(!_readState.advanceToNextField( iprot, 0, {{field:key}}, apache::thrift::protocol::{{ > module_types_tcc/struct_type}}))) { goto _advance_failure; } {{/first?}} _readField_{{field:cpp_name}}: {{#field:lazy?}} std::as_const(*this).__fbthrift_read_field_{{field:cpp_name}}(); if (auto iobuf = _readState.template tryFastSkip< {{type:type_class_with_indirection}}, {{type:cpp_type}} >(iprot, {{field:key}}, apache::thrift::protocol::{{ > module_types_tcc/struct_type}})) { const auto isDeserialized = __fbthrift_isDeserialized_.{{field:cpp_name}}.load(); __fbthrift_serializedData_.{{field:cpp_name}} = {{! }}{{^field:lazy_ref?}}std::move(*iobuf);{{/field:lazy_ref?}}{{! }}{{#field:lazy_ref?}}std::make_unique(std::move(*iobuf));{{/field:lazy_ref?}} __fbthrift_isDeserialized_.{{field:cpp_name}} = isDeserialized & ~::apache::thrift::detail::LazyDeserializationState::DESERIALIZED; } else { {{/field:lazy?}} {{^field:lazy?}} { {{/field:lazy?}} {{ > module_types_tcc/deserialize_field}} } {{#program:enforce_required?}}{{#field:required?}} isset_{{field:cpp_name}} = true; {{/field:required?}}{{/program:enforce_required?}} {{#field:has_isset?}} this->__isset.set({{field:isset_index}}, true); {{/field:has_isset?}} {{^last?}} {{#field:serialization_next_field_type}} if (UNLIKELY(!_readState.advanceToNextField( iprot, {{field:key}}, {{field:serialization_next_field_key}}, apache::thrift::protocol::{{ > module_types_tcc/struct_type}}))) { goto _advance_failure; } {{/field:serialization_next_field_type}} {{/last?}} {{#last?}} if (UNLIKELY(!_readState.advanceToNextField( iprot, {{field:key}}, 0, apache::thrift::protocol::T_STOP))) { goto _advance_failure; } {{/last?}} {{/field:type}} {{/struct:fields_in_serialization_order}} {{/struct:fields?}} {{^struct:fields?}} if (UNLIKELY(!_readState.advanceToNextField( iprot, 0, 0, apache::thrift::protocol::T_STOP))) { goto _loop; } {{/struct:fields?}} _end: _readState.readStructEnd(iprot); {{#program:enforce_required?}}{{#struct:fields_in_serialization_order}}{{#field:required?}} if (!isset_{{field:cpp_name}}) { TProtocolException::throwMissingRequiredField("{{field:name}}", "{{struct:name}}"); } {{/field:required?}}{{/struct:fields_in_serialization_order}}{{/program:enforce_required?}} return; goto _advance_failure; // Avoid compiler warnings about unused labels. _advance_failure: _readState.afterAdvanceFailure(iprot); _loop: if (_readState.atStop()) { goto _end; } if (iprot->kUsesFieldNames()) { _readState.template fillFieldTraitsFromName>(); } switch (_readState.fieldId) { {{#struct:fields_in_serialization_order}}{{#field:type}} case {{field:key}}: { if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::{{ > module_types_tcc/struct_type}}))) { goto _readField_{{field:cpp_name}}; } else { goto _skip; } } {{/field:type}}{{/struct:fields_in_serialization_order}} default: { {{#struct:fields?}} _skip: {{/struct:fields?}} _readState.skip(iprot); _readState.readFieldEnd(iprot); _readState.readFieldBeginNoInline(iprot); goto _loop; } } } {{#struct:fields_in_serialization_order}} {{#field:type}} {{#field:lazy?}} template void {{struct:cpp_underlying_name}}::__fbthrift_read_field_{{field:cpp_name}}_impl() const { ProtocolReader reader; reader.setInput(&{{#field:lazy_ref?}}*{{/field:lazy_ref?}}__fbthrift_serializedData_.{{field:cpp_name}}); ProtocolReader *iprot = &reader; [[maybe_unused]] apache::thrift::detail::ProtocolReaderStructReadState _readState; {{ > module_types_tcc/deserialize_field}} } {{/field:lazy?}} {{/field:type}} {{/struct:fields_in_serialization_order}} {{/program:tablebased?}} {{#program:tablebased?}} template void {{struct:cpp_underlying_name}}::readNoXfer(Protocol_* iprot) { ::apache::thrift::detail::read( iprot, ::apache::thrift::detail::toStructInfo( {{ > common/namespace_cpp2}}__fbthrift_struct_info_{{struct:cpp_underlying_name}} ), this); } {{/program:tablebased?}} {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/deserialize_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^program:tablebased?}} template void {{struct:cpp_underlying_name}}::readNoXfer(Protocol_* iprot) { apache::thrift::detail::ProtocolReaderStructReadState _readState; _readState.fieldId = 0; _readState.readStructBegin(iprot); _readState.readFieldBegin(iprot); if (_readState.atStop()) { apache::thrift::clear(*this); } else { if (iprot->kUsesFieldNames()) { _readState.template fillFieldTraitsFromName>(); } switch (_readState.fieldId) { {{#struct:fields}}{{#field:type}} case {{field:key}}: { if (_readState.isCompatibleWithType(iprot, apache::thrift::protocol::{{ > module_types_tcc/struct_type}})) { this->{{field:cpp_name}}_ref().emplace(); {{ > module_types_tcc/deserialize_field }} } else { _readState.skip(iprot); } break; } {{/field:type}}{{/struct:fields}} default: { _readState.skip(iprot); break; } } _readState.readFieldEnd(iprot); _readState.readFieldBegin(iprot); if (UNLIKELY(!_readState.atStop())) { using apache::thrift::protocol::TProtocolException; TProtocolException::throwUnionMissingStop(); } } _readState.readStructEnd(iprot); }{{! }}{{/program:tablebased?}}{{! }}{{#program:tablebased?}} template void {{struct:cpp_underlying_name}}::readNoXfer(Protocol_* iprot) { ::apache::thrift::detail::read( iprot, ::apache::thrift::detail::toStructInfo( {{ > common/namespace_cpp2}}__fbthrift_struct_info_{{struct:cpp_underlying_name}} ), this); }{{! }}{{/program:tablebased?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/field_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! A reference to the field's value. Takes into account indirection and wraps dereferenced pointers in (). }}{{#type:cpp_indirection?}}{{! }}::apache::thrift::apply_indirection({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}){{! }}{{/type:cpp_indirection?}}{{! }}{{^type:cpp_indirection?}}{{! }}{{#field:cpp_ref?}}(*{{ > field/member}}){{/field:cpp_ref?}}{{! }}{{^field:cpp_ref?}}{{ > field/member}}{{/field:cpp_ref?}}{{! }}{{/type:cpp_indirection?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/if_should_write.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. // Note: terse_writes is mutually exclusive with optional. }} {{#struct:union?}} case {{struct:cpp_underlying_name}}::Type::{{field:cpp_name}}: { {{/struct:union?}} {{^struct:union?}} {{! }}{{#field:optional?}}{{! }}if ({{ > module_types_tcc/optional_has_value}}) {{! }}{{/field:optional?}}{{! }}{{#field:deprecated_terse_writes?}}{{! }}if ({{#field:lazy?}}!(__fbthrift_isDeserialized_.{{field:cpp_name}} & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED) || {{/field:lazy?}}{{ > module_types_tcc/deprecated_terse_has_value }}) {{! }}{{/field:deprecated_terse_writes?}}{{! }}{{#field:terse?}}{{! }}if ({{#field:lazy?}}!(__fbthrift_isDeserialized_.{{field:cpp_name}} & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED) || {{/field:lazy?}}{{ > module_types_tcc/terse_has_value }}) {{! }}{{/field:terse?}}{ {{/struct:union?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/if_should_write_end.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#struct:union?}} break; } {{/struct:union?}} {{^struct:union?}} } {{/struct:union?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/member_or_ptr.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:cpp_ref?}}{{^field:intern_boxed_ref?}}*ptr{{/field:intern_boxed_ref?}}{{#field:intern_boxed_ref?}}ptr.mut(){{/field:intern_boxed_ref?}}{{/field:cpp_ref?}}{{^field:cpp_ref?}}{{ > field/member}}{{/field:cpp_ref?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/optional_has_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. // If an optional field is set. }}{{#field:optional?}}{{! }}{{#field:cpp_ref?}}{{! // For references, check if the field is not null and whether there is lazily deserialized data }}{{#field:lazy?}}!(__fbthrift_isDeserialized_.{{field:cpp_name}} & ::apache::thrift::detail::LazyDeserializationState::DESERIALIZED) || {{/field:lazy?}}{{ > field/member}}{{! }}{{/field:cpp_ref?}}{{! }}{{^field:cpp_ref?}}{{! // For other values, check __isset status. We don't use field access API // since if field is lazy field, we don't want to deserialize it }}this->__isset.get({{field:isset_index}}){{! }}{{/field:cpp_ref?}}{{! }}{{/field:optional?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/pm.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The instance of protocol methods to use. }}::apache::thrift::detail::pm::protocol_methods<{{type:type_class_with_indirection}}, {{type:cpp_standard_type}}> )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/pm_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The field value to use with protocol methods. }}{{#type:cpp_adapter}}{{type:cpp_adapter}}::toThrift({{/type:cpp_adapter}}{{#field:cpp_adapter}}{{field:cpp_adapter}}::toThrift({{/field:cpp_adapter}}{{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}{{#field:cpp_adapter}}){{/field:cpp_adapter}}{{#type:cpp_adapter}}){{/type:cpp_adapter}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/serialize_field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#field:type}} {{ > module_types_tcc/if_should_write}} {{#struct:union?}} {{/struct:union?}} constexpr int16_t kPrevFieldId = {{#first?}}{{#struct:indexing?}}::apache::thrift::detail::kSizeField.id{{/struct:indexing?}}{{^struct:indexing?}}0{{/struct:indexing?}}{{/first?}}{{^first?}}{{field:serialization_prev_field_key}}{{/first?}}; {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::detail::writeFieldBegin module_types_tcc/struct_type}}, {{field:key}}, kPrevFieldId>(*prot_, "{{field:name}}", {{^struct:union?}}previousFieldHasValue{{/struct:union?}}{{#struct:union?}}false{{/struct:union?}}); {{^struct:union?}} {{#struct:union?}} {{/struct:union?}} previousFieldHasValue = true; {{/struct:union?}} {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} indexWriter.recordFieldStart(); {{/field:lazy?}} {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} if constexpr (Protocol_::kHasIndexSupport()) { {{#struct:union?}} {{/struct:union?}} if (prot_->protocolType() == __fbthrift_protocol_) { {{#struct:union?}} {{/struct:union?}} auto lock = folly::make_shared_lock(__fbthrift_deserializationMutex_); {{#struct:union?}} {{/struct:union?}} if (__fbthrift_isDeserialized_.{{field:cpp_name}}.load() == ::apache::thrift::detail::LazyDeserializationState::UNTAINTED) { {{#struct:union?}} {{/struct:union?}} xfer += prot_->writeRaw({{#field:lazy_ref?}}*{{/field:lazy_ref?}}__fbthrift_serializedData_.{{field:cpp_name}}); {{#struct:union?}} {{/struct:union?}} goto written_lazy_field_{{field:cpp_name}}; {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} {{#struct:union?}} {{/struct:union?}} std::as_const(*this).__fbthrift_read_field_{{field:cpp_name}}(); {{/field:lazy?}} {{^field:non_opt_cpp_ref?}} {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::encode<{{field:type_tag}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::write(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:use_op_encode?}} {{/field:non_opt_cpp_ref?}} {{#field:non_opt_cpp_ref?}} {{#struct:union?}} {{/struct:union?}} if ({{ > field/member}}) { {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::encode<{{field:type_tag}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::write(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:use_op_encode?}} {{#type:resolves_to_container_or_enum?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->write{{ > module_types_tcc/struct_field_type}}Begin({{ > module_types_tcc/container_struct_type}}, 0); {{#struct:union?}} {{/struct:union?}} xfer += prot_->write{{ > module_types_tcc/struct_field_type}}End(); {{/type:resolves_to_container_or_enum?}} {{#type:struct?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->writeStructBegin("{{type:name}}"); {{#struct:union?}} {{/struct:union?}} xfer += prot_->writeStructEnd(); {{#struct:union?}} {{/struct:union?}} xfer += prot_->writeFieldStop(); {{/type:struct?}} {{#struct:union?}} {{/struct:union?}} } {{/field:non_opt_cpp_ref?}} {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} written_lazy_field_{{field:cpp_name}}: {{#struct:union?}} {{/struct:union?}} indexWriter.template recordFieldEnd module_types_tcc/pm_value}})>({{type:type_class_with_indirection}}{}, {{field:key}}); {{/field:lazy?}} {{#struct:union?}} {{/struct:union?}} xfer += prot_->writeFieldEnd(); {{#struct:union?}} {{ > module_types_tcc/if_should_write_end}} {{/struct:union?}} {{^struct:union?}} {{#field:optional?}} } else { previousFieldHasValue = false; } {{/field:optional?}} {{#field:deprecated_terse_writes?}} } else { previousFieldHasValue = false; } {{/field:deprecated_terse_writes?}} {{#field:terse?}} } else { previousFieldHasValue = false; } {{/field:terse?}} {{^field:optional?}}{{^field:deprecated_terse_writes?}}{{^field:terse?}} } {{/field:terse?}}{{/field:deprecated_terse_writes?}}{{/field:optional?}} {{/struct:union?}} {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/serialize_field_size.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#field:type}} {{ > module_types_tcc/if_should_write}} {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedFieldSize("{{field:name}}", apache::thrift::protocol::{{ > module_types_tcc/struct_type}}, {{field:key}}); {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} if constexpr (Protocol_::kHasIndexSupport()) { {{#struct:union?}} {{/struct:union?}} if (prot_->protocolType() == __fbthrift_protocol_) { {{#struct:union?}} {{/struct:union?}} auto lock = folly::make_shared_lock(__fbthrift_deserializationMutex_); {{#struct:union?}} {{/struct:union?}} if (__fbthrift_isDeserialized_.{{field:cpp_name}}.load() == ::apache::thrift::detail::LazyDeserializationState::UNTAINTED) { {{#struct:union?}} {{/struct:union?}} xfer += ({{#field:lazy_ref?}}*{{/field:lazy_ref?}}__fbthrift_serializedData_.{{field:cpp_name}}).computeChainDataLength(); {{#struct:union?}} {{/struct:union?}} goto written_lazy_field_{{field:cpp_name}}; {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} {{#struct:union?}} {{/struct:union?}} std::as_const(*this).__fbthrift_read_field_{{field:cpp_name}}(); {{/field:lazy?}} {{^field:non_opt_cpp_ref?}} {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::serialized_size(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{^field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::serializedSize(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:cpp_exactly_one_adapter?}} {{#field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::adapt_detail::serializedSize(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}, [&] {return {{ > module_types_tcc/pm}}::serializedSize(*prot_, {{ > module_types_tcc/pm_value}});}); {{/field:cpp_exactly_one_adapter?}} {{/field:use_op_encode?}} {{/field:non_opt_cpp_ref?}} {{#field:non_opt_cpp_ref?}} {{#struct:union?}} {{/struct:union?}} if ({{ > field/member}}) { {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::serialized_size(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{^field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::serializedSize(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:cpp_exactly_one_adapter?}} {{#field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::adapt_detail::serializedSize(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}, [&] {return {{ > module_types_tcc/pm}}::serializedSize(*prot_, {{ > module_types_tcc/pm_value}});}); {{/field:cpp_exactly_one_adapter?}} {{/field:use_op_encode?}} {{#type:resolves_to_container_or_enum?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSize{{ > module_types_tcc/struct_field_type}}Begin({{ > module_types_tcc/container_struct_type}}, 0); {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSize{{ > module_types_tcc/struct_field_type}}End(); {{/type:resolves_to_container_or_enum?}} {{#type:struct?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedStructSize("{{type:name}}"); {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSizeStop(); {{/type:struct?}} {{#struct:union?}} {{/struct:union?}} } {{/field:non_opt_cpp_ref?}} {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} written_lazy_field_{{field:cpp_name}}:; {{/field:lazy?}} {{ > module_types_tcc/if_should_write_end}} {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/serialize_field_size_zc.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#field:type}} {{ > module_types_tcc/if_should_write}} {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedFieldSize("{{field:name}}", apache::thrift::protocol::{{ > module_types_tcc/struct_type}}, {{field:key}}); {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} if constexpr (Protocol_::kHasIndexSupport()) { {{#struct:union?}} {{/struct:union?}} if (prot_->protocolType() == __fbthrift_protocol_) { {{#struct:union?}} {{/struct:union?}} auto lock = folly::make_shared_lock(__fbthrift_deserializationMutex_); {{#struct:union?}} {{/struct:union?}} if (__fbthrift_isDeserialized_.{{field:cpp_name}}.load() == ::apache::thrift::detail::LazyDeserializationState::UNTAINTED) { {{#struct:union?}} {{/struct:union?}} goto written_lazy_field_{{field:cpp_name}}; {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} } {{#struct:union?}} {{/struct:union?}} {{#struct:union?}} {{/struct:union?}} std::as_const(*this).__fbthrift_read_field_{{field:cpp_name}}(); {{/field:lazy?}} {{^field:non_opt_cpp_ref?}} {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::serialized_size<{{field:zero_copy_arg}}, {{field:type_tag}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{^field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::serializedSize<{{field:zero_copy_arg}}>(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:cpp_exactly_one_adapter?}} {{#field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::adapt_detail::serializedSize<{{field:zero_copy_arg}}, {{field:type_tag}}, {{field:cpp_first_adapter}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}, [&] {return {{ > module_types_tcc/pm}}::serializedSize<{{field:zero_copy_arg}}>(*prot_, {{ > module_types_tcc/pm_value}});}); {{/field:cpp_exactly_one_adapter?}} {{/field:use_op_encode?}} {{/field:non_opt_cpp_ref?}} {{#field:non_opt_cpp_ref?}} {{#struct:union?}} {{/struct:union?}} if ({{ > field/member}}) { {{#field:use_op_encode?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::op::serialized_size<{{field:zero_copy_arg}}, {{field:type_tag}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}); {{/field:use_op_encode?}} {{^field:use_op_encode?}} {{^field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += {{ > module_types_tcc/pm}}::serializedSize<{{field:zero_copy_arg}}>(*prot_, {{ > module_types_tcc/pm_value}}); {{/field:cpp_exactly_one_adapter?}} {{#field:cpp_exactly_one_adapter?}} {{#struct:union?}} {{/struct:union?}} xfer += ::apache::thrift::adapt_detail::serializedSize<{{field:zero_copy_arg}}, {{field:type_tag}}, {{field:cpp_first_adapter}}>(*prot_, {{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}, [&] {return {{ > module_types_tcc/pm}}::serializedSize<{{field:zero_copy_arg}}>(*prot_, {{ > module_types_tcc/pm_value}});}); {{/field:cpp_exactly_one_adapter?}} {{/field:use_op_encode?}} {{#type:resolves_to_container_or_enum?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSize{{ > module_types_tcc/struct_field_type}}Begin({{ > module_types_tcc/container_struct_type}}, 0); {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSize{{ > module_types_tcc/struct_field_type}}End(); {{/type:resolves_to_container_or_enum?}} {{#type:struct?}} {{#struct:union?}} {{/struct:union?}} } else { {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedStructSize("{{type:name}}"); {{#struct:union?}} {{/struct:union?}} xfer += prot_->serializedSizeStop(); {{/type:struct?}} {{#struct:union?}} {{/struct:union?}} } {{/field:non_opt_cpp_ref?}} {{#field:lazy?}} {{#struct:union?}} {{/struct:union?}} written_lazy_field_{{field:cpp_name}}:; {{/field:lazy?}} {{ > module_types_tcc/if_should_write_end}} {{/field:type}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/serialize_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}template uint32_t {{struct:cpp_underlying_name}}::serializedSize(Protocol_ const* prot_) const { uint32_t xfer = 0; xfer += prot_->serializedStructSize("{{struct:name}}"); {{#struct:fields_in_serialization_order}} {{ > module_types_tcc/serialize_field_size}} {{/struct:fields_in_serialization_order}} xfer += prot_->serializedSizeStop(); return xfer; } template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC(Protocol_ const* prot_) const { uint32_t xfer = 0; xfer += prot_->serializedStructSize("{{struct:name}}"); {{#struct:fields_in_serialization_order}} {{ > module_types_tcc/serialize_field_size_zc}} {{/struct:fields_in_serialization_order}} xfer += prot_->serializedSizeStop(); return xfer; } {{^program:tablebased?}} template uint32_t {{struct:cpp_underlying_name}}::write(Protocol_* prot_) const { uint32_t xfer = 0; xfer += prot_->writeStructBegin("{{struct:name}}"); {{#struct:indexing?}} ::apache::thrift::detail::IndexWriter indexWriter(prot_, xfer, {{struct:write_lazy_field_checksum}}); {{/struct:indexing?}} {{#struct:fields?}} bool previousFieldHasValue = true; {{/struct:fields?}} {{#struct:fields_in_serialization_order}} {{ > module_types_tcc/serialize_field}} {{/struct:fields_in_serialization_order}} {{#struct:indexing?}} indexWriter.finalize(); {{/struct:indexing?}} xfer += prot_->writeFieldStop(); xfer += prot_->writeStructEnd(); return xfer; } {{/program:tablebased?}} {{#program:tablebased?}} template uint32_t {{struct:cpp_underlying_name}}::write(Protocol_* iprot) const { return ::apache::thrift::detail::write( iprot, ::apache::thrift::detail::toStructInfo( {{ > common/namespace_cpp2}}__fbthrift_struct_info_{{struct:cpp_underlying_name}} ), this); } {{/program:tablebased?}} {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/serialize_union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}template uint32_t {{struct:cpp_underlying_name}}::serializedSize(Protocol_ const* prot_) const { uint32_t xfer = 0; xfer += prot_->serializedStructSize("{{struct:name}}"); switch(this->getType()) { {{#struct:fields}} {{ > module_types_tcc/serialize_field_size}} {{/struct:fields}} case {{struct:cpp_underlying_name}}::Type::__EMPTY__:; } xfer += prot_->serializedSizeStop(); return xfer; } template uint32_t {{struct:cpp_underlying_name}}::serializedSizeZC(Protocol_ const* prot_) const { uint32_t xfer = 0; xfer += prot_->serializedStructSize("{{struct:name}}"); switch(this->getType()) { {{#struct:fields}} {{ > module_types_tcc/serialize_field_size_zc}} {{/struct:fields}} case {{struct:cpp_underlying_name}}::Type::__EMPTY__:; } xfer += prot_->serializedSizeStop(); return xfer; } {{^program:tablebased?}} template uint32_t {{struct:cpp_underlying_name}}::write(Protocol_* prot_) const { uint32_t xfer = 0; xfer += prot_->writeStructBegin("{{struct:name}}"); switch(this->getType()) { {{#struct:fields}} {{ > module_types_tcc/serialize_field}} {{/struct:fields}} case {{struct:cpp_underlying_name}}::Type::__EMPTY__:; } xfer += prot_->writeFieldStop(); xfer += prot_->writeStructEnd(); return xfer; } {{/program:tablebased?}} {{#program:tablebased?}} template uint32_t {{struct:cpp_underlying_name}}::write(Protocol_* iprot) const { return ::apache::thrift::detail::write( iprot, ::apache::thrift::detail::toStructInfo( {{ > common/namespace_cpp2}}__fbthrift_struct_info_{{struct:cpp_underlying_name}} ), this); } {{/program:tablebased?}} {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/struct_field_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:void?}}Void{{/type:void?}}{{! }}{{#type:string?}}String{{/type:string?}}{{! }}{{#type:binary?}}Binary{{/type:binary?}}{{! }}{{#type:bool?}}Bool{{/type:bool?}}{{! }}{{#type:byte?}}Byte{{/type:byte?}}{{! }}{{#type:i16?}}I16{{/type:i16?}}{{! }}{{#type:i32?}}I32{{/type:i32?}}{{! }}{{#type:i64?}}I64{{/type:i64?}}{{! }}{{#type:double?}}Double{{/type:double?}}{{! }}{{#type:float?}}Float{{/type:float?}}{{! }}{{#type:set?}}Set{{/type:set?}}{{! }}{{#type:map?}}Map{{/type:map?}}{{! }}{{#type:list?}}List{{/type:list?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/struct_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:void?}}T_VOID{{/type:void?}}{{! }}{{#type:string_or_binary?}}T_STRING{{/type:string_or_binary?}}{{! }}{{#type:bool?}}T_BOOL{{/type:bool?}}{{! }}{{#type:byte?}}T_BYTE{{/type:byte?}}{{! }}{{#type:i16?}}T_I16{{/type:i16?}}{{! }}{{#type:i32?}}T_I32{{/type:i32?}}{{! }}{{#type:i64?}}T_I64{{/type:i64?}}{{! }}{{#type:double?}}T_DOUBLE{{/type:double?}}{{! }}{{#type:float?}}T_FLOAT{{/type:float?}}{{! }}{{#type:enum?}}T_I32{{/type:enum?}}{{! }}{{#type:map?}}T_MAP{{/type:map?}}{{! }}{{#type:set?}}T_SET{{/type:set?}}{{! }}{{#type:list?}}T_LIST{{/type:list?}}{{! }}{{#type:struct?}}T_STRUCT{{/type:struct?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/tcc_struct_traits.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} namespace apache { namespace thrift { namespace detail { {{#program:structs}} template <> struct TccStructTraits<{{struct:cpp_fullname}}> { static void translateFieldName( std::string_view _fname, int16_t& fid, apache::thrift::protocol::TType& _ftype) noexcept; }; {{/program:structs}} } // namespace detail } // namespace thrift } // namespace apache {{! }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/terse_has_no_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:intern_boxed_ref?}}{{! }}({{ > field/member}}.get() == &::apache::thrift::op::getIntrinsicDefault<{{ > field/tag}}>() || ::apache::thrift::op::isEmpty<{{ > field/tag}}>(*{{ > field/member}})){{! }}{{/field:intern_boxed_ref?}}{{! }}{{^field:intern_boxed_ref?}}{{! }}{{#field:cpp_ref?}}{{ > field/member}} && {{/field:cpp_ref?}}::apache::thrift::op::isEmpty<{{ > field/tag}}>({{#field:cpp_ref?}}*{{/field:cpp_ref?}}{{ > field/member}}){{! }}{{/field:intern_boxed_ref?}} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/terse_has_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}!({{ > module_types_tcc/terse_has_no_value }}) )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/union_setters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} )__FBTHRIFT_TAG__", // cpp2/module_types_tcc/variable_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:set?}}{{#type:set_elem_type}}_r{{ > module_types_tcc/variable_name}}{{/type:set_elem_type}}{{/type:set?}} )__FBTHRIFT_TAG__", // cpp2/module_visit_by_thrift_field_metadata.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include "{{program:include_prefix}}{{program:name}}_metadata.h" namespace apache { namespace thrift { namespace detail { {{#program:structs}} template <> struct VisitByFieldId<{{struct:cpp_fullname}}> { template void operator()([[maybe_unused]] F&& f, int32_t fieldId, [[maybe_unused]] T&& t) const { switch (fieldId) { {{#struct:fields}} case {{field:key}}: return f({{field:index}}, static_cast(t).{{field:cpp_name}}_ref()); {{/struct:fields}} default: throwInvalidThriftId(fieldId, "{{struct:cpp_fullname}}"); } } }; {{/program:structs}} } // namespace detail } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_visit_union.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{program:include_prefix}}{{program:name}}_metadata.h" #include namespace apache { namespace thrift { namespace detail { {{#program:structs}} {{#struct:union?}} template <> struct VisitUnion<{{struct:cpp_fullname}}> { template decltype(auto) operator()([[maybe_unused]] F&& f, T&& t) const { using Union = std::remove_reference_t; switch (t.getType()) { {{#struct:fields}} case Union::Type::{{field:cpp_name}}: return f({{field:index}}, *static_cast(t).{{field:cpp_name}}_ref()); {{/struct:fields}} case Union::Type::__EMPTY__: {{#struct:fields}}{{#first?}} return decltype(f({{field:index}}, *static_cast(t).{{field:cpp_name}}_ref()))(); {{/first?}}{{/struct:fields}} {{^struct:fields}} (void)0; {{/struct:fields}} } } }; {{/struct:union?}} {{/program:structs}} } // namespace detail } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // cpp2/module_visitation.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once {{#program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_visitation.h" {{/program:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_for_each_field.h" #include "{{program:include_prefix}}{{program:name}}_visit_union.h" #include "{{program:include_prefix}}{{program:name}}_visit_by_thrift_field_metadata.h" )__FBTHRIFT_TAG__", // cpp2/service.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include "{{service:include_prefix}}{{service:name}}.h" #include "{{service:include_prefix}}{{service:name}}.tcc" #include "{{service:include_prefix}}{{service:program_name}}_metadata.h" {{#service:has_service_schema}} #include "{{service:include_prefix}}{{service:program_name}}_constants.h" {{/service:has_service_schema}} #include {{ > service_cpp/handlers_cpp}} )__FBTHRIFT_TAG__", // cpp2/service.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include #include "{{service:include_prefix}}{{service:name}}AsyncClient.h" #include "{{service:include_prefix}}{{service:program_name}}_types.h" {{#service:extends}} #if __has_include("{{service:include_prefix}}{{service:name}}.h") #include "{{service:include_prefix}}{{service:name}}.h" #else #include "{{service:include_prefix}}{{service:program_name}}_handlers.h" #endif {{/service:extends}} {{#service:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types.h" {{/service:thrift_includes}} {{#service:cpp_includes}} #include {{cpp_include}} {{/service:cpp_includes}} {{^service:interactions?}} {{#service:streams?}} #include {{/service:streams?}} {{#service:sinks?}} #include {{/service:sinks?}} {{/service:interactions?}} {{#service:interactions?}} #include #include {{/service:interactions?}} namespace folly { class IOBuf; class IOBufQueue; } namespace apache { namespace thrift { class Cpp2RequestContext; class BinaryProtocolReader; class CompactProtocolReader; namespace transport { class THeader; } }} {{ > service_h/handlers_h}} )__FBTHRIFT_TAG__", // cpp2/service.tcc.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #pragma once #include "{{service:include_prefix}}{{service:name}}.h" #include {{ > service_cpp/service_inl}} )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/coroutine_functions.mustache R"__FBTHRIFT_TAG__({{! Copyright 2019 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} #if FOLLY_HAS_COROUTINES {{#function:sink?}} folly::coro::Task<{{ > types/return_type_client}}> {{ > service_common/client_class_name}}::co_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; co_return co_await co_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}}); } folly::coro::Task<{{ > types/return_type_client}}> {{ > service_common/client_class_name}}::co_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = {{function:cpp_name}}Ctx(&rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; auto wrappedCallback = apache::thrift::createSinkClientCallback( apache::thrift::RequestClientCallback::Ptr(apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback))); {{#function:creates_interaction?}} {{function:created_interaction}} handle(channel_, "{{function:created_interaction}}"); {{/function:creates_interaction?}} {{function:cpp_name}}Impl(rpcOptions, std::move(header), ctx.get(), wrappedCallback{{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); {{^function:creates_interaction?}} co_return recv_{{function:cpp_name}}(returnState); {{/function:creates_interaction?}} {{#function:creates_interaction?}} co_return std::make_pair( std::move(handle), recv_{{function:cpp_name}}(returnState) ); {{/function:creates_interaction?}} } {{/function:sink?}}{{! Other coroutine functions are inline templates to prevent binary size regression }} #endif // FOLLY_HAS_COROUTINES )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/function_implementation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{^function:sink?}}{{^service:reduced_client?}}{{^function:creates_interaction?}} void {{ > service_common/client_class_name}}::{{function:cpp_name}}(std::unique_ptr callback{{function:comma}}{{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; {{function:cpp_name}}(rpcOptions, std::move(callback){{function:comma}}{{ > service_common/param_list}}); } {{/function:creates_interaction?}}{{/service:reduced_client?}} void {{ > service_common/client_class_name}}::{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}) { auto [ctx, header] = {{function:cpp_name}}Ctx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; {{#function:oneway?}} callbackContext.oneWay = true; {{/function:oneway?}} callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } {{^function:stream?}} auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); {{/function:stream?}}{{#function:stream?}} auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)), rpcOptions.getBufferOptions()); {{/function:stream?}} {{function:cpp_name}}Impl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } {{/function:sink?}} void {{ > service_common/client_class_name}}::{{function:cpp_name}}Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, {{ > types/callback_type}} callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { {{function:cpp_name}}T(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } else { {{function:cpp_name}}T(&writer, rpcOptions, std::move(header), contextStack, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { {{function:cpp_name}}T(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } else { {{function:cpp_name}}T(&writer, rpcOptions, std::move(header), contextStack, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> {{ > service_common/client_class_name}}::{{function:cpp_name}}Ctx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, getServiceName(), "{{service:parent_service_name}}.{{ > common/function_name}}", *header); return {std::move(ctx), std::move(header)}; } )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/future_functions.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{^service:reduced_client?}}{{^function:creates_interaction?}} {{^function:stream?}} folly::Future<{{ > types/return_type_client_lift_unit}}> {{ > service_common/client_class_name}}::future_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; return future_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}}); } {{/function:stream?}} {{/function:creates_interaction?}}{{/service:reduced_client?}} folly::SemiFuture<{{ > types/return_type_client_lift_unit}}> {{ > service_common/client_class_name}}::semifuture_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; return semifuture_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}}); } {{^service:reduced_client?}}{{^function:creates_interaction?}} {{^function:stream?}} folly::Future<{{ > types/return_type_client_lift_unit}}> {{ > service_common/client_class_name}}::future_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { folly::Promise<{{ > types/return_type_client_lift_unit}}> promise; auto future = promise.getFuture(); {{#function:oneway?}} auto callback = std::make_unique(std::move(promise), channel_); {{/function:oneway?}} {{^function:oneway?}} auto callback = std::make_unique types/return_type_client_lift_unit}}>>(std::move(promise), recv_wrapped_{{function:cpp_name}}, channel_); {{/function:oneway?}} {{function:cpp_name}}(rpcOptions, std::move(callback){{function:comma}}{{ > service_common/param_list}}); return future; } {{/function:stream?}} {{/function:creates_interaction?}}{{/service:reduced_client?}} folly::SemiFuture<{{ > types/return_type_client_lift_unit}}> {{ > service_common/client_class_name}}::semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { {{#function:oneway?}} auto callbackAndFuture = makeOneWaySemiFutureCallback(channel_); {{/function:oneway?}} {{^function:oneway?}} auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_{{function:cpp_name}}, channel_); {{/function:oneway?}} {{#function:creates_interaction?}} {{function:created_interaction}} handle(channel_, "{{function:created_interaction}}"); {{/function:creates_interaction?}} auto callback = std::move(callbackAndFuture.first); {{function:cpp_name}}(rpcOptions, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); {{^function:creates_interaction?}} return std::move(callbackAndFuture.second); {{/function:creates_interaction?}} {{#function:creates_interaction?}} return std::move(callbackAndFuture.second).deferValue([handle = std::move(handle)](auto&&{{^type:void?}} val{{/type:void?}}) mutable { {{^type:void?}} return std::make_pair(std::move(handle), std::move(val)); {{/type:void?}} {{#type:void?}} return std::move(handle); {{/type:void?}} }); {{/function:creates_interaction?}} } {{#function:creates_interaction?}} std::pair< apache::thrift::Client<{{service:parent_service_qualified_name}}>::{{function:created_interaction}}, folly::SemiFuture<{{^type:void?}}{{ > types/return_type_client_no_handle}}{{/type:void?}}{{#type:void?}}folly::Unit{{/type:void?}}> > {{ > service_common/client_class_name}}::eager_semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_{{function:cpp_name}}, channel_); {{function:created_interaction}} handle(channel_, "{{function:created_interaction}}"); auto callback = std::move(callbackAndFuture.first); {{function:cpp_name}}(rpcOptions, std::move(callback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); return std::make_pair(std::move(handle), std::move(callbackAndFuture.second)); } {{/function:creates_interaction?}} {{^function:oneway?}}{{^service:reduced_client?}}{{^function:creates_interaction?}} {{^function:stream?}} folly::Future types/return_type_client_lift_unit}}, std::unique_ptr>> {{ > service_common/client_class_name}}::header_future_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { folly::Promise types/return_type_client_lift_unit}}, std::unique_ptr>> promise; auto future = promise.getFuture(); auto callback = std::make_unique types/return_type_client_lift_unit}}>>(std::move(promise), recv_wrapped_{{function:cpp_name}}, channel_); {{function:cpp_name}}(rpcOptions, std::move(callback){{function:comma}}{{ > service_common/param_list}}); return future; } {{/function:stream?}} folly::SemiFuture types/return_type_client_lift_unit}}, std::unique_ptr>> {{ > service_common/client_class_name}}::header_semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_{{function:cpp_name}}, channel_); auto callback = std::move(callbackAndFuture.first); {{function:cpp_name}}(rpcOptions, std::move(callback){{function:comma}}{{ > service_common/param_list}}); return std::move(callbackAndFuture.second); } {{/function:creates_interaction?}}{{/service:reduced_client?}}{{/function:oneway?}} )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/received.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:sync_returns_by_outparam?}} {{ > types/return_type_client_no_handle}} {{ > service_common/client_class_name}}::recv_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state) { {{#function:cpp_void?}} auto ew = recv_wrapped_{{function:cpp_name}}(state); {{/function:cpp_void?}} {{^function:cpp_void?}} {{ > types/return_type_client_no_handle}} _return; auto ew = recv_wrapped_{{function:cpp_name}}(_return, state); {{/function:cpp_void?}} {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} void {{ > service_common/client_class_name}}::recv_{{function:cpp_name}}({{function:cpp_return_type}}& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_{{function:cpp_name}}(_return, state); {{/function:sync_returns_by_outparam?}} if (ew) { ew.throw_exception(); } {{^function:sync_returns_by_outparam?}} {{^function:cpp_void?}} return _return; {{/function:cpp_void?}} {{/function:sync_returns_by_outparam?}} } )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/received_instance.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^type:resolves_to_complex_return?}} {{ > types/return_type_client}} {{ > service_common/client_class_name}}::recv_instance_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state) { {{#function:cpp_void?}} recv_{{function:cpp_name}}(state); {{/function:cpp_void?}} {{^function:cpp_void?}} return recv_{{function:cpp_name}}(state); {{/function:cpp_void?}} } {{/type:resolves_to_complex_return?}} {{#type:resolves_to_complex_return?}} void {{ > service_common/client_class_name}}::recv_instance_{{function:cpp_name}}({{function:cpp_return_type}}& _return, ::apache::thrift::ClientReceiveState& state) { return recv_{{function:cpp_name}}(_return, state); } {{/type:resolves_to_complex_return?}} {{#function:cpp_void?}} folly::exception_wrapper {{ > service_common/client_class_name}}::recv_instance_wrapped_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state) { return recv_wrapped_{{function:cpp_name}}(state); } {{/function:cpp_void?}} {{^function:cpp_void?}} folly::exception_wrapper {{ > service_common/client_class_name}}::recv_instance_wrapped_{{function:cpp_name}}({{ > types/return_type_client}}& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_{{function:cpp_name}}(_return, state); } {{/function:cpp_void?}} )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/received_wrapped.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:cpp_void?}}{{! }}folly::exception_wrapper {{ > service_common/client_class_name}}::recv_wrapped_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state) { {{/function:cpp_void?}} {{^function:cpp_void?}} folly::exception_wrapper {{ > service_common/client_class_name}}::recv_wrapped_{{function:cpp_name}}({{ > types/return_type_client_no_handle}}& _return, ::apache::thrift::ClientReceiveState& state) { {{/function:cpp_void?}} if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult; {{#function:sink?}} {{^function:sink_exceptions?}} using ExMapType = apache::thrift::detail::ap::EmptyExMapType; {{/function:sink_exceptions?}} {{#function:sink_exceptions?}} struct ExMapType { bool operator()(typename result::SinkPResultType& res, folly::exception_wrapper ew) { {{#function:sink_exceptions}} if (ew.with_exception([&]({{#field:type}}{{ > common/type_namespace_cpp2}}{{type:name}}{{/field:type}}& e) { res.get<{{field:index_plus_one}}>().ref() = e; res.setIsSet({{field:index_plus_one}}, true); })) { return true; } {{/function:sink_exceptions}} return false; } }; {{/function:sink_exceptions?}} {{/function:sink?}} switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; {{#function:sink?}} return apache::thrift::detail::ac::recv_wrapped( &reader, state{{^function:cpp_void?}}, state.extractSink(), _return{{/function:cpp_void?}}); {{/function:sink?}} {{^function:sink?}} return apache::thrift::detail::ac::recv_wrapped( &reader, state{{^function:cpp_void?}}, _return{{/function:cpp_void?}}); {{/function:sink?}} } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; {{#function:sink?}} return apache::thrift::detail::ac::recv_wrapped( &reader, state{{^function:cpp_void?}}, state.extractSink(), _return{{/function:cpp_void?}}); {{/function:sink?}} {{^function:sink?}} return apache::thrift::detail::ac::recv_wrapped( &reader, state{{^function:cpp_void?}}, _return{{/function:cpp_void?}}); {{/function:sink?}} } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/sync_functions.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:sync_returns_by_outparam?}} {{ > types/return_type_client}} {{ > service_common/client_class_name}}::sync_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; {{#function:void?}} sync_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}}); {{/function:void?}} {{^function:void?}} return sync_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}}); {{/function:void?}} {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} void {{ > service_common/client_class_name}}::sync_{{function:cpp_name}}({{function:cpp_return_type}}& _return{{function:comma}}{{ > service_common/function_param_list_client}}) { ::apache::thrift::RpcOptions rpcOptions; sync_{{function:cpp_name}}(rpcOptions, _return{{function:comma}}{{ > service_common/param_list}}); {{/function:sync_returns_by_outparam?}} } {{^function:sync_returns_by_outparam?}} {{ > types/return_type_client}} {{ > service_common/client_class_name}}::sync_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} void {{ > service_common/client_class_name}}::sync_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions, {{function:cpp_return_type}}& _return{{function:comma}}{{ > service_common/function_param_list_client}}) { {{/function:sync_returns_by_outparam?}} apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback<{{#function:oneway?}}true{{/function:oneway?}}{{^function:oneway?}}false{{/function:oneway?}}> callback(&returnState); {{^function:oneway?}} auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); {{/function:oneway?}} auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = {{function:cpp_name}}Ctx(&rpcOptions); {{^function:stream?}} auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); {{/function:stream?}}{{#function:stream?}} auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(&callback), rpcOptions.getBufferOptions()); {{/function:stream?}} {{#function:creates_interaction?}} {{function:created_interaction}} handle(channel_, "{{function:created_interaction}}"); {{/function:creates_interaction?}} callback.waitUntilDone( evb, [&] { {{function:cpp_name}}Impl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); }); if (returnState.isException()) { returnState.exception().throw_exception(); } {{^function:oneway?}} returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { {{^function:sync_returns_by_outparam?}} {{#function:void?}} recv_{{function:cpp_name}}(returnState); {{/function:void?}} {{^function:void?}} {{^function:creates_interaction?}} return recv_{{function:cpp_name}}(returnState); {{/function:creates_interaction?}} {{#function:creates_interaction?}} {{^type:void?}} return std::make_pair( std::move(handle), recv_{{function:cpp_name}}(returnState) ); {{/type:void?}} {{#type:void?}} recv_{{function:cpp_name}}(returnState); return std::move(handle); {{/type:void?}} {{/function:creates_interaction?}} {{/function:void?}} {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} recv_{{function:cpp_name}}(_return, returnState); {{/function:sync_returns_by_outparam?}} }); {{/function:oneway?}} } {{#type:sync_methods_return_try?}}{{^function:oneway?}} {{^function:sink?}} folly::Try types/return_type_client}}>> {{ > service_common/client_class_name}}::sync_complete_{{function:cpp_name}}( apache::thrift::RpcOptions&& rpcOptions{{function:comma}} {{ > service_common/function_param_list_client}}) { apache::thrift::ClientReceiveState returnState; auto ctxAndHeader = {{function:cpp_name}}Ctx(&rpcOptions); apache::thrift::ClientSyncCallback callback(&returnState); const auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* const evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); {{^function:stream?}} auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); {{/function:stream?}}{{#function:stream?}} auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(&callback), rpcOptions.getBufferOptions()); {{/function:stream?}} callback.waitUntilDone( evb, [&] { {{function:cpp_name}}Impl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback){{function:comma}}{{ > service_common/param_list}}, true); }); returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); folly::Try types/return_type_client}}>> tryResponse; if (auto* header = returnState.header()) { rpcOptions.setRoutingData(header->releaseRoutingData()); } if (!returnState.hasResponseBuffer()) { assert(returnState.isException()); tryResponse.emplaceException(std::move(returnState.exception())); } else { tryResponse.emplace(); tryResponse->responseContext.rpcTransportStats = returnState.getRpcTransportStats(); if (auto* header = returnState.header()) { if (!header->getHeaders().empty()) { tryResponse->responseContext.headers = header->releaseHeaders(); } if (auto load = header->getServerLoad()) { tryResponse->responseContext.serverLoad = *load; } } tryResponse->response.emplace(); auto ew = folly::fibers::runInMainContext([&] { {{#type:void?}} return recv_wrapped_{{function:cpp_name}}(returnState); {{/type:void?}} {{^type:void?}} return recv_wrapped_{{function:cpp_name}}(tryResponse->response.value(), returnState); {{/type:void?}} }); if (ew) { tryResponse->response.emplaceException(std::move(ew)); } } return tryResponse; } {{/function:sink?}} {{/function:oneway?}}{{/type:sync_methods_return_try?}} )__FBTHRIFT_TAG__", // cpp2/service_async_client_cpp/templated_received.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} template void {{ > service_common/client_class_name}}::{{function:cpp_name}}T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, {{ > types/callback_type}} callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}) { {{#function:in_or_creates_interaction?}} apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction({{#function:creates_interaction?}}handle, {{/function:creates_interaction?}}rpcOpts); {{/function:in_or_creates_interaction?}} {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_pargs args; {{#function:args}}{{#field:type}} {{^type:resolves_to_complex_return?}} args.get<{{field:index}}>().value = &p_{{field:cpp_name}}; {{/type:resolves_to_complex_return?}} {{#type:resolves_to_complex_return?}} args.get<{{field:index}}>().value = const_cast<{{type:cpp_type}}*>(&p_{{field:cpp_name}}); {{/type:resolves_to_complex_return?}} {{/field:type}}{{/function:args}}{{! }} auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "{{ > common/function_name}}", ::apache::thrift::FunctionQualifier::{{function:qualifier}}, "{{service:thrift_uri_or_service_name}}"{{#function:creates_interaction?}}, ::apache::thrift::InteractionMethodPosition::Factory, "{{function:created_interaction}}"{{/function:creates_interaction?}}{{#service:interaction?}}, ::apache::thrift::InteractionMethodPosition::Member, "{{service:name}}"{{/service:interaction?}}); apache::thrift::clientSendT<{{ > types/function_kind}}, Protocol_>(prot, {{! }}{{#function:in_or_creates_interaction?}}std::move(rpcOpts){{/function:in_or_creates_interaction?}}{{! }}{{^function:in_or_creates_interaction?}}std::forward(rpcOptions){{/function:in_or_creates_interaction?}}{{! }}, std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_common/client_class_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:interaction?}}apache::thrift::Client<{{service:parent_service_qualified_name}}>::{{service:cpp_name}}{{/service:interaction?}}{{^service:interaction?}}apache::thrift::Client<{{service:qualified_name}}>{{/service:interaction?}} )__FBTHRIFT_TAG__", // cpp2/service_common/function_param_list_client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{^first?}}, {{/first?}}{{ > types/param_type_client}} p_{{field:cpp_name}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/function_param_list_interceptor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}const {{type:cpp_type}}& /*p_{{field:cpp_name}}*/{{^last?}}, {{/last?}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/function_param_list_server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{^first?}}, {{/first?}}{{ > types/param_type_server}} p_{{field:cpp_name}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/function_param_list_server_commented_out.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{^first?}}, {{/first?}}{{ > types/param_type_server}} /*{{field:cpp_name}}*/{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/param_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{^first?}}, {{/first?}}{{! }}p_{{field:cpp_name}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/param_list_move.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{^first?}}, {{/first?}}{{! }}{{#type:resolves_to_complex_return?}}{{! }}{{#function:stack_arguments?}}{{! }}p_{{field:cpp_name}}{{! }}{{/function:stack_arguments?}}{{! }}{{^function:stack_arguments?}}{{! }}std::move(p_{{field:cpp_name}}){{! }}{{/function:stack_arguments?}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{^type:resolves_to_complex_return?}}{{! }}p_{{field:cpp_name}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_common/service_class_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^service:interaction?}}{{! }}apache::thrift::ServiceHandler<{{service:qualified_name}}>{{! }}{{/service:interaction?}}{{! }}{{#service:interaction?}}{{! }}apache::thrift::ServiceHandler<{{service:parent_service_qualified_name}}>::{{service:cpp_name}}If{{! }}{{/service:interaction?}} )__FBTHRIFT_TAG__", // cpp2/service_common/sync_function_return_param_server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:sync_returns_by_outparam?}}{{! }}{{function:cpp_return_type}}& /*_return*/{{function:comma}}{{! }}{{/function:sync_returns_by_outparam?}} )__FBTHRIFT_TAG__", // cpp2/service_common/sync_function_return_type_server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:sync_returns_by_outparam?}}{{! }}{{ > types/return_type_server}}{{! }}{{/function:sync_returns_by_outparam?}}{{! }}{{#function:sync_returns_by_outparam?}}{{! }}void{{! }}{{/function:sync_returns_by_outparam?}} )__FBTHRIFT_TAG__", // cpp2/service_common/typedefs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:functions}}{{^function:starts_interaction?}} {{ > service_tcc/typedef_params}} {{ > service_tcc/typedef_result}} {{/function:starts_interaction?}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_cpp/async_client_cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > common/namespace_cpp2_begin}} {{ > service_common/typedefs}} {{ > common/namespace_cpp2_end}} {{ > service_async_client_cpp/templated_received}} {{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} {{ > service_async_client_cpp/function_implementation}} {{^function:sink?}} {{ > service_async_client_cpp/sync_functions}} {{ > service_async_client_cpp/future_functions}} {{^service:reduced_client?}}{{^function:creates_interaction?}}{{^function:stream?}} void apache::thrift::Client<{{service:qualified_name}}>::{{function:cpp_name}}(folly::Function callback{{function:comma}}{{ > service_common/function_param_list_client}}) { {{function:cpp_name}}(std::make_unique(std::move(callback)){{function:comma}}{{ > service_common/param_list}}); } {{/function:stream?}}{{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:sink?}} {{ > service_async_client_cpp/coroutine_functions}} {{^function:oneway?}} {{ > service_async_client_cpp/received_wrapped}} {{ > service_async_client_cpp/received}} {{^service:reduced_client?}}{{^function:creates_interaction?}} {{ > service_async_client_cpp/received_instance}} {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:oneway?}} {{/function:starts_interaction?}}{{#function:starts_interaction?}} apache::thrift::Client<{{service:parent_service_qualified_name}}>::{{type:name}} apache::thrift::Client<{{service:qualified_name}}>::{{function:cpp_name}}() { return {{type:name}}(channel_, "{{type:name}}"); } {{/function:starts_interaction?}} {{/function:return_type}}{{/service:functions}} {{#service:interactions}} {{ > common/namespace_cpp2_begin}} {{ > service_common/typedefs}} {{ > common/namespace_cpp2_end}} {{ > service_async_client_cpp/templated_received}} {{#service:functions}}{{#function:return_type}} {{ > service_async_client_cpp/function_implementation}} {{^function:sink?}} {{ > service_async_client_cpp/sync_functions}} {{ > service_async_client_cpp/future_functions}} {{/function:sink?}} {{ > service_async_client_cpp/coroutine_functions}} {{^function:oneway?}} {{ > service_async_client_cpp/received_wrapped}} {{ > service_async_client_cpp/received}} {{/function:oneway?}} {{/function:return_type}}{{/service:functions}} {{/service:interactions}} )__FBTHRIFT_TAG__", // cpp2/service_cpp/handlers_cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} std::unique_ptr {{ > service_common/service_class_name}}::getProcessor() { return std::make_unique<{{service:qualified_name}}AsyncProcessor>(this); } {{ > service_common/service_class_name}}::CreateMethodMetadataResult {{ > service_common/service_class_name}}::createMethodMetadata() { return ::apache::thrift::detail::ap::createMethodMetadataMap<{{service:qualified_name}}AsyncProcessor>(getServiceRequestInfoMap().value().get()); } {{#service:has_service_schema}} #if defined(THRIFT_SCHEMA_AVAILABLE) std::optional> {{ > service_common/service_class_name}}::getServiceMetadataV1() { return apache::thrift::detail::si::schemaAsOptionalVector({{service:program_qualified_name}}_constants::{{service:service_schema_name}}()); } #endif {{/service:has_service_schema}} std::optional> {{ > service_common/service_class_name}}::getServiceRequestInfoMap() const { return __fbthrift_serviceInfoHolder.requestInfoMap(); } {{^service:interaction?}} {{service:qualified_name}}ServiceInfoHolder {{ > service_common/service_class_name}}::__fbthrift_serviceInfoHolder; {{/service:interaction?}} {{ > service_cpp/service_interface_impl}} {{#service:interactions}} {{ > service_cpp/service_interface_impl}} {{/service:interactions}} {{ > common/namespace_cpp2_begin}} {{ > service_cpp/service_null_impl}} const char* {{service:cpp_name}}AsyncProcessor::getServiceName() { return "{{service:name}}"; } void {{service:cpp_name}}AsyncProcessor::getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) { ::apache::thrift::detail::md::ServiceMetadata<::apache::thrift::ServiceHandler<{{service:qualified_name}}>>::gen(response); } void {{service:cpp_name}}AsyncProcessor::processSerializedCompressedRequestWithMetadata(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) { apache::thrift::detail::ap::process(this, iface_, std::move(req), std::move(serializedRequest), methodMetadata, protType, context, eb, tm); } void {{service:cpp_name}}AsyncProcessor::executeRequest(apache::thrift::ServerRequest&& request, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata) { apache::thrift::detail::ap::execute(this, std::move(request), apache::thrift::detail::ServerRequestHelper::protocol(request), methodMetadata); } {{ > service_cpp/processmap}} {{#service:interactions?}} {{ > service_cpp/interaction_constructor_map}} {{/service:interactions?}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_cpp/interaction_constructor_map.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}const {{service:cpp_name}}AsyncProcessor::InteractionConstructorMap& {{service:cpp_name}}AsyncProcessor::getInteractionConstructorMap() { return interactionConstructorMap_; } const {{service:cpp_name}}AsyncProcessor::InteractionConstructorMap {{service:cpp_name}}AsyncProcessor::interactionConstructorMap_ { {{#service:functions}}{{#function:return_type}}{{#function:starts_interaction?}} {"{{type:name}}", &{{service:cpp_name}}AsyncProcessor::{{function:name}}}, {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} }; std::unique_ptr {{service:cpp_name}}AsyncProcessor::createInteractionImpl(const std::string& name) { auto fn = getInteractionConstructorMap().at(name); return (this->*fn)(); } )__FBTHRIFT_TAG__", // cpp2/service_cpp/processmap.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}const {{service:cpp_name}}AsyncProcessor::ProcessMap& {{service:cpp_name}}AsyncProcessor::getOwnProcessMap() { return kOwnProcessMap_; } {{^service:functions?}} const {{service:cpp_name}}AsyncProcessor::ProcessMap {{service:cpp_name}}AsyncProcessor::kOwnProcessMap_ {}; {{/service:functions?}} {{#service:functions?}} const {{service:cpp_name}}AsyncProcessor::ProcessMap {{service:cpp_name}}AsyncProcessor::kOwnProcessMap_ { {{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} {"{{function:name}}", {&{{service:cpp_name}}AsyncProcessor::setUpAndProcess_{{function:cpp_name}}, &{{service:cpp_name}}AsyncProcessor::setUpAndProcess_{{function:cpp_name}}, &{{service:cpp_name}}AsyncProcessor::executeRequest_{{function:cpp_name}}, &{{service:cpp_name}}AsyncProcessor::executeRequest_{{function:cpp_name}}}}, {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} {{#service:interactions}}{{#service:functions}}{{#function:return_type}} {"{{service:name}}.{{function:name}}", {&{{service:parent_service_cpp_name}}AsyncProcessor::setUpAndProcess_{{service:cpp_name}}_{{function:cpp_name}}, &{{service:parent_service_cpp_name}}AsyncProcessor::setUpAndProcess_{{service:cpp_name}}_{{function:cpp_name}}, &{{service:parent_service_cpp_name}}AsyncProcessor::executeRequest_{{service:cpp_name}}_{{function:cpp_name}}, &{{service:parent_service_cpp_name}}AsyncProcessor::executeRequest_{{service:cpp_name}}_{{function:cpp_name}}}}, {{/function:return_type}}{{/service:functions}}{{/service:interactions}} }; {{/service:functions?}} apache::thrift::ServiceRequestInfoMap const& {{service:cpp_name}}ServiceInfoHolder::requestInfoMap() const { static folly::Indestructible requestInfoMap{staticRequestInfoMap()}; return *requestInfoMap; } apache::thrift::ServiceRequestInfoMap {{service:cpp_name}}ServiceInfoHolder::staticRequestInfoMap() { apache::thrift::ServiceRequestInfoMap requestInfoMap = { {{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} {"{{function:name}}", { {{#function:eb}}true{{/function:eb}}{{^function:eb}}false{{/function:eb}}, {{ > types/function_kind}}, "{{service:parent_service_name}}.{{ > common/function_name}}", std::nullopt, apache::thrift::concurrency::{{function:priority}}, {{#function:creates_interaction?}}"{{function:created_interaction}}"{{/function:creates_interaction?}}{{^function:creates_interaction?}}std::nullopt{{/function:creates_interaction?}}}}, {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} {{#service:interactions}}{{#service:functions}}{{#function:return_type}} {"{{service:name}}.{{function:name}}", { {{#function:eb}}true{{/function:eb}}{{^function:eb}}false{{/function:eb}}, {{ > types/function_kind}}, "{{service:parent_service_name}}.{{ > common/function_name}}", "{{service:name}}", apache::thrift::concurrency::{{function:priority}}, std::nullopt}}, {{/function:return_type}}{{/service:functions}}{{/service:interactions}} }; {{#service:extends}} apache::thrift::ServiceRequestInfoMap parentMap = {{ > common/namespace_cpp2}}{{service:cpp_name}}ServiceInfoHolder::staticRequestInfoMap(); requestInfoMap.insert(std::begin(parentMap), std::end(parentMap)); {{/service:extends}} return requestInfoMap; } )__FBTHRIFT_TAG__", // cpp2/service_cpp/service_inl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > common/namespace_cpp2_begin}} {{ > service_common/typedefs}} {{ > service_tcc/process_and_return}} {{#service:interactions}} {{ > service_common/typedefs}} {{ > service_tcc/process_and_return}} {{/service:interactions}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_cpp/service_interface_impl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:functions}}{{#function:return_type}} {{^function:starts_interaction?}} {{^function:eb}} {{ > service_common/sync_function_return_type_server}} {{ > service_common/service_class_name}}::{{function:cpp_name}}({{ > service_common/sync_function_return_param_server}}{{ > service_common/function_param_list_server_commented_out}}) { apache::thrift::detail::si::throw_app_exn_unimplemented("{{function:name}}"); } {{ > service_common/sync_function_return_type_server}} {{ > service_common/service_class_name}}::sync_{{function:cpp_name}}({{#function:sync_returns_by_outparam?}}{{!}}{{function:cpp_return_type}}& _return{{function:comma}}{{!}}{{/function:sync_returns_by_outparam?}}{{ > service_common/function_param_list_server}}) { return {{function:cpp_name}}({{#function:sync_returns_by_outparam?}}_return{{function:comma}}{{!}}{{/function:sync_returns_by_outparam?}}{{ > service_common/param_list_move}}); } folly::SemiFuture<{{ > types/return_type_server_lift_unit}}> {{ > service_common/service_class_name}}::semifuture_{{function:cpp_name}}({{ > service_common/function_param_list_server}}) { auto expected{apache::thrift::detail::si::InvocationType::SemiFuture}; __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Sync, std::memory_order_relaxed); {{^function:sync_returns_by_outparam?}} {{^function:void?}} return sync_{{function:cpp_name}}({{ > service_common/param_list_move}}); {{/function:void?}} {{#function:void?}} sync_{{function:cpp_name}}({{ > service_common/param_list_move}}); return folly::makeSemiFuture(); {{/function:void?}} {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} {{#function:stack_arguments?}} {{type:cpp_type}} ret; sync_{{function:cpp_name}}(ret{{function:comma}}{{ > service_common/param_list_move}}); {{/function:stack_arguments?}} {{^function:stack_arguments?}} auto ret = std::make_unique<{{type:cpp_type}}>(); sync_{{function:cpp_name}}(*ret{{function:comma}}{{ > service_common/param_list_move}}); {{/function:stack_arguments?}} return folly::makeSemiFuture(std::move(ret)); {{/function:sync_returns_by_outparam?}} } {{^service:interaction?}} folly::Future<{{ > types/return_type_server_lift_unit}}> {{ > service_common/service_class_name}}::future_{{function:cpp_name}}({{ > service_common/function_param_list_server}}) { auto expected{apache::thrift::detail::si::InvocationType::Future}; __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); return apache::thrift::detail::si::future(semifuture_{{function:cpp_name}}({{ > service_common/param_list_move}}), getInternalKeepAlive()); } {{/service:interaction?}} #if FOLLY_HAS_COROUTINES folly::coro::Task<{{ > types/return_type_server}}> {{ > service_common/service_class_name}}::co_{{function:cpp_name}}({{ > service_common/function_param_list_server}}) { auto expected{apache::thrift::detail::si::InvocationType::Coro}; __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::{{^service:interaction?}}Future{{/service:interaction?}}{{#service:interaction?}}SemiFuture{{/service:interaction?}}, std::memory_order_relaxed); {{#function:stack_arguments?}} apache::thrift::detail::si::ignore({{ > service_common/param_list_move}}); folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withoutCapturedArgs()); {{/function:stack_arguments?}} {{^function:stack_arguments?}} folly::throw_exception(apache::thrift::detail::si::UnimplementedCoroMethod::withCapturedArgs<{{ > service_common/function_param_list_server_commented_out}}>({{ > service_common/param_list_move}})); {{/function:stack_arguments?}} } folly::coro::Task<{{ > types/return_type_server}}> {{ > service_common/service_class_name}}::co_{{function:cpp_name}}(apache::thrift::RequestParams /* params */{{function:comma}}{{ > service_common/function_param_list_server}}) { auto expected{apache::thrift::detail::si::InvocationType::CoroParam}; __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(expected, apache::thrift::detail::si::InvocationType::Coro, std::memory_order_relaxed); return co_{{function:cpp_name}}({{ > service_common/param_list_move}}); } #endif // FOLLY_HAS_COROUTINES {{#function:oneway?}} void {{ > service_common/service_class_name}}::async_tm_{{function:cpp_name}}(apache::thrift::HandlerCallbackBase::Ptr callback{{function:comma}}{{ > service_common/function_param_list_server}}) { {{/function:oneway?}} {{^function:oneway?}} void {{ > service_common/service_class_name}}::async_tm_{{function:cpp_name}}(apache::thrift::HandlerCallbackPtr<{{ > types/return_type_server}}> callback{{function:comma}}{{ > service_common/function_param_list_server}}) { {{/function:oneway?}} // It's possible the coroutine versions will delegate to a future-based // version. If that happens, we need the RequestParams arguments to be // available to the future through the thread-local backchannel, so we create // a RAII object that sets up RequestParams and clears them on destruction. apache::thrift::detail::si::AsyncTmPrep asyncTmPrep(this, callback.get()); #if FOLLY_HAS_COROUTINES determineInvocationType: #endif // FOLLY_HAS_COROUTINES auto invocationType = __fbthrift_invocation_{{function:cpp_name}}.load(std::memory_order_relaxed); try { switch (invocationType) { case apache::thrift::detail::si::InvocationType::AsyncTm: { #if FOLLY_HAS_COROUTINES __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::CoroParam, std::memory_order_relaxed); apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_{{function:cpp_name}}(params{{function:comma}}{{ > service_common/param_list_move}}); apache::thrift::detail::si::{{#function:oneway?}}async_tm_coro_oneway{{/function:oneway?}}{{^function:oneway?}}async_tm_coro{{/function:oneway?}}(std::move(callback), std::move(task)); return; #else // FOLLY_HAS_COROUTINES {{^service:interaction?}} __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::Future, std::memory_order_relaxed); {{/service:interaction?}} {{#service:interaction?}} __fbthrift_invocation_{{function:cpp_name}}.compare_exchange_strong(invocationType, apache::thrift::detail::si::InvocationType::SemiFuture, std::memory_order_relaxed); {{/service:interaction?}} [[fallthrough]]; #endif // FOLLY_HAS_COROUTINES } {{^service:interaction?}} case apache::thrift::detail::si::InvocationType::Future: { auto fut = future_{{function:cpp_name}}({{ > service_common/param_list_move}}); apache::thrift::detail::si::{{#function:oneway?}}async_tm_future_oneway{{/function:oneway?}}{{^function:oneway?}}async_tm_future{{/function:oneway?}}(std::move(callback), std::move(fut)); return; } {{/service:interaction?}} case apache::thrift::detail::si::InvocationType::SemiFuture: { auto fut = semifuture_{{function:cpp_name}}({{ > service_common/param_list_move}}); apache::thrift::detail::si::{{#function:oneway?}}async_tm_semifuture_oneway{{/function:oneway?}}{{^function:oneway?}}async_tm_semifuture{{/function:oneway?}}(std::move(callback), std::move(fut)); return; } #if FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::CoroParam: { apache::thrift::RequestParams params{callback->getRequestContext(), callback->getThreadManager_deprecated(), callback->getEventBase(), callback->getHandlerExecutor()}; auto task = co_{{function:cpp_name}}(params{{function:comma}}{{ > service_common/param_list_move}}); apache::thrift::detail::si::{{#function:oneway?}}async_tm_coro_oneway{{/function:oneway?}}{{^function:oneway?}}async_tm_coro{{/function:oneway?}}(std::move(callback), std::move(task)); return; } case apache::thrift::detail::si::InvocationType::Coro: { auto task = co_{{function:cpp_name}}({{ > service_common/param_list_move}}); apache::thrift::detail::si::{{#function:oneway?}}async_tm_coro_oneway{{/function:oneway?}}{{^function:oneway?}}async_tm_coro{{/function:oneway?}}(std::move(callback), std::move(task)); return; } #endif // FOLLY_HAS_COROUTINES case apache::thrift::detail::si::InvocationType::Sync: { {{^function:sync_returns_by_outparam?}} {{^function:void?}} callback->result(sync_{{function:cpp_name}}({{ > service_common/param_list_move}})); {{/function:void?}} {{#function:void?}} sync_{{function:cpp_name}}({{ > service_common/param_list_move}}); {{^function:oneway?}} callback->done(); {{/function:oneway?}} {{/function:void?}} {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} {{type:cpp_type}} _return; sync_{{function:cpp_name}}(_return{{function:comma}}{{ > service_common/param_list_move}}); callback->result(std::move(_return)); {{/function:sync_returns_by_outparam?}} return; } default: { folly::assume_unreachable(); } } #if FOLLY_HAS_COROUTINES } catch (apache::thrift::detail::si::UnimplementedCoroMethod&{{^function:stack_arguments?}} ex{{/function:stack_arguments?}}) { {{^function:stack_arguments?}} std::tie({{ > service_common/param_list}}) = std::move(ex).restoreArgs<{{ > service_common/function_param_list_server_commented_out}}>(); {{/function:stack_arguments?}} goto determineInvocationType; #endif // FOLLY_HAS_COROUTINES } catch (...) { callback->exception(std::current_exception()); } } {{/function:eb}} {{#function:eb}}{{!Event base codegen}} {{#function:oneway?}} void {{ > service_common/service_class_name}}::async_eb_{{function:cpp_name}}(apache::thrift::HandlerCallbackBase::Ptr /*callback*/{{function:comma}}{{ > service_common/function_param_list_server_commented_out}}) { LOG(DFATAL) << "Function {{function:cpp_name}} is unimplemented"; } {{/function:oneway?}} {{^function:oneway?}} void {{ > service_common/service_class_name}}::async_eb_{{function:cpp_name}}(apache::thrift::HandlerCallbackPtr<{{ > types/return_type_server}}> callback{{function:comma}}{{ > service_common/function_param_list_server_commented_out}}) { callback->exception(apache::thrift::detail::si::create_app_exn_unimplemented("{{function:name}}")); } {{/function:oneway?}} {{/function:eb}} {{/function:starts_interaction?}} {{#function:starts_interaction?}} std::unique_ptr<{{ > service_common/service_class_name}}::{{type:name}}If> {{ > service_common/service_class_name}}::{{function:cpp_name}}() { apache::thrift::detail::si::throw_app_exn_unimplemented("{{function:name}}"); } {{/function:starts_interaction?}} {{/function:return_type}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_cpp/service_null_impl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}}{{^function:creates_interaction?}}{{^function:eb}}{{^function:stream?}} {{ > service_common/sync_function_return_type_server}} {{service:cpp_name}}SvNull::{{function:cpp_name}}({{ > service_common/sync_function_return_param_server}}{{ > service_common/function_param_list_server_commented_out}}) { {{! }}{{#type:resolves_to_complex_return?}} }{{/type:resolves_to_complex_return?}} {{^type:resolves_to_complex_return?}} {{#function:cpp_void?}} return; {{/function:cpp_void?}} {{#type:enum?}} return ({{type:cpp_type}})0; {{/type:enum?}} {{#function:stream?}} return {}; {{/function:stream?}} {{#function:sink?}} return {}; {{/function:sink?}} {{^function:cpp_void?}}{{^type:enum?}}{{^function:stream?}}{{^function:sink?}} return 0; {{/function:sink?}}{{/function:stream?}}{{/type:enum?}}{{/function:cpp_void?}} } {{/type:resolves_to_complex_return?}} {{/function:stream?}}{{/function:eb}}{{/function:creates_interaction?}}{{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_h/async_client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > common/namespace_cpp2_begin}} class {{service:cpp_name}}; {{ > common/namespace_cpp2_end}} namespace apache::thrift { template <> class Client<{{service:qualified_name}}> : public {{#service:extends}}{{ > common/namespace_cpp2}}{{service:cpp_name}}AsyncClient{{/service:extends}}{{^service:extends}}apache::thrift::GeneratedAsyncClient{{/service:extends}} { public: using {{#service:extends}}{{ > common/namespace_cpp2}}{{service:cpp_name}}AsyncClient::{{service:cpp_name}}AsyncClient{{/service:extends}}{{^service:extends}}apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient{{/service:extends}}; char const* getServiceName() const noexcept override { return "{{service:parent_service_name}}"; } {{#service:thrift_uri}} static const char* __fbthrift_thrift_uri() { return "{{service:thrift_uri}}"; } {{/service:thrift_uri}} {{#service:interactions}} {{ > service_h/interaction_async_client}} {{/service:interactions}} {{ > service_h/async_client_functions}} }; } // namespace apache::thrift {{ > common/namespace_cpp2_begin}} using {{service:cpp_name}}AsyncClient [[deprecated("Use apache::thrift::Client<{{service:cpp_name}}> instead")]] = ::apache::thrift::Client<{{service:cpp_name}}>; {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_h/async_client_functions.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:functions}}{{#function:return_type}} {{#function:starts_interaction?}} {{ > common/fun_docblock}} {{type:name}} {{function:cpp_name}}(); {{/function:starts_interaction?}}{{^function:starts_interaction?}} {{^function:sink?}} {{^service:reduced_client?}}{{^function:creates_interaction?}} {{ > common/fun_docblock}} virtual void {{function:cpp_name}}(std::unique_ptr callback{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:creates_interaction?}}{{/service:reduced_client?}} {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}} virtual{{/function:creates_interaction?}}{{/service:reduced_client?}} void {{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:sink?}} protected: void {{function:cpp_name}}Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, {{ > types/callback_type}} callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}, bool stealRpcOptions = false); public: {{^function:sink?}} {{^function:sync_returns_by_outparam?}} {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}{{ > types/return_type_client}} sync_{{function:cpp_name}}({{ > service_common/function_param_list_client}}); {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}{{ > types/return_type_client}} sync_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:sync_returns_by_outparam?}} {{#function:sync_returns_by_outparam?}} {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}void sync_{{function:cpp_name}}({{function:cpp_return_type}}& _return{{function:comma}}{{ > service_common/function_param_list_client}}); {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}void sync_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions, {{function:cpp_return_type}}& _return{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:sync_returns_by_outparam?}} {{^service:reduced_client?}}{{^function:creates_interaction?}}{{^function:stream?}} {{ > common/fun_docblock}} virtual folly::Future<{{ > types/return_type_client_lift_unit}}> future_{{function:cpp_name}}({{ > service_common/function_param_list_client}}); {{/function:stream?}}{{/function:creates_interaction?}}{{/service:reduced_client?}} {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}folly::SemiFuture<{{ > types/return_type_client_lift_unit}}> semifuture_{{function:cpp_name}}({{ > service_common/function_param_list_client}}); {{^service:reduced_client?}}{{^function:creates_interaction?}}{{^function:stream?}} {{ > common/fun_docblock}} virtual folly::Future<{{ > types/return_type_client_lift_unit}}> future_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:stream?}}{{/function:creates_interaction?}}{{/service:reduced_client?}} {{ > common/fun_docblock}} {{^service:reduced_client?}}{{^function:creates_interaction?}}virtual {{/function:creates_interaction?}}{{/service:reduced_client?}}folly::SemiFuture<{{ > types/return_type_client_lift_unit}}> semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{#function:creates_interaction?}} {{ > common/fun_docblock}} std::pair< apache::thrift::Client<{{service:parent_service_qualified_name}}>::{{function:created_interaction}}, folly::SemiFuture<{{^type:void?}}{{ > types/return_type_client_no_handle}}{{/type:void?}}{{#type:void?}}folly::Unit{{/type:void?}}> > eager_semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:creates_interaction?}} {{^function:oneway?}} {{^service:reduced_client?}}{{^function:creates_interaction?}} {{^function:stream?}} {{ > common/fun_docblock}} virtual folly::Future types/return_type_client_lift_unit}}, std::unique_ptr>> header_future_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:stream?}} {{ > common/fun_docblock}} virtual folly::SemiFuture types/return_type_client_lift_unit}}, std::unique_ptr>> header_semifuture_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); {{#type:sync_methods_return_try?}} {{ > common/fun_docblock}} FOLLY_NODISCARD [[deprecated("To be replaced by new API soon")]] virtual folly::Try types/return_type_client}}>> sync_complete_{{function:cpp_name}}( apache::thrift::RpcOptions&& rpcOptions{{function:comma}} {{ > service_common/function_param_list_client}}); {{/type:sync_methods_return_try?}} {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:oneway?}} #if FOLLY_HAS_COROUTINES {{! Coroutine functions are inline templates to prevent compile time and binary size regression }} #if __clang__ {{ > common/fun_docblock}} template folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { return co_{{function:cpp_name}}(nullptr{{function:comma}}{{ > service_common/param_list}}); } {{ > common/fun_docblock}} template folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { return co_{{function:cpp_name}}(&rpcOptions{{function:comma}}{{ > service_common/param_list}}); } #else {{! GCC coroutines implementation is less stable and results in ICE compiling the code below. Use semifuture_ implementation instead. }} {{ > common/fun_docblock}} folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}({{ > service_common/function_param_list_client}}) { {{^type:void?}}co_return {{/type:void?}}co_await folly::coro::detachOnCancel(semifuture_{{function:cpp_name}}({{ > service_common/param_list}})); } {{ > common/fun_docblock}} folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { {{^type:void?}}co_return {{/type:void?}}co_await folly::coro::detachOnCancel(semifuture_{{function:cpp_name}}(rpcOptions{{function:comma}}{{ > service_common/param_list}})); } #endif private: template folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}(apache::thrift::RpcOptions* rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback<{{#function:oneway?}}true{{/function:oneway?}}{{^function:oneway?}}false{{/function:oneway?}}> callback(&returnState, co_await folly::coro::co_current_executor); {{^function:oneway?}} auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); {{/function:oneway?}} auto [ctx, header] = {{function:cpp_name}}Ctx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback<{{#function:oneway?}}true{{/function:oneway?}}{{^function:oneway?}}false{{/function:oneway?}}>; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); {{^function:stream?}} auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); {{/function:stream?}}{{#function:stream?}} auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback), hasRpcOptions ? rpcOptions->getBufferOptions() : defaultRpcOptions->getBufferOptions()); {{/function:stream?}} {{#function:creates_interaction?}} {{function:created_interaction}} handle(channel_, "{{function:created_interaction}}"); {{/function:creates_interaction?}} if constexpr (hasRpcOptions) { {{function:cpp_name}}Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } else { {{function:cpp_name}}Impl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback){{#function:creates_interaction?}}, handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/param_list}}); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } {{^function:oneway?}} returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; {{#type:void?}} if (auto ew = recv_wrapped_{{function:cpp_name}}(returnState)) { co_yield folly::coro::co_error(std::move(ew)); } {{/type:void?}} {{^type:void?}} {{ > types/return_type_client_no_handle}} _return; if (auto ew = recv_wrapped_{{function:cpp_name}}(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } {{/type:void?}} {{^function:creates_interaction?}} {{^type:void?}} co_return _return; {{/type:void?}} {{/function:creates_interaction?}} {{#function:creates_interaction?}} {{^type:void?}} co_return std::make_pair(std::move(handle), std::move(_return)); {{/type:void?}} {{#type:void?}} co_return handle; {{/type:void?}} {{/function:creates_interaction?}} {{/function:oneway?}} } public: #endif // FOLLY_HAS_COROUTINES {{^service:reduced_client?}}{{^function:creates_interaction?}} {{^function:stream?}} {{ > common/fun_docblock}} virtual void {{function:cpp_name}}(folly::Function callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_param_list_client}}); {{/function:stream?}} {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:sink?}}{{#function:sink?}} #if FOLLY_HAS_COROUTINES {{ > common/fun_docblock}} folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}({{ > service_common/function_param_list_client}}); {{ > common/fun_docblock}} folly::coro::Task<{{ > types/return_type_client}}> co_{{function:cpp_name}}(apache::thrift::RpcOptions& rpcOptions{{function:comma}}{{ > service_common/function_param_list_client}}); #endif // FOLLY_HAS_COROUTINES {{/function:sink?}} {{#function:cpp_void?}} {{^function:oneway?}} {{ > common/fun_docblock}} static folly::exception_wrapper recv_wrapped_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{ > common/fun_docblock}} static void recv_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{^service:reduced_client?}}{{^function:creates_interaction?}} // Mock friendly virtual instance method {{ > common/fun_docblock}} virtual void recv_instance_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{ > common/fun_docblock}} virtual folly::exception_wrapper recv_instance_wrapped_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:oneway?}} {{/function:cpp_void?}} {{^function:cpp_void?}} {{ > common/fun_docblock}} static folly::exception_wrapper recv_wrapped_{{function:cpp_name}}({{ > types/return_type_client_no_handle}}& _return, ::apache::thrift::ClientReceiveState& state); {{^function:sync_returns_by_outparam?}} {{ > common/fun_docblock}} static {{ > types/return_type_client_no_handle}} recv_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{^service:reduced_client?}}{{^function:creates_interaction?}} // Mock friendly virtual instance method {{ > common/fun_docblock}} virtual {{ > types/return_type_client_no_handle}} recv_instance_{{function:cpp_name}}(::apache::thrift::ClientReceiveState& state); {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:sync_returns_by_outparam?}}{{#function:sync_returns_by_outparam?}} {{ > common/fun_docblock}} static void recv_{{function:cpp_name}}({{ > types/return_type_client_no_handle}}& _return, ::apache::thrift::ClientReceiveState& state); {{^service:reduced_client?}}{{^function:creates_interaction?}} // Mock friendly virtual instance method {{ > common/fun_docblock}} virtual void recv_instance_{{function:cpp_name}}({{ > types/return_type_client_no_handle}}& _return, ::apache::thrift::ClientReceiveState& state); {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:sync_returns_by_outparam?}} {{^service:reduced_client?}}{{^function:creates_interaction?}} {{ > common/fun_docblock}} virtual folly::exception_wrapper recv_instance_wrapped_{{function:cpp_name}}({{ > types/return_type_client_no_handle}}& _return, ::apache::thrift::ClientReceiveState& state); {{/function:creates_interaction?}}{{/service:reduced_client?}} {{/function:cpp_void?}} private: template void {{function:cpp_name}}T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, {{ > types/callback_type}} callback{{#function:creates_interaction?}}, const apache::thrift::InteractionHandle& handle{{/function:creates_interaction?}}{{function:comma}}{{ > service_common/function_para)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(m_list_client}}); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> {{function:cpp_name}}Ctx(apache::thrift::RpcOptions* rpcOptions); public: {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_h/async_processor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}class {{service:cpp_name}}AsyncProcessor : public {{#service:extends}}{{ > common/namespace_cpp2}}{{service:cpp_name}}AsyncProcessor{{/service:extends}}{{^service:extends}}::apache::thrift::GeneratedAsyncProcessorBase{{/service:extends}} { public: const char* getServiceName() override; void getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) override; {{#service:extends}} using BaseAsyncProcessor = {{ > common/namespace_cpp2}}{{service:cpp_name}}AsyncProcessor; {{/service:extends}} {{^service:extends}} using BaseAsyncProcessor = void; {{/service:extends}} protected: ::apache::thrift::ServiceHandler<{{service:qualified_name}}>* iface_; public: void processSerializedCompressedRequestWithMetadata(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) override; void executeRequest(apache::thrift::ServerRequest&& serverRequest, const apache::thrift::AsyncProcessorFactory::MethodMetadata& methodMetadata) override; public: using ProcessFuncs = GeneratedAsyncProcessorBase::ProcessFuncs<{{service:cpp_name}}AsyncProcessor>; using ProcessMap = GeneratedAsyncProcessorBase::ProcessMap; {{#service:interactions?}} using InteractionConstructor = GeneratedAsyncProcessorBase::InteractionConstructor<{{service:cpp_name}}AsyncProcessor>; using InteractionConstructorMap = GeneratedAsyncProcessorBase::InteractionConstructorMap; {{/service:interactions?}} static const {{service:cpp_name}}AsyncProcessor::ProcessMap& getOwnProcessMap(); {{#service:interactions?}} static const {{service:cpp_name}}AsyncProcessor::InteractionConstructorMap& getInteractionConstructorMap(); std::unique_ptr createInteractionImpl(const std::string& name) override; {{/service:interactions?}} private: static const {{service:cpp_name}}AsyncProcessor::ProcessMap kOwnProcessMap_; {{#service:interactions?}} static const {{service:cpp_name}}AsyncProcessor::InteractionConstructorMap interactionConstructorMap_; {{/service:interactions?}} private: {{#service:functions}} {{ > service_h/async_processor_per_function}} {{/service:functions}} {{#service:interactions}}{{#service:functions}} {{ > service_h/async_processor_per_function}} {{/service:functions}}{{/service:interactions}} public: {{service:cpp_name}}AsyncProcessor(::apache::thrift::ServiceHandler<{{service:qualified_name}}>* iface) : {{#service:extends}} {{ > common/namespace_cpp2}}{{service:cpp_name}}AsyncProcessor(iface), {{/service:extends}} iface_(iface) {} ~{{service:cpp_name}}AsyncProcessor() override {} }; )__FBTHRIFT_TAG__", // cpp2/service_h/async_processor_per_function.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:return_type}}{{^function:starts_interaction?}} template void setUpAndProcess_{{function:prefixed_name}}(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm); template void executeRequest_{{function:prefixed_name}}(apache::thrift::ServerRequest&& serverRequest); {{^function:oneway?}} template {{#function:cpp_void?}} static apache::thrift::SerializedResponse return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx); {{/function:cpp_void?}} {{^function:cpp_void?}} {{^function:stream?}}{{^function:sink?}} static apache::thrift::SerializedResponse return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, {{function:cpp_return_type}} const& _return); {{/function:sink?}}{{/function:stream?}} {{#function:stream?}} static apache::thrift::ResponseAndServerStreamFactory return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, folly::Executor::KeepAlive<> executor, {{function:cpp_return_type}}&& _return); {{/function:stream?}} {{#function:sink?}} static std::pair return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, {{function:cpp_return_type}}&& _return, folly::Executor::KeepAlive<> executor); {{/function:sink?}} {{/function:cpp_void?}} template static void throw_wrapped_{{function:prefixed_name}}(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx); {{/function:oneway?}} {{/function:starts_interaction?}}{{#function:starts_interaction?}} std::unique_ptr {{function:cpp_name}}() { return iface_->{{function:cpp_name}}(); } {{/function:starts_interaction?}}{{/function:return_type}} )__FBTHRIFT_TAG__", // cpp2/service_h/handlers_h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > service_h/service_interface}}{{! }} {{ > common/namespace_cpp2_begin}} {{ > service_h/service_null}} {{ > service_h/async_processor}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_h/interaction_async_client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}class {{service:cpp_name}} final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<{{service:parent_service_qualified_name}}>; public: char const* getServiceName() const noexcept override { return "{{service:parent_service_name}}"; } {{ > service_h/async_client_functions}} }; )__FBTHRIFT_TAG__", // cpp2/service_h/interaction_service_interface.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > service_h/service_info_holder}} class {{service:cpp_name}}If : public apache::thrift::{{#interaction:serial?}}SerialInteraction{{/interaction:serial?}}{{#interaction:eb?}}EventBase{{/interaction:eb?}}Tile, public apache::thrift::ServerInterface { public: std::string_view getGeneratedName() const override { return "{{service:name}}"; } typedef {{service:parent_service_qualified_name}}AsyncProcessor ProcessorType; std::unique_ptr getProcessor() override { std::terminate(); } CreateMethodMetadataResult createMethodMetadata() override { std::terminate(); } {{ > service_h/service_interface_functions}} }; )__FBTHRIFT_TAG__", // cpp2/service_h/service_info_holder.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}class {{service:cpp_name}}ServiceInfoHolder : public apache::thrift::ServiceInfoHolder { public: apache::thrift::ServiceRequestInfoMap const& requestInfoMap() const override; static apache::thrift::ServiceRequestInfoMap staticRequestInfoMap(); }; )__FBTHRIFT_TAG__", // cpp2/service_h/service_interface.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > common/namespace_cpp2_begin}} class {{service:cpp_name}}; class {{service:cpp_name}}AsyncProcessor; {{ > service_h/service_info_holder}} {{ > common/namespace_cpp2_end}} namespace apache::thrift { template <> class ServiceHandler<{{service:qualified_name}}> : {{#service:extends}}virtual public {{ > common/namespace_cpp2}}{{service:cpp_name}}SvIf{{/service:extends}}{{^service:extends}}public apache::thrift::ServerInterface{{/service:extends}} { public: std::string_view getGeneratedName() const override { return "{{service:name}}"; } {{#service:thrift_uri}} static const char* __fbthrift_thrift_uri() { return "{{service:thrift_uri}}"; } {{/service:thrift_uri}} typedef {{service:qualified_name}}AsyncProcessor ProcessorType; std::unique_ptr getProcessor() override; CreateMethodMetadataResult createMethodMetadata() override; {{#service:has_service_schema}} #if defined(THRIFT_SCHEMA_AVAILABLE) std::optional> getServiceMetadataV1() override; #endif {{/service:has_service_schema}} private: std::optional> getServiceRequestInfoMap() const; public: {{#service:interactions}} {{ > service_h/interaction_service_interface}} {{/service:interactions}} {{ > service_h/service_interface_functions}} }; } // namespace apache::thrift {{ > common/namespace_cpp2_begin}} using {{service:cpp_name}}SvIf [[deprecated("Use apache::thrift::ServiceHandler<{{service:cpp_name}}> instead")]] = ::apache::thrift::ServiceHandler<{{service:cpp_name}}>; {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_h/service_interface_functions.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} {{^function:eb}} virtual {{ > service_common/sync_function_return_type_server}} sync_{{function:cpp_name}}({{ > service_common/sync_function_return_param_server}}{{ > service_common/function_param_list_server_commented_out}}); [[deprecated("Use sync_{{function:cpp_name}} instead")]] virtual {{ > service_common/sync_function_return_type_server}} {{function:cpp_name}}({{ > service_common/sync_function_return_param_server}}{{ > service_common/function_param_list_server_commented_out}}); {{^service:interaction?}} virtual folly::Future<{{ > types/return_type_server_lift_unit}}> future_{{function:cpp_name}}({{ > service_common/function_param_list_server}}); {{/service:interaction?}} virtual folly::SemiFuture<{{ > types/return_type_server_lift_unit}}> semifuture_{{function:cpp_name}}({{ > service_common/function_param_list_server}}); #if FOLLY_HAS_COROUTINES virtual folly::coro::Task<{{ > types/return_type_server}}> co_{{function:cpp_name}}({{ > service_common/function_param_list_server}}); virtual folly::coro::Task<{{ > types/return_type_server}}> co_{{function:cpp_name}}(apache::thrift::RequestParams params{{function:comma}}{{ > service_common/function_param_list_server}}); #endif {{/function:eb}} {{#function:oneway?}} virtual void async_{{#function:eb}}eb{{/function:eb}}{{^function:eb}}tm{{/function:eb}}_{{function:cpp_name}}(apache::thrift::HandlerCallbackBase::Ptr callback{{function:comma}}{{ > service_common/function_param_list_server}}); {{/function:oneway?}} {{^function:oneway?}} virtual void async_{{#function:eb}}eb{{/function:eb}}{{^function:eb}}tm{{/function:eb}}_{{function:cpp_name}}(apache::thrift::HandlerCallbackPtr<{{ > types/return_type_server}}> callback{{function:comma}}{{ > service_common/function_param_list_server}}); {{/function:oneway?}} {{/function:starts_interaction?}}{{#function:starts_interaction?}} virtual std::unique_ptr<{{type:name}}If> {{function:cpp_name}}(); {{/function:starts_interaction?}} {{/function:return_type}} {{/service:functions}} private: {{^service:interaction?}} static {{service:qualified_name}}ServiceInfoHolder __fbthrift_serviceInfoHolder; {{/service:interaction?}} {{#service:functions}} {{^function:eb}} std::atomic __fbthrift_invocation_{{function:cpp_name}}{apache::thrift::detail::si::InvocationType::AsyncTm}; {{/function:eb}} {{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_h/service_null.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}class {{service:cpp_name}}SvNull : public ::apache::thrift::ServiceHandler<{{service:cpp_name}}>{{#service:extends}}, virtual public ::apache::thrift::ServiceHandler<{{ > common/namespace_cpp2}}{{service:cpp_name}}>{{/service:extends}} { public: {{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}}{{^function:creates_interaction?}}{{^function:eb}}{{^function:stream?}} {{ > service_common/sync_function_return_type_server}} {{function:cpp_name}}({{ > service_common/sync_function_return_param_server}}{{ > service_common/function_param_list_server_commented_out}}) override; {{/function:stream?}}{{/function:eb}}{{/function:creates_interaction?}}{{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} }; )__FBTHRIFT_TAG__", // cpp2/service_processmap_protocol.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{ > Autogen}} #include "{{service:include_prefix}}{{service:name}}.h" #include "{{service:include_prefix}}{{service:name}}.tcc" {{ > common/namespace_cpp2_begin}} {{ > common/namespace_cpp2_end}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/field_data_params.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}, apache::thrift::FieldData<{{field:key}}, {{type:type_class_with_indirection}}, {{type:cpp_type}}*{{#type:use_op_encode?}}, {{type:type_tag}}{{/type:use_op_encode?}}>{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/field_data_return.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^type:void?}}{{! }}, apache::thrift::FieldData<0, {{type:type_class_with_indirection}}, {{type:cpp_type}}*{{#type:use_op_encode?}}, {{type:type_tag}}{{/type:use_op_encode?}}>{{! }}{{/type:void?}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/field_data_throws.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type}}, apache::thrift::FieldData<{{field:key}}, {{type:type_class_with_indirection}}, {{type:cpp_type}}{{#type:use_op_encode?}}, {{type:type_tag}}{{/type:use_op_encode?}}>{{/field:type}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/get_args_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:args}}{{#field:type}}{{! }}{{#type:resolves_to_complex_return?}}{{! }}{{^function:stack_arguments?}}{{! }}, std::move(uarg_{{field:cpp_name}}){{! }}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{! }}, args.get<{{field:index}}>().ref(){{! }}{{/function:stack_arguments?}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{^type:resolves_to_complex_return?}}{{! }}, args.get<{{field:index}}>().ref(){{! }}{{/type:resolves_to_complex_return?}}{{! }}{{/field:type}}{{/function:args}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/process_and_return.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:functions}}{{#function:return_type}}{{^function:starts_interaction?}} template void {{service:parent_service_cpp_name}}AsyncProcessor::setUpAndProcess_{{function:prefixed_name}}(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, {{^function:eb}}tm{{/function:eb}}{{#function:eb}}nullptr{{/function:eb}}, {{ > types/function_kind}}, iface_{{#service:interaction?}}, "{{service:name}}"{{/service:interaction?}}{{#function:creates_interaction?}}, "{{function:created_interaction}}", true{{/function:creates_interaction?}})) { return; } {{^function:eb}} auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::{{function:priority}}); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, {{ > types/function_kind}}, &{{service:parent_service_cpp_name}}AsyncProcessor::executeRequest_{{function:prefixed_name}}, this); {{/function:eb}}{{#function:eb}} {{#function:in_or_creates_interaction?}} processInThread(std::move(req), std::move(serializedRequest), ctx, eb, nullptr, {{ > types/function_kind}}, &{{service:parent_service_cpp_name}}AsyncProcessor::executeRequest_{{function:prefixed_name}}, this); {{/function:in_or_creates_interaction?}} {{^function:in_or_creates_interaction?}} {{^function:oneway?}} if (!req->getShouldStartProcessing()) { {{#function:in_or_creates_interaction?}} auto tile = serverRequest.requestContext()->releaseTile(); {{/function:in_or_creates_interaction?}} apache::thrift::HandlerCallbackBase::releaseRequest(std::move(req), eb{{#function:in_or_creates_interaction?}}, std::move(tile){{/function:in_or_creates_interaction?}}); return; } {{/function:oneway?}} apache::thrift::ServerRequest serverRequest{std::move(req), std::move(serializedRequest), ctx, {}, {}, {}, {}}; executeRequest_{{function:prefixed_name}}(std::move(serverRequest)); {{/function:in_or_creates_interaction?}} {{/function:eb}} } template void {{service:parent_service_cpp_name}}AsyncProcessor::executeRequest_{{#service:interaction?}}{{service:name}}_{{/service:interaction?}}{{function:cpp_name}}(apache::thrift::ServerRequest&& serverRequest) { {{#function:in_or_creates_interaction?}} auto tile = serverRequest.requestContext()->releaseTile(); {{/function:in_or_creates_interaction?}} // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{#service:interaction?}}{{service:name}}_{{/service:interaction?}}{{function:cpp_name}}_pargs args; {{#function:args}}{{#field:type}} {{^type:resolves_to_complex_return?}} {{^type:enum?}} {{type:cpp_type}} uarg_{{field:cpp_name}}{0}; {{/type:enum?}} {{#type:enum?}} {{type:cpp_type}} uarg_{{field:cpp_name}}{static_cast<{{type:cpp_type}}>(0)}; {{/type:enum?}} args.get<{{field:index}}>().value = &uarg_{{field:cpp_name}}; {{/type:resolves_to_complex_return?}} {{#type:resolves_to_complex_return?}} {{#function:stack_arguments?}} {{type:cpp_type}} uarg_{{field:cpp_name}}; args.get<{{field:index}}>().value = &uarg_{{field:cpp_name}}; {{/function:stack_arguments?}} {{^function:stack_arguments?}} auto uarg_{{field:cpp_name}} = std::make_unique<{{type:cpp_type}}>(); args.get<{{field:index}}>().value = uarg_{{field:cpp_name}}.get(); {{/function:stack_arguments?}} {{/type:resolves_to_complex_return?}} {{/field:type}}{{/function:args}} auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "{{service:parent_service_name}}.{{ > common/function_name}}", serverRequest.requestContext()); {{#service:interaction?}} auto& iface = static_cast::{{service:name}}If&>(*tile); {{/service:interaction?}} try { deserializeRequest(args, "{{ > common/function_name}}", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { {{#function:oneway?}} LOG(ERROR) << "exception in function {{ > common/function_name}}: " << folly::exceptionStr(std::current_exception()); apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest)->runInEventBaseThread([req = apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest))] {}); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = std::make_unique( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , nullptr , nullptr , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) {{#function:in_or_creates_interaction?}}, std::move(tile){{/function:in_or_creates_interaction?}}); {{/function:oneway?}} {{^function:oneway?}} folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "{{ > common/function_name}}"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = std::make_unique types/return_type_server}}>>( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , return_{{function:prefixed_name}} , throw_wrapped_{{#service:interaction?}}{{service:name}}_{{/service:interaction?}}{{function:cpp_name}} , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , {{^function:eb}}apache::thrift::detail::ServerRequestHelper::executor(serverRequest){{/function:eb}}{{#function:eb}}nullptr{{/function:eb}} , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) {{#function:in_or_creates_interaction?}}, std::move(tile){{/function:in_or_creates_interaction?}}); {{/function:oneway?}} {{^service:interaction?}}iface_->{{/service:interaction?}}{{#service:interaction?}}iface.{{/service:interaction?}}{{#function:eb}}async_eb{{/function:eb}}{{^function:eb}}async_tm{{/function:eb}}_{{function:cpp_name}}(std::move(callback){{ > service_tcc/get_args_ref}}); } {{^function:oneway?}} template {{#function:cpp_void?}} apache::thrift::SerializedResponse {{service:parent_service_cpp_name}}AsyncProcessor::return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx) { {{/function:cpp_void?}} {{^function:cpp_void?}} {{^function:stream?}}{{^function:sink?}} apache::thrift::SerializedResponse {{service:parent_service_cpp_name}}AsyncProcessor::return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, {{function:cpp_return_type}} const& _return) { {{/function:sink?}}{{/function:stream?}} {{#function:stream?}} apache::thrift::ResponseAndServerStreamFactory {{service:parent_service_cpp_name}}AsyncProcessor::return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, folly::Executor::KeepAlive<> executor, {{function:cpp_return_type}}&& _return) { {{/function:stream?}} {{#function:sink?}} std::pair {{service:parent_service_cpp_name}}AsyncProcessor::return_{{function:prefixed_name}}(apache::thrift::ContextStack* ctx, {{function:cpp_return_type}}&& _return, folly::Executor::KeepAlive<> executor) { {{/function:sink?}} {{/function:cpp_void?}} ProtocolOut_ prot; {{#function:stream?}} {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult::FieldsType result; using StreamPResultType = {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult::StreamPResultType; {{#function:stream_has_first_response?}} result.get<0>().value = const_cast<{{function:cpp_return_type}}::ResponseType*>(&_return.response); result.setIsSet(0, true); auto& returnStream = _return.stream; {{/function:stream_has_first_response?}} {{^function:stream_has_first_response?}} auto& returnStream = _return; {{/function:stream_has_first_response?}} {{^function:stream_exceptions?}} using ExMapType = apache::thrift::detail::ap::EmptyExMapType; {{/function:stream_exceptions?}} {{#function:stream_exceptions?}} struct ExMapType { bool operator()(StreamPResultType& res, folly::exception_wrapper ew) { {{#function:stream_exceptions}} if (ew.with_exception([&]({{#field:type}}{{ > common/type_namespace_cpp2}}{{type:name}}{{/field:type}}& e) { res.get<{{field:index_plus_one}}>().ref() = e; res.setIsSet({{field:index_plus_one}}, true); })) { return true; } {{/function:stream_exceptions}} return false; } }; {{/function:stream_exceptions?}} auto encodedStream = apache::thrift::detail::ap::encode_server_stream(std::move(returnStream), std::move(executor)); return {serializeResponse("{{ > common/function_name}}", &prot, ctx, result), std::move(encodedStream)}; {{/function:stream?}} {{#function:sink?}} {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult::FieldsType result; using SinkPResultType = {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult::SinkPResultType; using FinalResponsePResultType = {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult::FinalResponsePResultType; {{#function:sink_has_first_response?}} result.get<0>().value = &_return.response; result.setIsSet(0, true); {{/function:sink_has_first_response?}} {{^function:sink_final_response_exceptions?}} using ExMapType = apache::thrift::detail::ap::EmptyExMapType; {{/function:sink_final_response_exceptions?}} {{#function:sink_final_response_exceptions?}} struct ExMapType { bool operator()(FinalResponsePResultType& res, folly::exception_wrapper ew) { {{#function:sink_final_response_exceptions}} if (ew.with_exception([&]({{#field:type}}{{ > common/type_namespace_cpp2}}{{type:name}}{{/field:type}}& e) { res.get<{{field:index_plus_one}}>().ref() = e; res.setIsSet({{field:index_plus_one}}, true); })) { return true; } {{/function:sink_final_response_exceptions}} return false; } }; {{/function:sink_final_response_exceptions?}} auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( {{#function:sink_has_first_response?}} std::move(_return.sinkConsumer), {{/function:sink_has_first_response?}} {{^function:sink_has_first_response?}} std::move(_return), {{/function:sink_has_first_response?}} std::move(executor)); return {serializeResponse("{{ > common/function_name}}", &prot, ctx, result), std::move(sinkConsumerImpl)}; {{/function:sink?}} {{^function:stream?}}{{^function:sink?}} {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult result; {{^type:void?}} result.get<0>().value = const_cast<{{function:cpp_return_type}}*>(&_return); result.setIsSet(0, true); {{/type:void?}} return serializeResponse("{{ > common/function_name}}", &prot, ctx, result); {{/function:sink?}}{{/function:stream?}} } template void {{service:parent_service_cpp_name}}AsyncProcessor::throw_wrapped_{{function:prefixed_name}}(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } {{#function:exceptions?}} {{ > common/namespace_cpp2}}{{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult result; {{/function:exceptions?}} {{#function:exceptions}} if (ew.with_exception([&]({{#field:type}}{{ > common/type_namespace_cpp2}}{{type:name}}{{/field:type}}& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader<{{#field:type}}{{ > common/type_namespace_cpp2}}{{type:name}}{{/field:type}}>(ew, *reqCtx); {{#function:cpp_void?}} result.get<{{field:index}}>().ref() = e; result.setIsSet({{field:index}}, true); {{/function:cpp_void?}} {{^function:cpp_void?}} {{^function:stream?}}{{^function:sink?}} result.get<{{field:index_plus_one}}>().ref() = e; result.setIsSet({{field:index_plus_one}}, true); {{/function:sink?}}{{/function:stream?}} {{#function:stream?}} {{#function:stream_has_first_response?}} result.fields.get<{{field:index_plus_one}}>().ref() = e; result.fields.setIsSet({{field:index_plus_one}}, true); {{/function:stream_has_first_response?}} {{^function:stream_has_first_response?}} result.fields.get<{{field:index}}>().ref() = e; result.fields.setIsSet({{field:index}}, true); {{/function:stream_has_first_response?}} {{/function:stream?}} {{#function:sink?}} {{#function:sink_has_first_response?}} result.fields.get<{{field:index_plus_one}}>().ref() = e; result.fields.setIsSet({{field:index_plus_one}}, true); {{/function:sink_has_first_response?}} {{^function:sink_has_first_response?}} result.fields.get<{{field:index}}>().ref() = e; result.fields.setIsSet({{field:index}}, true); {{/function:sink_has_first_response?}} {{/function:sink?}} {{/function:cpp_void?}} } )) {} else {{/function:exceptions}} { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "{{ > common/function_name}}"); return; } {{#function:exceptions?}} ProtocolOut_ prot; {{^function:stream?}}{{^function:sink?}} auto response = serializeResponse("{{ > common/function_name}}", &prot, ctx, result); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "{{ >)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__( common/function_name}}"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); return req->sendReply(std::move(payload)); {{/function:sink?}}{{/function:stream?}} {{#function:stream?}} auto response = serializeResponse("{{ > common/function_name}}", &prot, ctx, result.fields); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "{{ > common/function_name}}"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); req->sendStreamReply(std::move(payload), apache::thrift::detail::ServerStreamFactory{nullptr}); {{/function:stream?}} {{#function:sink?}} auto response = serializeResponse("{{ > common/function_name}}", &prot, ctx, result.fields); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "{{ > common/function_name}}"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); req->sendSinkReply(std::move(payload), apache::thrift::detail::SinkConsumerImpl{}); {{/function:sink?}} {{/function:exceptions?}} } {{/function:oneway?}} {{/function:starts_interaction?}}{{/function:return_type}}{{/service:functions}} )__FBTHRIFT_TAG__", // cpp2/service_tcc/typedef_params.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} typedef apache::thrift::ThriftPresult service_tcc/field_data_params}}> {{service:parent_service_cpp_name}}_{{function:prefixed_name}}_pargs; {{! Force newline }} )__FBTHRIFT_TAG__", // cpp2/service_tcc/typedef_result.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:return_type}} {{^function:oneway?}} {{^function:stream?}} {{^function:sink?}} typedef apache::thrift::ThriftPresult service_tcc/field_data_return}}{{! }}{{#function:exceptions}}{{ > service_tcc/field_data_throws}}{{/function:exceptions}}>{{! }} {{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult; {{/function:sink?}}{{! }}{{#function:sink?}} typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult service_tcc/field_data_return}}{{/function:sink_first_response_type}}{{! }}{{#function:exceptions}}{{ > service_tcc/field_data_throws}}{{/function:exceptions}}>, apache::thrift::ThriftPresult service_tcc/field_data_return}}{{/function:sink_elem_type}}{{! }}{{#function:sink_exceptions}}{{ > service_tcc/field_data_throws}}{{/function:sink_exceptions}}>, apache::thrift::ThriftPresult service_tcc/field_data_return}}{{/function:sink_final_response_type}}{{! }}{{#function:sink_final_response_exceptions}}{{ > service_tcc/field_data_throws}}{{/function:sink_final_response_exceptions}}> > {{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult; {{/function:sink?}} {{/function:stream?}}{{! }}{{#function:stream?}} typedef apache::thrift::ThriftPResultStream< apache::thrift::ThriftPresult service_tcc/field_data_return}}{{/function:stream_first_response_type}}{{! }}{{#function:exceptions}}{{ > service_tcc/field_data_throws}}{{/function:exceptions}}>, apache::thrift::ThriftPresult service_tcc/field_data_return}}{{/function:stream_elem_type}}{{! }}{{#function:stream_exceptions}}{{ > service_tcc/field_data_throws}}{{/function:stream_exceptions}}> > {{service:parent_service_cpp_name}}_{{function:prefixed_name}}_presult; {{/function:stream?}} {{/function:oneway?}} {{/function:return_type}} )__FBTHRIFT_TAG__", // cpp2/types/adapter_post.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:cpp_adapter}}){{/type:cpp_adapter}} )__FBTHRIFT_TAG__", // cpp2/types/adapter_pre.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:cpp_adapter}}{{type:cpp_adapter}}::fromThrift({{/type:cpp_adapter}} )__FBTHRIFT_TAG__", // cpp2/types/apply_indirection_post.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:cpp_indirection?}}){{/type:cpp_indirection?}} )__FBTHRIFT_TAG__", // cpp2/types/apply_indirection_pre.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:cpp_indirection?}}::apache::thrift::apply_indirection({{/type:cpp_indirection?}} )__FBTHRIFT_TAG__", // cpp2/types/callback_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:return_type}}{{#function:sink?}}{{! }}apache::thrift::SinkClientCallback*{{! }}{{/function:sink?}}{{! }}{{#function:stream?}}{{! }}apache::thrift::StreamClientCallback*{{! }}{{/function:stream?}}{{! }}{{^function:sink?}}{{^function:stream?}}{{! }}apache::thrift::RequestClientCallback::Ptr{{! }}{{/function:stream?}}{{/function:sink?}}{{/function:return_type}} )__FBTHRIFT_TAG__", // cpp2/types/const_value_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:string?}}char const *{{/type:string?}}{{! }}{{^type:string?}}{{constant:cpp_type}}{{/type:string?}}{{! }} )__FBTHRIFT_TAG__", // cpp2/types/function_kind.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:oneway?}}{{! }}{{^function:stream?}}{{! }}{{^function:sink?}}{{! }}apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE{{! }}{{/function:sink?}}{{! }}{{#function:sink?}}{{! }}apache::thrift::RpcKind::SINK{{! }}{{/function:sink?}}{{! }}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}apache::thrift::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE{{! }}{{/function:stream?}}{{! }}{{/function:oneway?}}{{! }}{{#function:oneway?}}{{! }}apache::thrift::RpcKind::SINGLE_REQUEST_NO_RESPONSE{{! }}{{/function:oneway?}} )__FBTHRIFT_TAG__", // cpp2/types/indirected_string_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Deduces the underlying string type after indirection }}{{#type:resolved_cpp_type}}{{! }}{{#type:cpp_indirection?}}{{! }}::folly::remove_cvref_t<::folly::invoke_result_t<::apache::thrift::detail::apply_indirection_fn, {{type:resolved_cpp_type}} const&>>{{! }}{{/type:cpp_indirection?}}{{! }}{{^type:cpp_indirection?}}{{! }}{{type:resolved_cpp_type}}{{! }}{{/type:cpp_indirection?}}{{! }}{{/type:resolved_cpp_type}}{{! }}{{^type:resolved_cpp_type}}{{! }}std::string{{! }}{{/type:resolved_cpp_type}} )__FBTHRIFT_TAG__", // cpp2/types/param_type_client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:resolves_to_complex_return?}}{{! }}const {{type:cpp_type}}&{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{^type:resolves_to_complex_return?}}{{! }}{{type:cpp_type}}{{! }}{{/type:resolves_to_complex_return?}} )__FBTHRIFT_TAG__", // cpp2/types/param_type_server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:resolves_to_complex_return?}}{{! }}{{#function:stack_arguments?}}{{! }}const {{type:cpp_type}}&{{! }}{{/function:stack_arguments?}}{{! }}{{^function:stack_arguments?}}{{! }}std::unique_ptr<{{type:cpp_type}}>{{! }}{{/function:stack_arguments?}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{^type:resolves_to_complex_return?}}{{! }}{{type:cpp_type}}{{! }}{{/type:resolves_to_complex_return?}} )__FBTHRIFT_TAG__", // cpp2/types/return_type_client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:creates_interaction?}}{{! }}{{ > types/return_type_client_no_handle}}{{! }}{{/function:creates_interaction?}}{{! }}{{#function:creates_interaction?}}{{! }}{{#type:void?}}{{! }}apache::thrift::Client<{{service:parent_service_qualified_name}}>::{{function:created_interaction}}{{! }}{{/type:void?}}{{! }}{{^type:void?}}{{! }}std::pair::{{function:created_interaction}}, {{ > types/return_type_client_no_handle}}>{{! }}{{/type:void?}}{{! }}{{/function:creates_interaction?}} )__FBTHRIFT_TAG__", // cpp2/types/return_type_client_lift_unit.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:void?}}folly::Unit{{/function:void?}}{{! }}{{^function:void?}}{{ > types/return_type_client}}{{/function:void?}} )__FBTHRIFT_TAG__", // cpp2/types/return_type_client_no_handle.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}apache::thrift::ResponseAndClientBufferedStream<{{! }}{{#function:stream_first_response_type}}{{type:cpp_type}}{{/function:stream_first_response_type}},{{! }}{{#function:stream_elem_type}}{{type:cpp_type}}{{/function:stream_elem_type}}>{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}apache::thrift::ClientBufferedStream<{{! }}{{#function:stream_elem_type}}{{type:cpp_type}}{{/function:stream_elem_type}}>{{! }}{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{#function:sink?}}{{! }}{{#function:sink_has_first_response?}}{{! }}apache::thrift::ResponseAndClientSink<{{! }}{{#function:sink_first_response_type}}{{type:cpp_type}}{{/function:sink_first_response_type}}, {{! }}{{#function:sink_elem_type}}{{type:cpp_type}}{{/function:sink_elem_type}}, {{! }}{{#function:sink_final_response_type}}{{type:cpp_type}}{{/function:sink_final_response_type}}>{{! }}{{/function:sink_has_first_response?}}{{! }}{{^function:sink_has_first_response?}}{{! }}apache::thrift::ClientSink<{{! }}{{#function:sink_elem_type}}{{type:cpp_type}}{{/function:sink_elem_type}}, {{! }}{{#function:sink_final_response_type}}{{type:cpp_type}}{{/function:sink_final_response_type}}>{{! }}{{/function:sink_has_first_response?}}{{! }}{{/function:sink?}}{{! }}{{^function:sink?}}{{! }}{{function:cpp_return_type}}{{! }}{{/function:sink?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // cpp2/types/return_type_server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:creates_interaction?}}{{! }}apache::thrift::TileAndResponse::{{function:created_interaction}}If, {{! }}{{/function:creates_interaction?}}{{! }}{{#type:resolves_to_complex_return?}}{{! }}{{#function:stack_arguments?}}{{! }}{{function:cpp_return_type}}{{! }}{{/function:stack_arguments?}}{{! }}{{^function:stack_arguments?}}{{! }}std::unique_ptr<{{type:cpp_type}}>{{! }}{{/function:stack_arguments?}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{^type:resolves_to_complex_return?}}{{! }}{{function:cpp_return_type}}{{! }}{{/type:resolves_to_complex_return?}}{{! }}{{#function:creates_interaction?}}{{! }}>{{! }}{{/function:creates_interaction?}} )__FBTHRIFT_TAG__", // cpp2/types/return_type_server_lift_unit.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:void?}}folly::Unit{{/function:void?}}{{! }}{{^function:void?}}{{ > types/return_type_server}}{{/function:void?}} )__FBTHRIFT_TAG__", // cpp2/types_custom_protocol.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{ > Autogen}} #pragma once /** * This header file includes the tcc files of the corresponding header file * and the header files of its dependent types. Include this header file * only when you need to use custom protocols (e.g. DebugProtocol, * VirtualProtocol) to read/write thrift structs. */ #include "{{service:include_prefix}}{{service:name}}.tcc" #include "{{service:include_prefix}}{{service:program_name}}_types_custom_protocol.h" {{#service:extends}} #include "{{service:include_prefix}}{{service:name}}_custom_protocol.h" {{/service:extends}} {{#service:thrift_includes}} #include "{{program:include_prefix}}{{program:name}}_types_custom_protocol.h" {{/service:thrift_includes}} )__FBTHRIFT_TAG__", // go/codec/decode.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read function for a given field type. }} {{#type:typedef?}} {{#type:typedef}} {{#typedef:defined_kind?}} {{> codec/decode_typedef}} {{/typedef:defined_kind?}} {{^typedef:defined_kind?}} {{#type:typedef_type}} {{> codec/decode}} {{/type:typedef_type}} {{/typedef:defined_kind?}} {{/type:typedef}} {{/type:typedef?}} {{^type:typedef?}} {{#type:struct?}} {{#type:struct}} {{> codec/decode_struct}} {{/type:struct}} {{/type:struct?}} {{#type:enum?}} {{#type:enum}} {{> codec/decode_enum}} {{/type:enum}} {{/type:enum?}} {{#type:base?}} {{> codec/decode_base}} {{/type:base?}} {{#type:list?}} {{> codec/decode_list}} {{/type:list?}} {{#type:set?}} {{> codec/decode_set}} {{/type:set?}} {{#type:map?}} {{> codec/decode_map}} {{/type:map?}} {{/type:typedef?}} {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_base.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a base type. Note: byte type is special, it is sent/received on a Format object as Go 'byte' type, but is represented in the generated code as Go 'int8' type, so we need to do some type-converting here. }} {{#type:byte?}} resultByte, err := p.{{> common/primitive_decode_func}}() result := int8(resultByte) {{/type:byte?}} {{^type:byte?}} result, err := p.{{> common/primitive_decode_func}}() {{/type:byte?}} if err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for an enum type. }} enumResult, err := p.ReadI32() if err != nil { return err } result := {{enum:go_qualified_name}}(enumResult) {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a list type. }} _ /* elemType */, size, err := p.ReadListBegin() if err != nil { return thrift.PrependError("error reading list begin: ", err) } listResult := make({{> common/type}}, 0, size) for i := 0; i < size; i++ { {{#type:list_elem_type}} var elem {{> common/type}} {{! Use scope to avoid multiple 'result' variable collisions }} { {{> codec/decode}} elem = result } listResult = append(listResult, {{#type:struct?}}&{{/type:struct?}}elem) {{/type:list_elem_type}} } if err := p.ReadListEnd(); err != nil { return thrift.PrependError("error reading list end: ", err) } result := listResult {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_map.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a map type. }} _ /* keyType */, _ /* valueType */, size, err := p.ReadMapBegin() if err != nil { return thrift.PrependError("error reading map begin: ", err) } mapResult := make({{> common/type}}, size) for i := 0; i < size; i++ { {{! Use scopes to avoid multiple 'result' variable collisions }} {{#type:key_type}} var key {{^type:go_comparable?}}*{{/type:go_comparable?}}{{> common/type}} { {{> codec/decode}} key = {{^type:go_comparable?}}&{{/type:go_comparable?}}result } {{/type:key_type}} {{#type:value_type}} var value {{#type:struct?}}*{{/type:struct?}}{{> common/type}} { {{> codec/decode}} value = {{#type:struct?}}&{{/type:struct?}}result } {{/type:value_type}} mapResult[key] = value } if err := p.ReadMapEnd(); err != nil { return thrift.PrependError("error reading map end: ", err) } result := mapResult {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_set.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a set type. }} _ /* elemType */, size, err := p.ReadSetBegin() if err != nil { return thrift.PrependError("error reading set begin: ", err) } setResult := make({{> common/type}}, 0, size) for i := 0; i < size; i++ { {{#type:set_elem_type}} var elem {{> common/type}} {{! Use scope to avoid multiple 'result' variable collisions }} { {{> codec/decode}} elem = result } setResult = append(setResult, {{#type:struct?}}&{{/type:struct?}}elem) {{/type:set_elem_type}} } if err := p.ReadSetEnd(); err != nil { return thrift.PrependError("error reading set end: ", err) } result := setResult {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a struct type. }} result := *{{struct:go_qualified_new_func}}() err := result.Read(p) if err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/decode_typedef.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read code for a typedef. }} result, err := {{typedef:go_qualified_read_func}}(p) if err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a given field type. }} {{#type:typedef?}} {{#type:typedef}} {{#typedef:defined_kind?}} {{> codec/encode_typedef}} {{/typedef:defined_kind?}} {{^typedef:defined_kind?}} {{#type:typedef_type}} {{> codec/encode}} {{/type:typedef_type}} {{/typedef:defined_kind?}} {{/type:typedef}} {{/type:typedef?}} {{^type:typedef?}} {{#type:struct?}} {{#type:struct}} {{> codec/encode_struct}} {{/type:struct}} {{/type:struct?}} {{#type:enum?}} {{#type:enum}} {{> codec/encode_enum}} {{/type:enum}} {{/type:enum?}} {{#type:base?}} {{> codec/encode_base}} {{/type:base?}} {{#type:list?}} {{> codec/encode_list}} {{/type:list?}} {{#type:set?}} {{> codec/encode_set}} {{/type:set?}} {{#type:map?}} {{> codec/encode_map}} {{/type:map?}} {{/type:typedef?}} {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_base.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a base type. Note: byte type is special, it is sent/received on a Format object as Go 'byte' type, but is represented in the generated code as Go 'int8' type, so we need to do some type-converting here. }} {{#type:byte?}} if err := p.{{> common/primitive_encode_func}}(byte(item)); err != nil { {{/type:byte?}} {{^type:byte?}} if err := p.{{> common/primitive_encode_func}}(item); err != nil { {{/type:byte?}} return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for an enum type. }} if err := p.WriteI32(int32(item)); err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a list type. NOTE: `item` is allowed to be a `nil` slice! }} if err := p.WriteListBegin({{! }}{{#type:list_elem_type}}{{> common/ttype}}{{/type:list_elem_type}}, {{! }}len(item)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range item { {{! Use scope to avoid multiple 'item' variable collisions }} { item := v {{#type:list_elem_type}} {{> codec/encode}} {{/type:list_elem_type}} } } if err := p.WriteListEnd(); err != nil { return thrift.PrependError("error writing list end: ", err) } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_map.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a map type. NOTE: `item` is allowed to be a `nil` map! }} if err := p.WriteMapBegin({{! }}{{#type:key_type}}{{> common/ttype}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> common/ttype}}{{/type:value_type}}, {{! }}len(item)); err != nil { return thrift.PrependError("error writing map begin: ", err) } for k, v := range item { {{#type:key_type}} {{^type:go_comparable?}} if k == nil { return fmt.Errorf("%T write map: nil key is not allowed.", item) } {{/type:go_comparable?}} {{/type:key_type}} {{! Use scopes to avoid multiple 'item' variable collisions }} { {{#type:key_type}} item := {{^type:go_comparable?}}{{^type:struct?}}*{{/type:struct?}}{{/type:go_comparable?}}k {{> codec/encode}} {{/type:key_type}} } { item := v {{#type:value_type}} {{> codec/encode}} {{/type:value_type}} } } if err := p.WriteMapEnd(); err != nil { return thrift.PrependError("error writing map end: ", err) } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_set.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a set type. NOTE: `item` is allowed to be a `nil` map! }} if err := p.WriteSetBegin({{! }}{{#type:set_elem_type}}{{> common/ttype}}{{/type:set_elem_type}}, {{! }}len(item)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for _, v := range item { {{! Use scope to avoid multiple 'item' variable collisions }} { item := v {{#type:set_elem_type}} {{> codec/encode}} {{/type:set_elem_type}} } } if err := p.WriteSetEnd(); err != nil { return thrift.PrependError("error writing set end: ", err) } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a struct type. }} if err := item.Write(p); err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/codec/encode_typedef.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a typedef. }} err := {{typedef:go_qualified_write_func}}(item, p) if err != nil { return err } {{!newline}} )__FBTHRIFT_TAG__", // go/common/go_zero_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines a Go zero-value representation for a given Thrift type. The following templates have complete type parity: * const/value.mustache * common/natural_default_value.mustache * common/go_zero_value.mustache }}{{#type:typedef?}}{{! }}{{#type:typedef}}{{! }}{{#type:typedef_type}}{{ }}{{> common/go_zero_value}}{{! }}{{/type:typedef_type}}{{ }}{{/type:typedef}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:string?}}""{{/type:string?}}{{! }}{{#type:binary?}}nil{{/type:binary?}}{{! }}{{#type:bool?}}false{{/type:bool?}}{{! }}{{#type:byte?}}0{{/type:byte?}}{{! }}{{#type:i16?}}0{{/type:i16?}}{{! }}{{#type:i32?}}0{{/type:i32?}}{{! }}{{#type:i64?}}0{{/type:i64?}}{{! }}{{#type:double?}}0.0{{/type:double?}}{{! }}{{#type:float?}}0.0{{/type:float?}}{{! }}{{#type:enum?}}0{{/type:enum?}}{{! }}{{#type:list?}}nil{{/type:list?}}{{! }}{{#type:set?}}nil{{/type:set?}}{{! }}{{#type:map?}}nil{{/type:map?}}{{! }}{{#type:struct?}}nil{{/type:struct?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // go/common/header.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}// @{{}}generated by Thrift for [[[ program path ]]] // This file is probably not the place you want to edit! package {{program:go_pkg_name}} // [[[ program thrift source path ]]] {{!newline}} )__FBTHRIFT_TAG__", // go/common/natural_default_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines a Thrift natural default value for a given type. Natural default values are values assigned to Thrift fields/variables by default in the abscence of explicit user-provided default values. Natural default values are based on Thrift specification. All type values are rendered as "concrete" values, except for structs - which are rendered as struct pointers. Callers are responsible for dereferencing appropriately if needed. The following templates have complete type parity: * const/value.mustache * common/natural_default_value.mustache * common/go_zero_value.mustache }}{{#type:typedef?}}{{! }}{{#type:typedef}}{{! }}{{#typedef:defined_kind?}}{{ }}{{typedef:go_qualified_new_func}}(){{! }}{{/typedef:defined_kind?}}{{ }}{{^typedef:defined_kind?}}{{ }}{{#type:typedef_type}}{{ }}{{> common/natural_default_value}}{{! }}{{/type:typedef_type}}{{ }}{{/typedef:defined_kind?}}{{ }}{{/type:typedef}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:string?}}""{{/type:string?}}{{! }}{{#type:binary?}}[]byte(""){{/type:binary?}}{{! }}{{#type:bool?}}false{{/type:bool?}}{{! }}{{#type:byte?}}0{{/type:byte?}}{{! }}{{#type:i16?}}0{{/type:i16?}}{{! }}{{#type:i32?}}0{{/type:i32?}}{{! }}{{#type:i64?}}0{{/type:i64?}}{{! }}{{#type:double?}}0.0{{/type:double?}}{{! }}{{#type:float?}}0.0{{/type:float?}}{{! }}{{#type:enum?}}0{{/type:enum?}}{{! }}{{#type:list?}}make({{> common/type}}, 0){{/type:list?}}{{! }}{{#type:set?}}make({{> common/type}}, 0){{/type:set?}}{{! }}{{#type:map?}}make({{> common/type}}){{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#type:struct}}{{! }}{{struct:go_qualified_new_func}}(){{! }}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // go/common/pointerize_func.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines a pointerize function for a given primitive type. These functions come from thrift/lib/go/thrift/pointerize.go module. }}{{#type:byte?}}thrift.Int8Ptr{{/type:byte?}}{{! }}{{#type:i16?}}thrift.Int16Ptr{{/type:i16?}}{{! }}{{#type:i32?}}thrift.Int32Ptr{{/type:i32?}}{{! }}{{#type:i64?}}thrift.Int64Ptr{{/type:i64?}}{{! }}{{#type:string?}}thrift.StringPtr{{/type:string?}}{{! }}{{#type:bool?}}thrift.BoolPtr{{/type:bool?}}{{! }}{{#type:float?}}thrift.Float32Ptr{{/type:float?}}{{! }}{{#type:double?}}thrift.Float64Ptr{{/type:double?}} )__FBTHRIFT_TAG__", // go/common/primitive_decode_func.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the decoding/read function for a given primitive type. These functions come from Format interface in thrift/lib/go/thrift/format.go }}{{#type:string?}}ReadString{{/type:string?}}{{! }}{{#type:binary?}}ReadBinary{{/type:binary?}}{{! }}{{#type:bool?}}ReadBool{{/type:bool?}}{{! }}{{#type:byte?}}ReadByte{{/type:byte?}}{{! }}{{#type:i16?}}ReadI16{{/type:i16?}}{{! }}{{#type:i32?}}ReadI32{{/type:i32?}}{{! }}{{#type:i64?}}ReadI64{{/type:i64?}}{{! }}{{#type:double?}}ReadDouble{{/type:double?}}{{! }}{{#type:float?}}ReadFloat{{/type:float?}} )__FBTHRIFT_TAG__", // go/common/primitive_encode_func.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This file defines the encoding/write function for a given primitive type. These functions come from Format interface in thrift/lib/go/thrift/format.go }}{{#type:string?}}WriteString{{/type:string?}}{{! }}{{#type:binary?}}WriteBinary{{/type:binary?}}{{! }}{{#type:bool?}}WriteBool{{/type:bool?}}{{! }}{{#type:byte?}}WriteByte{{/type:byte?}}{{! }}{{#type:i16?}}WriteI16{{/type:i16?}}{{! }}{{#type:i32?}}WriteI32{{/type:i32?}}{{! }}{{#type:i64?}}WriteI64{{/type:i64?}}{{! }}{{#type:double?}}WriteDouble{{/type:double?}}{{! }}{{#type:float?}}WriteFloat{{/type:float?}} )__FBTHRIFT_TAG__", // go/common/registry.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines a RegisterStructs function for registering all program structs using a provided 'register' callback. }} // RegisterTypes registers types found in this file that have a thrift_uri with the passed in registry. func RegisterTypes(registry interface { RegisterType(name string, initializer func() any) }) { {{#program:structs}} {{#struct:thrift_uri}} registry.RegisterType("{{struct:thrift_uri}}", func() any { return {{struct:go_qualified_new_func}}() }) {{/struct:thrift_uri}} {{/program:structs}} {{#program:enums}} {{#enum:thrift_uri}} registry.RegisterType("{{enum:thrift_uri}}", func() any { return {{enum:go_name}}(0) }) {{/enum:thrift_uri}} {{/program:enums}} } )__FBTHRIFT_TAG__", // go/common/ttype.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines the mapping of a thrift type to the go thrift.TType value. }}{{#type:string?}}thrift.STRING{{/type:string?}}{{! }}{{#type:binary?}}thrift.STRING{{/type:binary?}}{{! }}{{#type:bool?}}thrift.BOOL{{/type:bool?}}{{! }}{{#type:byte?}}thrift.BYTE{{/type:byte?}}{{! }}{{#type:i16?}}thrift.I16{{/type:i16?}}{{! }}{{#type:i32?}}thrift.I32{{/type:i32?}}{{! }}{{#type:i64?}}thrift.I64{{/type:i64?}}{{! }}{{#type:double?}}thrift.DOUBLE{{/type:double?}}{{! }}{{#type:float?}}thrift.FLOAT{{/type:float?}}{{! }}{{#type:enum?}}thrift.I32{{/type:enum?}}{{! }}{{#type:struct?}}thrift.STRUCT{{/type:struct?}}{{! }}{{#type:list?}}thrift.LIST{{/type:list?}}{{! }}{{#type:set?}}thrift.SET{{/type:set?}}{{! }}{{#type:map?}}thrift.MAP{{/type:map?}} )__FBTHRIFT_TAG__", // go/common/type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines a Go type. }}{{#type:typedef?}}{{! }}{{#type:typedef}}{{! }}{{typedef:go_qualified_name}}{{! }}{{/type:typedef}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:string?}}string{{/type:string?}}{{! }}{{#type:binary?}}[]byte{{/type:binary?}}{{! }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int8{{/type:byte?}}{{! }}{{#type:i16?}}int16{{/type:i16?}}{{! }}{{#type:i32?}}int32{{/type:i32?}}{{! }}{{#type:i64?}}int64{{/type:i64?}}{{! }}{{#type:double?}}float64{{/type:double?}}{{! }}{{#type:float?}}float32{{/type:float?}}{{! }}{{#type:enum?}}{{! }}{{#type:enum}}{{! }}{{enum:go_qualified_name}}{{! }}{{/type:enum}}{{! }}{{/type:enum?}}{{! }}{{#type:struct?}}{{! }}{{#type:struct}}{{! }}{{struct:go_qualified_name}}{{! }}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{#type:list?}}{{! }}[]{{#type:list_elem_type}}{{! }}{{#type:struct?}}{{! }}*{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{^type:struct?}}{{! }}{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{/type:list_elem_type}}{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}map[{{! }}{{#type:key_type}}{{! }}{{#type:go_comparable?}}{{! }}{{> common/type}}{{! }}{{/type:go_comparable?}}{{! }}{{^type:go_comparable?}}{{! }}*{{> common/type}}{{! }}{{/type:go_comparable?}}{{! }}{{/type:key_type}}{{! }}]{{! }}{{#type:value_type}}{{! }}{{#type:struct?}}{{! }}*{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{^type:struct?}}{{! }}{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{/type:value_type}}{{! }}{{/type:map?}}{{! }}{{#type:set?}}{{! }}[]{{#type:set_elem_type}}{{! }}{{#type:struct?}}{{! }}*{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{^type:struct?}}{{! }}{{> common/type}}{{! }}{{/type:struct?}}{{! }}{{/type:set_elem_type}}{{! }}{{/type:set?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // go/common/unused_imports_protection.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Protection for unused imports. }} {{#program:thrift_imports}} var _ = {{program:go_package_alias}}.GoUnusedProtection__ {{/program:thrift_imports}} {{! new line }} )__FBTHRIFT_TAG__", // go/const.go.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{> common/header}} import ( {{#program:thrift_imports}} {{program:go_package_alias}} "{{program:go_import_path}}" {{/program:thrift_imports}} thrift "{{program:thrift_lib_import}}" ) {{> common/unused_imports_protection}} // (needed to ensure safety because of naive import list construction) var _ = thrift.ZERO var GoUnusedProtection__ int {{#program:constants?}} {{#program:constants}} {{#constant:docs?}} {{! new line before documented constant}} {{constant:docs}}{{! }}{{/constant:docs?}}{{! }}{{#constant:var?}}var {{/constant:var?}}{{! }}{{^constant:var?}}const {{/constant:var?}}{{! }}{{constant:go_name}} {{! }}{{#constant:type}}{{! }}{{#type:struct?}}*{{/type:struct?}}{{> common/type}} = {{! }}{{#constant:value}}{{! }}{{> const/value}}{{! }}{{/constant:value}} {{/constant:type}} {{#constant:docs?}} {{! new line after documented constant}} {{/constant:docs?}}{{! }}{{/program:constants}}{{! }}{{/program:constants?}} )__FBTHRIFT_TAG__", // go/const/struct_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{struct:go_qualified_new_func}}(){{! }}{{#value:const_struct?}}{{! }}{{#value:const_struct}}. Set{{constant:go_name}}{{#program:compat_setters?}}NonCompat{{/program:compat_setters?}}({{! }}{{#constant:type}}{{! }}{{#constant:value}}{{! }}{{^value:base?}} {{#type:struct?}}*{{/type:struct?}}{{> const/value}}, {{/value:base?}}{{! }}{{#value:base?}}{{! }}{{> const/value}}{{! }}{{/value:base?}}{{! }}{{/constant:value}}{{! }}{{/constant:type}}{{! }}){{! }}{{/value:const_struct}}{{! }}{{/value:const_struct?}} )__FBTHRIFT_TAG__", // go/const/value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines a constant value representation for a given value. All type values are rendered as "concrete" values, except for structs - which are rendered as struct pointers. Callers are responsible for dereferencing appropriately if needed. The following templates have complete type parity: * const/value.mustache * common/natural_default_value.mustache * common/go_zero_value.mustache }} {{#type:typedef?}}{{! }}{{#type:typedef_type}}{{! }}{{> const/value}}{{! }}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:byte?}}{{value:integer_value}}{{/type:byte?}}{{! }}{{#type:i16?}}{{value:integer_value}}{{/type:i16?}}{{! }}{{#type:i32?}}{{value:integer_value}}{{/type:i32?}}{{! }}{{#type:i64?}}{{value:integer_value}}{{/type:i64?}}{{! }}{{#type:string?}}{{value:go_quoted_value}}{{/type:string?}}{{! }}{{#type:binary?}}[]byte({{value:go_quoted_value}}){{/type:binary?}}{{! }}{{#type:bool?}}{{! }}{{#value:nonzero?}}true{{/value:nonzero?}}{{! }}{{^value:nonzero?}}false{{/value:nonzero?}}{{! }}{{/type:bool?}}{{! }}{{#type:float?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:double?}}{{! }}{{#type:enum?}}{{! }}{{#type:enum}}{{! }}{{enum:go_qualified_name}}{{! }}{{/type:enum}}{{! }}{{#value:enum_value?}}{{! }}{{#value:enum_value}}{{! Known enum value with a name. }}_{{enum_value:name}}{{! }}{{/value:enum_value}}{{! }}{{/value:enum_value?}}{{! }}{{^value:enum_value?}}{{! Unknown enum value without a name. }}({{value:integer_value}}){{! }}{{/value:enum_value?}}{{! }}{{/type:enum?}}{{! Structs }}{{#type:struct?}}{{! }}{{#type:struct}}{{! }}{{#value:referenceable?}}{{! }}{{#value:owning_const}}{{! }}{{#constant:program}}{{! }}{{constant:go_qualified_name}}{{! }}{{/constant:program}}{{! }}{{/value:owning_const}}{{! }}{{/value:referenceable?}}{{! }}{{^value:referenceable?}}{{! }}{{> const/struct_value}}{{! }}{{/value:referenceable?}}{{! }}{{/type:struct}}{{! }}{{/type:struct?}}{{! Map constants }}{{#type:map?}}{{! }}{{> common/type}}{ {{#value:map_elements}} {{#element:key}}{{! }}{{#type:key_type}}{{! }}{{> const/value}}{{! }}{{/type:key_type}}{{! }}{{/element:key}}: {{! }}{{#element:value}}{{! }}{{#type:value_type}}{{! }}{{> const/value}}{{! }}{{/type:value_type}}{{! }}{{/element:value}}, {{/value:map_elements}} }{{/type:map?}}{{! List constants }}{{#type:list?}}{{! }}{{> common/type}}{ {{#value:list_elements}} {{#type:list_elem_type}}{{! }}{{> const/value}},{{! }}{{/type:list_elem_type}} {{/value:list_elements}} }{{/type:list?}}{{! Set constants }}{{#type:set?}}{{! }}{{> common/type}}{ {{#value:list_elements}} {{#type:set_elem_type}}{{! }}{{> const/value}},{{! }}{{/type:set_elem_type}} {{/value:list_elements}} }{{/type:set?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // go/doc.go.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#program:docs?}} {{program:docs}} {{/program:docs?}} {{> common/header}} )__FBTHRIFT_TAG__", // go/metadata.go.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! NOTE: Unfortunately map literals cannot be used to store metadata, due to a bug in the Go compiler: https://github.com/golang/go/issues/33437 The bug results in a "NewBulk too big" compilation error for some very large schemas. The workaround is to create slice literals (one with keys, one with values), create an empty map during runtime and populate that map from the two slices. }}{{> common/header}} import ( {{#program:thrift_imports}} {{program:go_package_alias}} "{{program:go_import_path}}" {{/program:thrift_imports}} thrift "{{program:thrift_lib_import}}" {{#program:import_metadata_package?}} metadata "{{program:thrift_metadata_import}}" {{/program:import_metadata_package?}} ) // mapsCopy is a copy of maps.Copy from Go 1.21 // TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback. func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { for k, v := range src { dst[k] = v } } {{> common/unused_imports_protection}} // (needed to ensure safety because of naive import list construction) var _ = thrift.ZERO // TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback. // var _ = maps.Copy[map[int]int, map[int]int] {{#program:import_metadata_package?}} var _ = metadata.GoUnusedProtection__ {{/program:import_metadata_package?}} // Premade Thrift types var ( {{#program:thrift_metadata_types}} {{type:metadata_name}} = {{program:metadata_qualifier}}NewThriftType().{{> metadata/thrift_type_setter}}( {{> metadata/thrift_type_instance}} ) {{/program:thrift_metadata_types}} ) var structMetadatas = []*{{program:metadata_qualifier}}ThriftStruct{ {{#program:structs}} {{^struct:exception?}} {{> metadata/thrift_metadata_struct}}, {{/struct:exception?}} {{/program:structs}} } var exceptionMetadatas = []*{{program:metadata_qualifier}}ThriftException{ {{#program:structs}} {{#struct:exception?}} {{> metadata/thrift_metadata_exception}}, {{/struct:exception?}} {{/program:structs}} } var enumMetadatas = []*{{program:metadata_qualifier}}ThriftEnum{ {{#program:enums}} {{> metadata/thrift_metadata_enum}}, {{/program:enums}} } var serviceMetadatas = []*{{program:metadata_qualifier}}ThriftService{ {{#program:services}} {{> metadata/thrift_metadata_service}}, {{/program:services}} } // GetThriftMetadata returns complete Thrift metadata for current and imported packages. func GetThriftMetadata() *{{program:metadata_qualifier}}ThriftMetadata { allEnums := GetEnumsMetadata() allStructs := GetStructsMetadata() allExceptions := GetExceptionsMetadata() allServices := GetServicesMetadata() return {{program:metadata_qualifier}}NewThriftMetadata(). SetEnums(allEnums). SetStructs(allStructs). SetExceptions(allExceptions). SetServices(allServices) } // GetEnumsMetadata returns Thrift metadata for enums in the current and recursively included packages. func GetEnumsMetadata() map[string]*{{program:metadata_qualifier}}ThriftEnum { allEnumsMap := make(map[string]*{{program:metadata_qualifier}}ThriftEnum) // Add enum metadatas from the current program... for _, enumMetadata := range enumMetadatas { allEnumsMap[enumMetadata.GetName()] = enumMetadata } // ...now add enum metadatas from recursively included programs. {{#program:thrift_imports}} mapsCopy(allEnumsMap, {{program:go_package_alias}}.GetEnumsMetadata()) {{/program:thrift_imports}} return allEnumsMap } // GetStructsMetadata returns Thrift metadata for structs in the current and recursively included packages. func GetStructsMetadata() map[string]*{{program:metadata_qualifier}}ThriftStruct { allStructsMap := make(map[string]*{{program:metadata_qualifier}}ThriftStruct) // Add struct metadatas from the current program... for _, structMetadata := range structMetadatas { allStructsMap[structMetadata.GetName()] = structMetadata } // ...now add struct metadatas from recursively included programs. {{#program:thrift_imports}} mapsCopy(allStructsMap, {{program:go_package_alias}}.GetStructsMetadata()) {{/program:thrift_imports}} return allStructsMap } // GetExceptionsMetadata returns Thrift metadata for exceptions in the current and recursively included packages. func GetExceptionsMetadata() map[string]*{{program:metadata_qualifier}}ThriftException { allExceptionsMap := make(map[string]*{{program:metadata_qualifier}}ThriftException) // Add exception metadatas from the current program... for _, exceptionMetadata := range exceptionMetadatas { allExceptionsMap[exceptionMetadata.GetName()] = exceptionMetadata } // ...now add exception metadatas from recursively included programs. {{#program:thrift_imports}} mapsCopy(allExceptionsMap, {{program:go_package_alias}}.GetExceptionsMetadata()) {{/program:thrift_imports}} return allExceptionsMap } // GetServicesMetadata returns Thrift metadata for services in the current and recursively included packages. func GetServicesMetadata() map[string]*{{program:metadata_qualifier}}ThriftService { allServicesMap := make(map[string]*{{program:metadata_qualifier}}ThriftService) // Add service metadatas from the current program... for _, serviceMetadata := range serviceMetadatas { allServicesMap[serviceMetadata.GetName()] = serviceMetadata } // ...now add service metadatas from recursively included programs. {{#program:thrift_imports}} mapsCopy(allServicesMap, {{program:go_package_alias}}.GetServicesMetadata()) {{/program:thrift_imports}} return allServicesMap } // GetThriftMetadataForService returns Thrift metadata for the given service. func GetThriftMetadataForService(scopedServiceName string) *{{program:metadata_qualifier}}ThriftMetadata { thriftMetadata := GetThriftMetadata() allServicesMap := thriftMetadata.GetServices() relevantServicesMap := make(map[string]*{{program:metadata_qualifier}}ThriftService) serviceMetadata := allServicesMap[scopedServiceName] // Visit and record all recursive parents of the target service. for serviceMetadata != nil { relevantServicesMap[serviceMetadata.GetName()] = serviceMetadata if serviceMetadata.IsSetParent() { serviceMetadata = allServicesMap[serviceMetadata.GetParent()] } else { serviceMetadata = nil } } thriftMetadata.SetServices(relevantServicesMap) return thriftMetadata } )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift enum. }} {{program:metadata_qualifier}}NewThriftEnum(). SetName("{{enum:scoped_name}}"). SetElements( map[int32]string{ {{#enum:values}} {{enum_value:value}}: "{{enum_value:name}}", {{/enum:values}} }, ) )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_exception.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift exception. }} {{program:metadata_qualifier}}NewThriftException(). SetName("{{struct:scoped_name}}"){{#struct:fields?}}. SetFields( []*{{program:metadata_qualifier}}ThriftField{ {{#struct:fields_sorted}} {{> metadata/thrift_metadata_field}}, {{/struct:fields_sorted}} }, ){{/struct:fields?}} )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift struct field. }} {{program:metadata_qualifier}}NewThriftField(). SetId({{field:key}}). SetName("{{field:name}}"). SetIsOptional({{#field:optional?}}true{{/field:optional?}}{{^field:optional?}}false{{/field:optional?}}). SetType({{#field:type}}{{type:metadata_name}}{{/field:type}}) )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_function.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift service function. }} {{program:metadata_qualifier}}NewThriftFunction(). SetName("{{function:name}}"). SetIsOneway({{#function:oneway?}}true{{/function:oneway?}}{{^function:oneway?}}false{{/function:oneway?}}). SetReturnType({{#function:return_type}}{{type:metadata_name}}{{/function:return_type}}){{#function:args?}}. SetArguments( []*{{program:metadata_qualifier}}ThriftField{ {{#function:args}} {{> metadata/thrift_metadata_field}}, {{/function:args}} }, ){{/function:args?}}{{#function:exceptions?}}. SetExceptions( []*{{program:metadata_qualifier}}ThriftField{ {{#function:exceptions}} {{> metadata/thrift_metadata_field}}, {{/function:exceptions}} }, ){{/function:exceptions?}} )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_service.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift service. }} {{program:metadata_qualifier}}NewThriftService(). SetName("{{service:scoped_name}}"). {{#service:extends?}} {{#service:extends}} SetParent(thrift.StringPtr("{{service:scoped_name}}")). {{/service:extends}} {{/service:extends?}} SetFunctions( []*{{program:metadata_qualifier}}ThriftFunction{ {{#service:functions}} {{#function:go_supported?}} {{> metadata/thrift_metadata_function}}, {{/function:go_supported?}} {{/service:functions}} }, ) )__FBTHRIFT_TAG__", // go/metadata/thrift_metadata_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines metadata for a Thrift struct. }} {{program:metadata_qualifier}}NewThriftStruct(). SetName("{{struct:scoped_name}}"). SetIsUnion({{#struct:union?}}true{{/struct:union?}}{{^struct:union?}}false{{/struct:union?}}){{#struct:fields?}}. SetFields( []*{{program:metadata_qualifier}}ThriftField{ {{#struct:fields_sorted}} {{> metadata/thrift_metadata_field}}, {{/struct:fields_sorted}} }, ){{/struct:fields?}} )__FBTHRIFT_TAG__", // go/metadata/thrift_primitive_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines the mapping from an AST type to Thrift metadata primitive type. }}{{#type:string?}}THRIFT_STRING_TYPE{{/type:string?}}{{! }}{{#type:binary?}}THRIFT_BINARY_TYPE{{/type:binary?}}{{! }}{{#type:bool?}}THRIFT_BOOL_TYPE{{/type:bool?}}{{! }}{{#type:byte?}}THRIFT_BYTE_TYPE{{/type:byte?}}{{! }}{{#type:i16?}}THRIFT_I16_TYPE{{/type:i16?}}{{! }}{{#type:i32?}}THRIFT_I32_TYPE{{/type:i32?}}{{! }}{{#type:i64?}}THRIFT_I64_TYPE{{/type:i64?}}{{! }}{{#type:double?}}THRIFT_DOUBLE_TYPE{{/type:double?}}{{! }}{{#type:float?}}THRIFT_FLOAT_TYPE{{/type:float?}}{{! }}{{#type:void?}}THRIFT_VOID_TYPE{{/type:void?}} )__FBTHRIFT_TAG__", // go/metadata/thrift_type_instance.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines the mapping from an AST type to Thrift metadata type. }} {{#type:typedef?}} {{#type:typedef}} {{#typedef:defined_kind?}} {{program:metadata_qualifier}}NewThriftTypedefType(). SetName("{{typedef:scoped_name}}"). SetUnderlyingType({{#type:typedef_type}}{{type:metadata_name}}{{/type:typedef_type}}), {{/typedef:defined_kind?}} {{^typedef:defined_kind?}} {{#type:typedef_type}} {{> metadata/thrift_type_instance}} {{/type:typedef_type}} {{/typedef:defined_kind?}} {{/type:typedef}} {{/type:typedef?}} {{^type:typedef?}} {{#type:metadata_primitive?}} {{program:metadata_qualifier}}ThriftPrimitiveType_{{> metadata/thrift_primitive_type}}.Ptr(), {{/type:metadata_primitive?}} {{#type:enum?}} {{#type:enum}} {{program:metadata_qualifier}}NewThriftEnumType(). SetName("{{enum:scoped_name}}"), {{/type:enum}} {{/type:enum?}} {{#type:struct?}} {{#type:struct}} {{#struct:union?}} {{program:metadata_qualifier}}NewThriftUnionType(). SetName("{{struct:scoped_name}}"), {{/struct:union?}} {{^struct:union?}} {{program:metadata_qualifier}}NewThriftStructType(). SetName("{{struct:scoped_name}}"), {{/struct:union?}} {{/type:struct}} {{/type:struct?}} {{#type:list?}} {{#type:list_elem_type}} {{program:metadata_qualifier}}NewThriftListType(). SetValueType({{type:metadata_name}}), {{/type:list_elem_type}} {{/type:list?}} {{#type:map?}} {{program:metadata_qualifier}}NewThriftMapType(). SetKeyType({{#type:key_type}}{{type:metadata_name}}{{/type:key_type}}). SetValueType({{#type:value_type}}{{type:metadata_name}}{{/type:value_type}}), {{/type:map?}} {{#type:set?}} {{#type:set_elem_type}} {{program:metadata_qualifier}}NewThriftSetType(). SetValueType({{type:metadata_name}}), {{/type:set_elem_type}} {{/type:set?}} {{/type:typedef?}} )__FBTHRIFT_TAG__", // go/metadata/thrift_type_setter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines the mapping from an AST type to Thrift metadata type setter function name. }}{{#type:typedef?}}{{! }}{{#type:typedef}}{{! }}{{#typedef:defined_kind?}}{{! }}SetTTypedef{{! }}{{/typedef:defined_kind?}}{{! }}{{^typedef:defined_kind?}}{{! }}{{#type:typedef_type}}{{! }}{{> metadata/thrift_type_setter}}{{! }}{{/type:typedef_type}}{{! }}{{/typedef:defined_kind?}}{{! }}{{/type:typedef}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:metadata_primitive?}}{{! }}SetTPrimitive{{! }}{{/type:metadata_primitive?}}{{! }}{{#type:enum?}}{{! }}SetTEnum{{! }}{{/type:enum?}}{{! }}{{#type:struct?}}{{! }}{{#type:struct}}{{! }}{{#struct:union?}}{{! }}SetTUnion{{! }}{{/struct:union?}}{{! }}{{^struct:union?}}{{! }}SetTStruct{{! }}{{/struct:union?}}{{! }}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{#type:list?}}{{! }}SetTList{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}SetTMap{{! }}{{/type:map?}}{{! }}{{#type:set?}}{{! }}SetTSet{{! }}{{/type:set?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // go/svc/client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defined the client type/functions for a thrift service. }} type {{service:go_name}}ChannelClient struct { {{#service:extends?}} {{#service:extends}} // Inherited/extended service *{{service:go_qualified_name}}ChannelClient {{/service:extends}} {{/service:extends?}} ch thrift.RequestChannel } // Compile time interface enforcer var _ {{service:go_name}}ChannelClientInterface = &{{service:go_name}}ChannelClient{} func New{{service:go_name}}ChannelClient(channel thrift.RequestChannel) *{{service:go_name}}ChannelClient { return &{{service:go_name}}ChannelClient{ {{#service:extends?}} {{#service:extends}} {{service:go_name}}ChannelClient: {{service:go_package_alias_prefix}}New{{service:go_name}}ChannelClient(channel), {{/service:extends}} {{/service:extends?}} ch: channel, } } func (c *{{service:go_name}}ChannelClient) Close() error { return c.ch.Close() } type {{service:go_name}}Client struct { {{#service:extends?}} {{#service:extends}} // Inherited/extended service *{{service:go_qualified_name}}Client {{/service:extends}} {{/service:extends?}} chClient *{{service:go_name}}ChannelClient Mu sync.Mutex } // Compile time interface enforcer var _ {{service:go_name}}ClientInterface = &{{service:go_name}}Client{} var _ {{service:go_name}}ContextClientInterface = &{{service:go_name}}Client{} func New{{service:go_name}}Client(prot thrift.Protocol) *{{service:go_name}}Client { return &{{service:go_name}}Client{ {{#service:extends?}} {{#service:extends}} {{service:go_name}}Client: {{service:go_package_alias_prefix}}New{{service:go_name}}Client(prot), {{/service:extends}} {{/service:extends?}} chClient: New{{service:go_name}}ChannelClient( thrift.NewSerialChannel(prot), ), } } func (c *{{service:go_name}}Client) Close() error { return c.chClient.Close() } {{#service:functions}} {{#function:go_supported?}} func (c *{{service:go_name}}ChannelClient) {{> svc/func_signature}} { {{function:in_var_name}} := &req{{service:go_name}}{{function:go_name}}{ {{#function:args}} {{#field:type}} {{field:go_name}}: {{field:go_arg_name}}, {{/field:type}} {{/function:args}} } {{#function:oneway?}} return c.ch.Oneway({{function:ctx_arg_name}}, "{{function:name}}", {{function:in_var_name}}) {{/function:oneway?}}{{! }}{{^function:oneway?}} {{function:out_var_name}} := newResp{{service:go_name}}{{function:go_name}}() {{function:err_var_name}} := c.ch.Call({{function:ctx_arg_name}}, "{{function:name}}", {{function:in_var_name}}, {{function:out_var_name}}) if {{function:err_var_name}} != nil { return {{^function:void?}}{{#function:return_type}}{{> common/go_zero_value}}{{/function:return_type}}, {{/function:void?}}{{function:err_var_name}} }{{#function:exceptions?}}{{! }}{{#function:exceptions}}{{! }} else if {{function:out_var_name}}.{{field:go_name}} != nil { return {{^function:void?}}{{#function:return_type}}{{> common/go_zero_value}}{{/function:return_type}}, {{/function:void?}}{{function:out_var_name}}.{{field:go_name}} }{{/function:exceptions}}{{! }}{{/function:exceptions?}} return {{^function:void?}}{{function:out_var_name}}.Get{{function:retval_field_name}}(), {{/function:void?}}nil {{/function:oneway?}} } func (c *{{service:go_name}}Client) {{> svc/func_signature_no_ctx}} { return c.chClient.{{function:go_name}}(context.Background(){{function:comma}}{{! }}{{#function:args}}{{field:go_arg_name}}{{^last?}}, {{/last?}}{{/function:args}}) } func (c *{{service:go_name}}Client) {{> svc/func_signature_with_ctx}} { return c.chClient.{{function:go_name}}({{function:ctx_arg_name}}{{function:comma}}{{! }}{{#function:args}}{{field:go_arg_name}}{{^last?}}, {{/last?}}{{/function:args}}) } {{/function:go_supported?}} {{/service:functions}} {{#service:req_resp_structs}} {{> types/struct}} {{/service:req_resp_structs}} )__FBTHRIFT_TAG__", // go/svc/func_signature.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines function signature for the service methods. }}{{function:go_name}}({{! }}{{function:ctx_arg_name}} context.Context{{! }}{{function:comma}}{{! }}{{#function:args}}{{! }}{{field:go_arg_name}} {{#field:type}}{{> types/field_type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) {{! }}{{#function:return_type}}{{! }}({{^type:void?}}{{#type:struct?}}*{{/type:struct?}}{{> common/type}}, {{/type:void?}}error){{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // go/svc/func_signature_no_ctx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines function signature for the service methods, without the context. }}{{function:go_name}}({{! }}{{#function:args}}{{! }}{{field:go_arg_name}} {{#field:type}}{{> types/field_type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) {{! }}{{#function:return_type}}{{! }}({{^type:void?}}{{#type:struct?}}*{{/type:struct?}}{{> common/type}}, {{/type:void?}}error){{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // go/svc/func_signature_with_ctx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines function signature for the service methods. }}{{function:go_name}}Context({{! }}{{function:ctx_arg_name}} context.Context{{! }}{{function:comma}}{{! }}{{#function:args}}{{! }}{{field:go_arg_name}} {{#field:type}}{{> types/field_type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) {{! }}{{#function:return_type}}{{! }}({{^type:void?}}{{#type:struct?}}*{{/type:struct?}}{{> common/type}}, {{/type:void?}}error){{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // go/svc/interface.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}type {{service:go_name}} interface { {{#service:extends?}} {{#service:extends}} // Inherited/extended service {{service:go_qualified_name}} {{/service:extends}} {{/service:extends?}} {{#service:functions}} {{#function:go_supported?}} {{> svc/func_signature}} {{/function:go_supported?}} {{/service:functions}} } type {{service:go_name}}ChannelClientInterface interface { thrift.ClientInterface {{service:go_name}} } type {{service:go_name}}ClientInterface interface { thrift.ClientInterface {{^program:compat?}} {{#service:extends?}} {{#service:extends}} // Inherited/extended service {{service:go_qualified_name}}ClientInterface {{/service:extends}} {{/service:extends?}} {{/program:compat?}} {{#service:functions}} {{#function:go_supported?}} {{> svc/func_signature_no_ctx}} {{/function:go_supported?}} {{/service:functions}} } {{!COMPAT: backwards compatibility Currently there are a bunch of use cases that implement ClientInterface without Context functions. 1. We need to manually move them over to ContextClientInterface 2. Add func_signature_with_ctx to ClientInterface 3. Move them back to ClientInterface 4. Delete ContextClientInterface }}{{! }}type {{service:go_name}}ContextClientInterface interface { {{service:go_name}}ClientInterface {{#service:extends?}} {{#service:extends}} // Inherited/extended service {{service:go_qualified_name}}ContextClientInterface {{/service:extends}} {{/service:extends?}} {{#service:functions}} {{#function:go_supported?}} {{> svc/func_signature_with_ctx}} {{/function:go_supported?}} {{/service:functions}} } )__FBTHRIFT_TAG__", // go/svc/proc_func_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines function name for processor. }}procFunc{{service:go_name}}{{function:go_name}} )__FBTHRIFT_TAG__", // go/svc/processor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This tempalte defined the client type/functions for a thrift service. }} type {{service:go_name}}Processor struct { {{#service:extends?}} {{#service:extends}} // Inherited/extended processor *{{service:go_qualified_name}}Processor {{/service:extends}} {{/service:extends?}} {{^service:extends?}} processorMap map[string]thrift.ProcessorFunctionContext functionServiceMap map[string]string handler {{service:go_name}} {{/service:extends?}} } // Compile time interface enforcer var _ thrift.ProcessorContext = &{{service:go_name}}Processor{} func New{{service:go_name}}Processor(handler {{service:go_name}}) *{{service:go_name}}Processor { p := &{{service:go_name}}Processor{ {{#service:extends?}} {{#service:extends}} {{service:go_package_alias_prefix}}New{{service:go_name}}Processor(handler), {{/service:extends}} {{/service:extends?}} {{^service:extends?}} handler: handler, processorMap: make(map[string]thrift.ProcessorFunctionContext), functionServiceMap: make(map[string]string), {{/service:extends?}} } {{#service:functions}} {{#function:go_supported?}} p.AddToProcessorMap("{{function:name}}", &{{> svc/proc_func_name}}{handler: handler}) {{/function:go_supported?}} {{/service:functions}} {{#service:functions}} {{#function:go_supported?}} p.AddToFunctionServiceMap("{{function:name}}", "{{service:go_name}}") {{/function:go_supported?}} {{/service:functions}} return p } {{^service:extends?}} func (p *{{service:go_name}}Processor) AddToProcessorMap(key string, processor thrift.ProcessorFunctionContext) { p.processorMap[key] = processor } func (p *{{service:go_name}}Processor) AddToFunctionServiceMap(key, service string) { p.functionServiceMap[key] = service } func (p *{{service:go_name}}Processor) GetProcessorFunctionContext{{! }}(key string) (processor thrift.ProcessorFunctionContext, err error) { if processor, ok := p.processorMap[key]; ok { return processor, nil } return nil, nil } func (p *{{service:go_name}}Processor) ProcessorMap() map[string]thrift.ProcessorFunctionContext { return p.processorMap } func (p *{{service:go_name}}Processor) FunctionServiceMap() map[string]string { return p.functionServiceMap } {{/service:extends?}} {{#program:gen_metadata?}} func (p *{{service:go_name}}Processor) GetThriftMetadata() *{{program:metadata_qualifier}}ThriftMetadata { return GetThriftMetadataForService("{{service:scoped_name}}") } {{/program:gen_metadata?}} {{#service:functions}} {{#function:go_supported?}} type {{> svc/proc_func_name}} struct { handler {{service:go_name}} } // Compile time interface enforcer var _ thrift.ProcessorFunctionContext = &{{> svc/proc_func_name}}{} func (p *{{> svc/proc_func_name}}) Read(iprot thrift.Format) (thrift.Struct, thrift.Exception) { args := newReq{{service:go_name}}{{function:go_name}}() if err := args.Read(iprot); err != nil { return nil, err } iprot.ReadMessageEnd() return args, nil } func (p *{{> svc/proc_func_name}}) Write(seqId int32, result thrift.WritableStruct, oprot thrift.Format) (err thrift.Exception) { var err2 error messageType := thrift.REPLY switch {{#function:exceptions?}}v := {{/function:exceptions?}}result.(type) { {{#function:exceptions?}} {{#function:exceptions}} case *{{#field:type}}{{> common/type}}{{/field:type}}: result = &resp{{service:go_name}}{{function:go_name}}{ {{field:go_name}}: v, } {{/function:exceptions}} {{/function:exceptions?}} case thrift.ApplicationException: messageType = thrift.EXCEPTION } if err2 = oprot.WriteMessageBegin("{{function:name}}", messageType, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { err = err2 } if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { err = err2 } if err2 = oprot.Flush(); err == nil && err2 != nil { err = err2 } return err } func (p *{{> svc/proc_func_name}}) RunContext(ctx context.Context, reqStruct thrift.Struct) (thrift.WritableStruct, thrift.ApplicationException) { {{#function:args?}} args := reqStruct.(*req{{service:go_name}}{{function:go_name}}) {{/function:args?}} {{^function:oneway?}} result := newResp{{service:go_name}}{{function:go_name}}() {{/function:oneway?}} {{^function:void?}}retval, {{/function:void?}}err := p.handler.{{function:go_name}}({{! }}ctx{{function:comma}}{{! }}{{#function:args}}{{! }}args.{{field:go_name}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}) if err != nil { {{#function:exceptions?}} switch v := err.(type) { {{#function:exceptions}} case *{{#field:type}}{{> common/type}}{{/field:type}}: result.{{field:go_name}} = v return result, nil {{/function:exceptions}} default: x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing {{function:go_name}}: " + err.Error(), err) return x, x } {{/function:exceptions?}} {{^function:exceptions?}} x := thrift.NewApplicationExceptionCause(thrift.INTERNAL_ERROR, "Internal error processing {{function:go_name}}: " + err.Error(), err) return x, x {{/function:exceptions?}} } {{^function:void?}} result.{{function:retval_field_name}} = {{^function:retval_nilable?}}&{{/function:retval_nilable?}}retval {{/function:void?}} {{#function:oneway?}} return nil, nil {{/function:oneway?}} {{^function:oneway?}} return result, nil {{/function:oneway?}} } {{/function:go_supported?}} {{/service:functions}} )__FBTHRIFT_TAG__", // go/svcs.go.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{> common/header}} {{#program:services?}} import ( "context" "fmt" "strings" "sync" {{#program:thrift_imports}} {{program:go_package_alias}} "{{program:go_import_path}}" {{/program:thrift_imports}} thrift "{{program:thrift_lib_import}}" {{#program:gen_metadata?}} {{#program:import_metadata_package?}} metadata "{{program:thrift_metadata_import}}" {{/program:import_metadata_package?}} {{/program:gen_metadata?}} ) {{> common/unused_imports_protection}} // (needed to ensure safety because of naive import list construction) var _ = context.Background var _ = fmt.Printf var _ = strings.Split var _ = sync.Mutex{} var _ = thrift.ZERO {{#program:gen_metadata?}} {{#program:import_metadata_package?}} var _ = metadata.GoUnusedProtection__ {{/program:import_metadata_package?}} {{/program:gen_metadata?}} {{#program:services}}{{! }}{{#service:docs?}}{{! }}{{service:docs}}{{! }}{{/service:docs?}} {{> svc/interface}} {{> svc/client}} {{> svc/processor}} {{/program:services}} {{/program:services?}} )__FBTHRIFT_TAG__", // go/types.go.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{> common/header}} import ( "fmt" "strings" {{#program:thrift_imports}} {{program:go_package_alias}} "{{program:go_import_path}}" {{/program:thrift_imports}} thrift "{{program:thrift_lib_import}}" ) {{> common/unused_imports_protection}} // (needed to ensure safety because of naive import list construction) var _ = fmt.Printf var _ = strings.Split var _ = thrift.ZERO {{! Typedefs }} {{#program:typedefs?}} {{#program:typedefs}} {{> types/typedef}} {{/program:typedefs}} {{/program:typedefs?}} {{! Enums }} {{#program:enums?}} {{#program:enums}} {{> types/enum}} {{/program:enums}} {{/program:enums?}} {{! Structs }} {{#program:structs?}} {{#program:structs}} {{> types/struct}} {{/program:structs}} {{/program:structs?}} {{#program:structs?}} {{> common/registry}} {{/program:structs?}} )__FBTHRIFT_TAG__", // go/types/enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template generates a Thrift enum. }} type {{enum:go_name}} int32 {{^enum:empty?}} const ( {{#enum:values}} {{enum:go_name}}_{{enum_value:name}} {{enum:go_name}} = {{enum_value:value}} {{/enum:values}} ) {{/enum:empty?}} // Enum value maps for {{enum:go_name}} var ( {{enum:go_name}}ToName = map[{{enum:go_name}}]string { {{#enum:values}} {{enum:go_name}}_{{enum_value:name}}: "{{enum_value:name}}", {{/enum:values}} } {{enum:go_name}}ToValue = map[string]{{enum:go_name}} { {{#enum:values}} "{{enum_value:name}}": {{enum:go_name}}_{{enum_value:name}}, {{/enum:values}} } ) func (x {{enum:go_name}}) String() string { if v, ok := {{enum:go_name}}ToName[x]; ok { return v } return "" } func (x {{enum:go_name}}) Ptr() *{{enum:go_name}} { return &x } {{#program:compat?}} // Deprecated: Use {{enum:go_name}}ToValue instead (e.g. `x, ok := {{enum:go_name}}ToValue["name"]`). func {{enum:go_name}}FromString(s string) ({{enum:go_name}}, error) { if v, ok := {{enum:go_name}}ToValue[s]; ok { return v, nil } return {{enum:go_name}}(0), fmt.Errorf("not a valid {{enum:go_name}} string") } {{/program:compat?}} )__FBTHRIFT_TAG__", // go/types/field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates struct field definitions for thrift structs. }} {{field:go_name}} {{> types/field_type}}{{! }} `thrift:"{{! }}{{field:name}}{{! }},{{field:key}}{{! }}{{#field:required?}},required{{/field:required?}}{{! }}{{#field:optional?}},optional{{/field:optional?}}{{! }}" {{! }}{{#field:go_tag?}}{{! }}{{field:go_tag}}{{! }}{{/field:go_tag?}}{{! }}{{^field:go_tag?}}{{! }}json:"{{field:name}}{{#field:json_omitempty?}},omitempty{{/field:json_omitempty?}}" {{! }}db:"{{field:name}}"{{! }}{{/field:go_tag?}}` )__FBTHRIFT_TAG__", // go/types/field_default_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template defines a default value for a field in a Thrift struct. Produces user-defined default value for a field (if defined by user), otherwise, produces the "natural default value" (as per Thrift spec). }} {{#field:type}}{{! }}{{#field:value}}{{! }}{{> const/value}}{{! }}{{/field:value}}{{! }}{{^field:value}}{{! }}{{> common/natural_default_value}}{{! }}{{/field:value}}{{! }}{{/field:type}} )__FBTHRIFT_TAG__", // go/types/field_method_default_get.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Get* method for a field in a Thrift struct. }} {{#field:type}} {{#type:struct?}} // Deprecated: Use {{struct:go_qualified_new_func}}().Get{{field:go_name}}() instead. func (x *{{struct:go_name}}) DefaultGet{{field:go_name}}() *{{> common/type}} { if !x.IsSet{{field:go_name}}() { return {{> common/natural_default_value}} } return x.{{field:go_name}} } {{/type:struct?}} {{/field:type}} {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_get.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Get* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) Get{{field:go_name}}{{#program:compat_getters?}}NonCompat{{/program:compat_getters?}}() {{> types/field_type}} { return x.{{field:go_name}} } {{#program:compat_getters?}} func (x *{{struct:go_name}}) Get{{field:go_name}}() {{#field:type}}{{#type:struct?}}*{{/type:struct?}}{{> common/type}}{{/field:type}} { {{#field:nilable?}} if !x.IsSet{{field:go_name}}() { {{#field:type}} {{#type:struct?}} return nil {{/type:struct?}} {{^type:struct?}} return {{> types/field_default_value}} {{/type:struct?}} {{/field:type}} } {{/field:nilable?}} return {{#field:non_struct_pointer?}}*{{/field:non_struct_pointer?}}x.{{field:go_name}} } {{/program:compat_getters?}} {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_is_set.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a IsSet* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) IsSet{{field:go_name}}() bool { return x != nil && x.{{field:go_name}} != nil } {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_read.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a readField* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) readField{{field:key_str}}(p thrift.Format) error { // {{field:go_name}} {{#field:type}} {{> codec/decode}} {{/field:type}} x.{{field:go_setter_name}}{{#program:compat_setters?}}NonCompat{{/program:compat_setters?}}(result) return nil } {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_set.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Set* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) {{field:go_setter_name}}{{#program:compat_setters?}}NonCompat{{/program:compat_setters?}}(value {{#field:type}}{{> common/type}}{{/field:type}}) *{{struct:go_name}} { x.{{field:go_name}} = {{#field:pointer?}}&{{/field:pointer?}}value return x } {{#program:compat_setters?}} func (x *{{struct:go_name}}) {{field:go_setter_name}}(value {{#field:compat_setter_pointer?}}*{{/field:compat_setter_pointer?}}{{#field:type}}{{> common/type}}{{/field:type}}) *{{struct:go_name}} { {{#field:compat_setter_pointer?}} {{^field:pointer?}} if (value == nil) { x.{{field:go_name}} = nil return x } {{/field:pointer?}} {{/field:compat_setter_pointer?}} x.{{field:go_name}} = {{field:compat_setter_value_op}}value return x } {{/program:compat_setters?}} {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_to_string.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a toString* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) toString{{field:key_str}}() string { // {{field:go_name}} {{#field:non_struct_pointer?}} if x.IsSet{{field:go_name}}() { return fmt.Sprintf("%v", *x.Get{{field:go_name}}{{#program:compat_getters?}}NonCompat{{/program:compat_getters?}}()) } {{/field:non_struct_pointer?}} return fmt.Sprintf("%v", x.Get{{field:go_name}}{{#program:compat_getters?}}NonCompat{{/program:compat_getters?}}()) } {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_method_write.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a writeField* method for a field in a Thrift struct. }} func (x *{{struct:go_name}}) writeField{{field:key_str}}(p thrift.Format) error { // {{field:go_name}} {{#field:must_be_set_to_serialize?}} if !x.IsSet{{field:go_name}}() { return nil } {{/field:must_be_set_to_serialize?}} if err := p.WriteFieldBegin("{{field:name}}", {{#field:type}}{{> common/ttype}}{{/field:type}}, {{field:key}}); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error: ", x), err) } item := {{#field:non_struct_pointer?}}*{{/field:non_struct_pointer?}}x.Get{{field:go_name}}{{#program:compat_getters?}}NonCompat{{/program:compat_getters?}}() {{#field:type}} {{> codec/encode}} {{/field:type}} if err := p.WriteFieldEnd(); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error: ", x), err) } return nil } {{! new line }} )__FBTHRIFT_TAG__", // go/types/field_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Defines field types for structs. }} {{#field:type}}{{! }}{{#field:pointer?}}{{! }}*{{! }}{{/field:pointer?}}{{! }}{{> common/type}}{{! }}{{/field:type}} )__FBTHRIFT_TAG__", // go/types/struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template generate a Thrift struct }} {{! type definition }} {{> types/struct_definition}} {{! new function }} {{> types/struct_method_new}} {{! methods }} {{> types/struct_methods}} {{#program:compat?}} {{! builder }} {{#program:gen_builders?}} {{> types/struct_builder}} {{/program:gen_builders?}} {{/program:compat?}} {{#struct:resp?}} {{! exception }} {{> types/struct_method_exception}} {{/struct:resp?}} {{! write (serialize) }} {{> types/struct_method_write}} {{! read (deserialize) }} {{> types/struct_method_read}} {{! string }} {{> types/struct_method_string}} {{#struct:exception?}} {{! error }} {{> types/struct_method_error}} {{/struct:exception?}} )__FBTHRIFT_TAG__", // go/types/struct_builder.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a builder type for thrift structs. }} // Deprecated: Use "New" constructor and setters to build your structs. // e.g {{struct:go_qualified_new_func}}().Set().Set() type {{struct:go_name}}Builder struct { obj *{{struct:go_name}} } // Deprecated: Use "New" constructor and setters to build your structs. // e.g {{struct:go_qualified_new_func}}().Set().Set() func {{struct:go_qualified_new_func}}Builder() *{{struct:go_name}}Builder { return &{{struct:go_name}}Builder{ obj: {{struct:go_qualified_new_func}}(), } } {{#struct:fields_sorted}} // Deprecated: Use "New" constructor and setters to build your structs. // e.g {{struct:go_qualified_new_func}}().Set().Set() func (x *{{struct:go_name}}Builder) {{field:go_name}}(value {{> types/field_type}}) *{{struct:go_name}}Builder { x.obj.{{field:go_name}} = value return x } {{/struct:fields_sorted}} // Deprecated: Use "New" constructor and setters to build your structs. // e.g {{struct:go_qualified_new_func}}().Set().Set() func (x *{{struct:go_name}}Builder) Emit() *{{struct:go_name}} { {{! Create a shallow copy of our 'obj' to let Emit() issue a new object on every call }} var objCopy {{struct:go_name}} = *x.obj return &objCopy } {{!newline}} )__FBTHRIFT_TAG__", // go/types/struct_definition.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates the type defintion for a thrift struct. }} type {{struct:go_name}} struct { {{#struct:fields_sorted}} {{> types/field}} {{/struct:fields_sorted}} } // Compile time interface enforcer var _ thrift.Struct = &{{struct:go_name}}{} {{#struct:resp?}} var _ thrift.WritableResult = &{{struct:go_name}}{} {{! TODO: resp struct is an internal implementation detail. Can we unexport it? }} // Deprecated: {{struct:go_public_resp_name}} is deprecated, since it is supposed to be internal. type {{struct:go_public_resp_name}} = {{struct:go_name}} {{/struct:resp?}}{{! }}{{#struct:req?}} {{! TODO: req struct is an internal implementation detail. Can we unexport it? }} // Deprecated: {{struct:go_public_req_name}} is deprecated, since it is supposed to be internal. type {{struct:go_public_req_name}} = {{struct:go_name}} {{/struct:req?}} )__FBTHRIFT_TAG__", // go/types/struct_method_error.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates an Error method for Thrift structs (exceptions). }} func (x *{{struct:go_name}}) Error() string { return x.String() } )__FBTHRIFT_TAG__", // go/types/struct_method_exception.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates an Exception method for response helper structs. (Implementing thrift.WriteableResult interface.) }} func (x *{{struct:go_name}}) Exception() thrift.WritableException { {{#struct:fields_sorted}} {{^field:retval?}} if x.{{field:go_name}} != nil { return x.{{field:go_name}} } {{/field:retval?}} {{/struct:fields_sorted}} return nil } {{!newline}} )__FBTHRIFT_TAG__", // go/types/struct_method_new.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a New method for Thrift structs. }} func {{struct:go_qualified_new_func}}() *{{struct:go_name}} { return (&{{struct:go_name}}{}){{! }}{{^struct:union?}}{{! }}{{#struct:fields_sorted}}{{! // Fields with given default values. }}{{#field:value}}. {{field:go_setter_name}}{{#program:compat_setters?}}NonCompat{{/program:compat_setters?}}({{! }}{{#field:type}}{{! }}{{^type:base?}} {{#type:struct?}}*{{/type:struct?}}{{> const/value}}, {{/type:base?}}{{! }}{{#type:base?}}{{! }}{{> const/value}}{{! }}{{/type:base?}}{{! }}{{/field:type}}{{! }}){{/field:value}}{{! // Non-optional fields without given default values. }}{{^field:value}}{{! }}{{^field:optional?}}. {{field:go_setter_name}}{{#program:compat_setters?}}NonCompat{{/program:compat_setters?}}({{! }}{{#field:type}}{{! }}{{#type:struct?}}*{{/type:struct?}}{{> common/natural_default_value}}{{! }}{{/field:type}}{{! }}){{/field:optional?}}{{! }}{{/field:value}}{{! }}{{/struct:fields_sorted}}{{! }}{{/struct:union?}} } {{!newline}} )__FBTHRIFT_TAG__", // go/types/struct_method_read.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Read method for Thrift structs. }} func (x *{{struct:go_name}}) Read(p thrift.Format) error { if _, err := p.ReadStructBegin(); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", x), err) } for { _, wireType, id, err := p.ReadFieldBegin() if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", x, id), err) } if wireType == thrift.STOP { break; } switch { {{#struct:fields_sorted}} {{#field:type}} case (id == {{field:key}} && wireType == thrift.Type({{> common/ttype}})): // {{field:name}} if err := x.readField{{field:key_str}}(p); err != nil { return err } {{/field:type}} {{/struct:fields_sorted}} default: if err := p.Skip(wireType); err != nil { return err } } if err := p.ReadFieldEnd(); err != nil { return err } } if err := p.ReadStructEnd(); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", x), err) } return nil } {{!newline}} )__FBTHRIFT_TAG__", // go/types/struct_method_string.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a String method for Thrift structs. }} func (x *{{struct:go_name}}) String() string { {{! NOTE: Go may invoke String() method on a nil pointer, so an explicit nil check is required for safety. }} if x == nil { return "" } var sb strings.Builder sb.WriteString("{{struct:go_name}}({") {{#struct:fields_sorted}} sb.WriteString(fmt.Sprintf("{{field:go_name}}:%s{{^last?}} {{/last?}}", x.toString{{field:key_str}}())) {{/struct:fields_sorted}} sb.WriteString("})") return sb.String() } )__FBTHRIFT_TAG__", // go/types/struct_method_write.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Write method for Thrift structs. }} func (x *{{struct:go_name}}) Write(p thrift.Format) error { {{#struct:union?}} if countSet := x.countSetFields(); countSet > 1 { return fmt.Errorf("%T write union: no more than one field must be set (%d set).", x, countSet) } {{/struct:union?}} if err := p.WriteStructBegin("{{struct:name}}"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", x), err) } {{#struct:fields_sorted}} if err := x.writeField{{field:key_str}}(p); err != nil { return err } {{/struct:fields_sorted}} if err := p.WriteFieldStop(); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", x), err) } if err := p.WriteStructEnd(); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", x), err) } return nil } {{!newline}} )__FBTHRIFT_TAG__", // go/types/struct_methods.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Creates the following methods for Thrift structs: Get*, Set*, IsSet*, writeField*, readField*, String }}{{! Get method. }}{{#struct:fields_sorted}} {{> types/field_method_get}} {{/struct:fields_sorted}}{{! Set method. }}{{#struct:fields_sorted}} {{> types/field_method_set}} {{/struct:fields_sorted}}{{! IsSet method. }}{{#struct:fields_sorted}} {{#field:nilable?}} {{> types/field_method_is_set}} {{/field:nilable?}} {{/struct:fields_sorted}}{{! writeField method. }}{{#struct:fields_sorted}} {{> types/field_method_write}} {{/struct:fields_sorted}}{{! readField method. }}{{#struct:fields_sorted}} {{> types/field_method_read}} {{/struct:fields_sorted}}{{! toString method. }}{{#struct:fields_sorted}} {{> types/field_method_to_string}} {{/struct:fields_sorted}}{{! DefaultGet method. }}{{#struct:fields_sorted}} {{#field:pointer?}} {{> types/field_method_default_get}} {{/field:pointer?}} {{/struct:fields_sorted}}{{! countSetFields method. }}{{#struct:union?}} func (x *{{struct:go_name}}) countSetFields() int { count := int(0) {{#struct:fields_sorted}} if (x.IsSet{{field:go_name}}()) { count++ } {{/struct:fields_sorted}} return count } func (x *{{struct:go_name}}) CountSetFields{{struct:go_name}}() int { return x.countSetFields() } {{/struct:union?}} )__FBTHRIFT_TAG__", // go/types/typedef.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template generates a thrift typedef }} type {{typedef:go_name}} = {{#typedef:type}}{{> common/type}}{{/typedef:type}} {{#typedef:type}} {{#type:enum?}} {{#type:enum}} {{> types/typedef_enum}} {{/type:enum}} {{/type:enum?}} {{/typedef:type}} {{! new function }} {{> types/typedef_method_new}} {{! write (serialize) }} {{> types/typedef_method_write}} {{! read (deserialize) }} {{> types/typedef_method_read}} )__FBTHRIFT_TAG__", // go/types/typedef_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template generates a thrift typedef }} {{^enum:empty?}} const ( {{#enum:values}} {{typedef:go_name}}_{{enum_value:name}} {{typedef:go_name}} = {{> types/typedef_enum_go_qualified_name }}_{{enum_value:name}} {{/enum:values}} ) {{/enum:empty?}} // Enum value maps for {{enum:go_name}} var ( {{typedef:go_name}}ToName = {{> types/typedef_enum_go_qualified_name }}ToName {{typedef:go_name}}ToValue = {{> types/typedef_enum_go_qualified_name }}ToValue ) {{#program:compat?}} // Deprecated: Use {{typedef:go_name}}ToValue instead (e.g. `x, ok := {{typedef:go_name}}ToValue["name"]`). func {{typedef:go_name}}FromString(s string) ({{typedef:go_name}}, error) { return {{> types/typedef_enum_go_qualified_name }}FromString(s) } {{/program:compat?}} )__FBTHRIFT_TAG__", // go/types/typedef_enum_go_qualified_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template calculates the Go qualified name of a typedefed enum. This can be one of two cases: 1. This is a simple typedef to enum, so the name is enum_go_qualified_name 2. This is a typedef to a typedef (to an enum) so the name is: #type_typedef typedef_go_qualified_name /type_typedef This was #2 is using the qual. name of the typedefs' type which is also a typedef. }} {{#typedef:type}}{{! }}{{#type:typedef?}}{{#type:typedef}}{{typedef:go_qualified_name}}{{/type:typedef}}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{enum:go_qualified_name}}{{/type:typedef?}}{{! }}{{/typedef:type}} )__FBTHRIFT_TAG__", // go/types/typedef_method_new.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a New method for Thrift typedefs. }} {{#typedef:type}} func {{typedef:go_qualified_new_func}}() {{#type:struct?}}*{{/type:struct?}}{{typedef:go_name}} { return {{> common/natural_default_value}} } {{/typedef:type}} )__FBTHRIFT_TAG__", // go/types/typedef_method_read.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Read method for Thrift typedefs. NOTE: use of a function (rather that an instance method) is intentional! Typedefs are implemented as Go type aliases (type Foo = Bar) under the hood, meaning that all instance methods are "inherited" by the alias (typedef). Implementing Read in the form of an instance method may result in a "method already declared" compilation error. So instead we must use a uniquely named Read function (with no receiver) which takes the alias (typedef) as an argument. }} func {{typedef:go_qualified_read_func}}(p thrift.Format) ({{typedef:go_name}}, error) { var decodeResult {{typedef:go_name}} decodeErr := func() error { {{#typedef:type}} {{> codec/decode}} {{/typedef:type}} decodeResult = result return nil }() return decodeResult, decodeErr } )__FBTHRIFT_TAG__", // go/types/typedef_method_write.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template creates a Write method for Thrift typedefs. NOTE: use of a function (rather that an instance method) is intentional! Typedefs are implemented as Go type aliases (type Foo = Bar) under the hood, meaning that all instance methods are "inherited" by the alias (typedef). Implementing Write in the form of an instance method may result in a "method already declared" compilation error. So instead we must use a uniquely named Write function (with no receiver) which takes the alias (typedef) as an argument. }} {{#typedef:type}} func {{typedef:go_qualified_write_func}}(item {{#type:struct?}}*{{/type:struct?}}{{typedef:go_name}}, p thrift.Format) error { {{> codec/encode}} return nil } {{/typedef:type}} )__FBTHRIFT_TAG__", // html/index.html.mustache R"__FBTHRIFT_TAG__( Thrift Declarations in {{program:name}}

Thrift Declarations

Structs

{{#program:structs}}

{{struct:name}}

Fields

    {{#struct:fields}}
  • {{field:key}}: {{field:type}} {{field:name}}
  • {{/struct:fields}}

{{/program:structs}}

Services

{{#program:services}}

{{service:name}}

Functions

    {{#service:functions}}
  • {{function:name}}
  • {{/service:functions}}
{{/program:services}} )__FBTHRIFT_TAG__", // java/AdaptedBoxedType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{! }}{{#type:lastAdapter?}}{{! }}{{type:setAdapter}}{{> AdaptedBoxedType}}{{! }}{{/type:lastAdapter?}}{{! }}{{^type:lastAdapter?}}{{! }}{{type:typeClassName}}{{! }}{{/type:lastAdapter?}}{{! }}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{> BoxedType}}{{! }}{{/type:typedef?}}{{! }}{{/type:javaType}})__FBTHRIFT_TAG__", // java/AdaptedType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:hasAdapter?}}{{! }}{{type:typeClassName}}{{! }}{{/type:hasAdapter?}}{{! }}{{^type:hasAdapter?}}{{! }}{{> Type}}{{! }}{{/type:hasAdapter?}}{{! }}{{/type:javaType}} )__FBTHRIFT_TAG__", // java/AsyncReactiveWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.thrift.client.*; import java.util.*; public class {{service:javaCapitalName}}AsyncReactiveWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}AsyncReactiveWrapper{{/service:extends}} implements {{service:javaCapitalName}}.Reactive { private final {{service:javaCapitalName}}.Async _delegate; public {{service:javaCapitalName}}AsyncReactiveWrapper({{service:javaCapitalName}}.Async _delegate) { {{#service:extends}}super(_delegate);{{/service:extends}} this._delegate = _delegate; } @java.lang.Override public void dispose() { _delegate.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return com.facebook.thrift.util.FutureUtil.toMono(() -> _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} {{#service:sinkFunctions}} @java.lang.Override public {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads) { throw new UnsupportedOperationException(); } {{/service:sinkFunctions}} {{#service:interactions}} public class {{service:name}}Impl implements {{service:name}} { private {{service:javaParentCapitalName}}.Async.{{service:name}} _delegateInteraction; {{service:name}}Impl({{service:javaParentCapitalName}}.Async.{{service:name}} delegateInteraction) { this._delegateInteraction = delegateInteraction; } {{#service:singleRequestFunctions}} public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) { return com.facebook.thrift.util.FutureUtil.toMono(() -> _delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}},{{/last?}}{{/function:args}})); } public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { return com.facebook.thrift.util.FutureUtil.toMono(() -> _delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}},{{/function:args}} rpcOptions)); } public reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { return com.facebook.thrift.util.FutureUtil.toMono(() -> _delegateInteraction.{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}} rpcOptions)); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} @java.lang.Override public void dispose() { _delegateInteraction.close(); } } public {{service:name}} create{{service:name}}() { return new {{service:name}}Impl(_delegate.create{{service:name}}()); } {{^last?}} {{/last?}} {{/service:interactions}} } )__FBTHRIFT_TAG__", // java/AutoGenerated.mustache R"__FBTHRIFT_TAG__(/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/BlockingReactiveWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.thrift.client.*; import java.util.*; public class {{service:javaCapitalName}}BlockingReactiveWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}BlockingReactiveWrapper{{/service:extends}} implements {{service:javaCapitalName}}.Reactive { private final {{service:javaCapitalName}} _delegate; public {{service:javaCapitalName}}BlockingReactiveWrapper({{service:javaCapitalName}} _delegate) { {{#service:extends}}super(_delegate);{{/service:extends}} this._delegate = _delegate; } @java.lang.Override public void dispose() { _delegate.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { {{#function:voidType}} reactor.core.publisher.Mono _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); _sink.success(); } catch (Throwable _e) { throw reactor.core.Exceptions.propagate(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} {{^function:voidType}} reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _sink.success(_delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } catch (Throwable _e) { _sink.error(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} {{#service:sinkFunctions}} @java.lang.Override public {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads) { throw new UnsupportedOperationException(); } {{/service:sinkFunctions}} {{#service:interactions}} public class {{service:name}}Impl implements {{service:name}} { private {{service:javaParentCapitalName}}.{{service:name}} _delegateInteraction; {{service:name}}Impl({{service:javaParentCapitalName}}.{{service:name}} delegateInteraction) { this._delegateInteraction = delegateInteraction; } {{#service:singleRequestFunctions}} @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { {{#function:voidType}} reactor.core.publisher.Mono _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); _sink.success(); } catch (Throwable _e) { throw reactor.core.Exceptions.propagate(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} {{^function:voidType}} reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _sink.success(_delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } catch (Throwable _e) { _sink.error(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} } @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } @java.lang.Override public reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} @java.lang.Override public void dispose() {} } public {{service:name}} create{{service:name}}() { return new {{service:name}}Impl(_delegate.create{{service:name}}()); } {{^last?}} {{/last?}} {{/service:interactions}} } )__FBTHRIFT_TAG__", // java/BoxedType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:hasAdapter?}}{{! }}{{type:typeClassName}}{{! }}{{/type:hasAdapter?}}{{! }}{{^type:hasAdapter?}}{{! }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{> BoxedType}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:void?}}Void{{/type:void?}}{{! }}{{#type:bool?}}Boolean{{/type:bool?}}{{! }}{{#type:byte?}}Byte{{/type:byte?}}{{! }}{{#type:i16?}}Short{{/type:i16?}}{{! }}{{#type:i32?}}Integer{{/type:i32?}}{{! }}{{#type:i64?}}Long{{/type:i64?}}{{! }}{{#type:double?}}Double{{/type:double?}}{{! }}{{#type:float?}}Float{{/type:float?}}{{! }}{{#type:string?}}{{! }}{{#type:isBinaryString?}}{{#type:isAdapterSet?}}io.netty.buffer.ByteBuf{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}{{#field:hasAdapter?}}io.netty.buffer.ByteBuf{{/field:hasAdapter?}}{{^field:hasAdapter?}}byte[]{{/field:hasAdapter?}}{{/type:isAdapterSet?}}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}String{{/type:isBinaryString?}}{{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{#type:isAdapterSet?}}io.netty.buffer.ByteBuf{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}{{#field:hasAdapter?}}io.netty.buffer.ByteBuf{{/field:hasAdapter?}}{{^field:hasAdapter?}}byte[]{{/field:hasAdapter?}}{{/type:isAdapterSet?}}{{/type:binary?}}{{! }}{{#type:map?}}{{! }}Map<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}>{{! }}{{/type:map?}}{{! }}{{#type:list?}}{{! }}List<{{#type:list_elem_type}}{{> BoxedType}}{{/type:list_elem_type}}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}Set<{{#type:set_elem_type}}{{> BoxedType}}{{/type:set_elem_type}}>{{! }}{{/type:set?}}{{! }}{{#type:struct?}}{{! }}{{#type:struct}}{{struct:javaPackage}}.{{struct:javaCapitalName}}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#type:enum}}{{enum:javaPackage}}.{{enum:javaCapitalName}}{{/type:enum}}{{! }}{{/type:enum?}}{{! }}{{/type:typedef?}}{{! }}{{/type:hasAdapter?}}{{! }}{{/type:javaType}} )__FBTHRIFT_TAG__", // java/ConstantStruct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{! NOTE: It is impossible to have constants if structs are created in mutable bean style. If customer specify a constant of mutable struct type. Build will fail. }} new {{> BoxedType}}.Builder(){{! }}{{#value:const_struct}}{{! }}{{#constant:type}}{{! }}{{#constant:value}}.set{{constant:javaFieldName}}({{> DefaultValue}}){{! }}{{/constant:value}}{{! }}{{/constant:type}}{{! }}{{/value:const_struct}}.build() )__FBTHRIFT_TAG__", // java/ConstantUnion.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#value:const_struct}}{{! }}{{> BoxedType}}{{#constant:type}}{{! }}.from{{constant:javaFieldName}}({{#constant:value}}{{> DefaultValue}}{{/constant:value}}){{! }}{{/constant:type}}{{! }}{{/value:const_struct}}{{! }}{{^value:const_struct}}{{! }}new {{> BoxedType}}(){{! }}{{/value:const_struct}} )__FBTHRIFT_TAG__", // java/Constants.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{program:javaPackage}}; import com.facebook.swift.codec.*; import com.google.common.collect.*; import java.util.*; @SwiftGenerated public final class {{program:constantClassName}} { private {{program:constantClassName}}() {} {{#program:constants}} {{^constant:javaIgnoreConstant?}}{{! }}{{#constant:type}}{{! }}{{#type:base?}} public static final {{> Type}} {{constant:javaCapitalName}} = {{#constant:value}}{{> DefaultValue}}{{/constant:value}}; {{/type:base?}}{{! }}{{^type:base?}} public static final {{> Type}} {{constant:javaCapitalName}} = construct_{{constant:javaCapitalName}}(); private static {{#constant:type}}{{> Type}}{{/constant:type}} construct_{{constant:javaCapitalName}}() { return {{#constant:value}}{{> DefaultValue}}{{/constant:value}}; } {{/type:base?}}{{! }}{{/constant:type}}{{! }}{{/constant:javaIgnoreConstant?}} {{/program:constants}} } )__FBTHRIFT_TAG__", // java/Default.mustache R"__FBTHRIFT_TAG__(private static class _{{struct:javaCapitalName}}Lazy { private static final {{struct:javaCapitalName}} _DEFAULT = new {{struct:javaCapitalName}}.Builder().build(); } public static {{struct:javaCapitalName}} defaultInstance() { return _{{struct:javaCapitalName}}Lazy._DEFAULT; } )__FBTHRIFT_TAG__", // java/DefaultValue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Note: This template works by simultaneously traversing the `type` and `value` maps so that the type of the constant is known. Before including this template, open constant:type and constant:value. On recursive calls, make sure to open the next subtree's :type and :value elements as well. See the section titled 'Map Constants' for an example. }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{> DefaultValue}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! Integer constants }}{{#type:byte?}}(byte){{value:integer_value}}{{/type:byte?}}{{! }}{{#type:i16?}}(short){{value:integer_value}}{{/type:i16?}}{{! }}{{#type:i32?}}{{value:integer_value}}{{/type:i32?}}{{! }}{{#type:i64?}}{{value:integer_value}}L{{/type:i64?}}{{! Boolean constants }}{{#type:bool?}}{{! }}{{#value:nonzero?}}true{{/value:nonzero?}}{{! }}{{^value:nonzero?}}false{{/value:nonzero?}}{{! }}{{/type:bool?}}{{! Floating point constants }}{{#type:double?}}{{! }}{{#value:double?}}(double){{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:double?}}{{! }}{{#type:float?}}{{! }}{{#value:double?}}(float){{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}(float){{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:float?}}{{! String constants }}{{#type:string?}}{{value:quotedString}}{{/type:string?}}{{! }}{{#type:binary?}}{{#field:hasAdapter?}}io.netty.buffer.Unpooled.wrappedBuffer({{value:quotedString}}.getBytes()){{/field:hasAdapter?}}{{^field:hasAdapter?}}{{value:quotedString}}.getBytes(){{/field:hasAdapter?}}{{/type:binary?}}{{! Map constants }}{{#type:map?}}{{! }}{{#struct:asBean?}}com.google.common.collect.Maps.newHashMap({{/struct:asBean?}}ImmutableMap.<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}>builder() {{#value:map_elements}} .put({{#element:key}}{{#type:key_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}{{> DefaultValue}}{{#type:hasAdapter?}}){{/type:hasAdapter?}}{{/type:key_type}}{{/element:key}}, {{! }}{{#element:value}}{{#type:value_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}{{> DefaultValue}}{{#type:hasAdapter?}}){{/type:hasAdapter?}}{{/type:value_type}}{{/element:value}}) {{/value:map_elements}} .build(){{#struct:asBean?}}){{/struct:asBean?}}{{! }}{{/type:map?}}{{! List constants }}{{#type:list?}}{{! }}{{#struct:asBean?}}com.google.common.collect.Lists.newArrayList({{/struct:asBean?}}ImmutableList.<{{#type:list_elem_type}}{{> BoxedType}}{{/type:list_elem_type}}>builder() {{#value:list_elements}} .add({{#type:list_elem_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}{{> DefaultValue}}{{#type:hasAdapter?}}){{/type:hasAdapter?}}{{/type:list_elem_type}}) {{/value:list_elements}} .build(){{#struct:asBean?}}){{/struct:asBean?}}{{! }}{{/type:list?}}{{! Set constants }}{{#type:set?}}{{! }}{{#struct:asBean?}}com.google.common.collect.Sets.newHashSet({{/struct:asBean?}}ImmutableSet.<{{#type:set_elem_type}}{{> BoxedType}}{{/type:set_elem_type}}>builder() {{#value:list_elements}} .add({{#type:set_elem_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}{{> DefaultValue}}{{#type:hasAdapter?}}){{/type:hasAdapter?}}{{/type:set_elem_type}}) {{/value:list_elements}} .build(){{#struct:asBean?}}){{/struct:asBean?}}{{! }}{{/type:set?}}{{! Enum Constants }}{{#type:enum?}}{{> BoxedType}}.{{value:javaEnumValueName}}{{/type:enum?}}{{! Struct Constants }}{{#type:struct?}}{{! }}{{#type:struct}}{{! }}{{#value:referenceable?}}{{! }}{{#value:owning_const}}{{! }}{{#constant:program}}{{! }}{{program:javaPackage}}.Constants.{{constant:javaCapitalName}}{{! }}{{/constant:program}}{{! }}{{/value:owning_const}}{{! }}{{/value:referenceable?}}{{! }}{{^value:referenceable?}}{{! }}{{#struct:plain?}}{{> ConstantStruct}}{{/struct:plain?}}{{! }}{{#struct:union?}}{{> ConstantUnion}}{{/struct:union?}}{{! }}{{/value:referenceable?}}{{! }}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // java/DefaultValueContainer.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Note: This template works by simultaneously traversing the `type` and `value` maps so that the type of the constant is known. Before including this template, open constant:type and constant:value. On recursive calls, make sure to open the next subtree's :type and :value elements as well. See the section titled 'Map Constants' for an example. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> DefaultValueContainer}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> DefaultValueContainer}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> DefaultValueContainer}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:map?}}{{! }}{{^type:javaType}}{{> BoxedType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}}new Hash{{> BoxedType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{#type:javaType}}{{type:javaType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}} new {{type:javaType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{! }}{{#value:map_elements}} { {{field:setIsNested}}{{! }}{{#element:key}}{{#type:key_type}}{{! }}{{#type:isContainer?}}{{> Type}} _key{{field:nestedDepth}};{{type:setIsMapKey}} {{field:nestedDepth++}}{{> DefaultValueContainer}}{{field:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> Type}} _key{{field:nestedDepth}} = {{> DefaultValue}};{{! }}{{/type:isContainer?}}{{/type:key_type}}{{! }}{{/element:key}}{{! }}{{#element:value}}{{#type:value_type}}{{! }}{{#type:isContainer?}}{{type:setIsMapValue}} {{> Type}} _val{{field:nestedDepth}}; {{field:nestedDepth++}}{{> DefaultValueContainer}}{{field:nestedDepth--}}{{! }}{{/type:isContainer?}}{{! }}{{^type:isContainer?}} {{> Type}} _val{{field:nestedDepth}} = {{> DefaultValue}};{{! }}{{/type:isContainer?}}{{/type:value_type}}{{/element:value}}{{! }} _objRef{{field:nestedDepth}}.put(_key{{field:nestedDepth}}, _val{{field:nestedDepth}}); }{{! }}{{/value:map_elements}}{{! }}{{! }}{{^field:isFirstDepth?}} {{#type:isMapKey?}}_key{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}_val{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}_objRef{{field:prevNestedDepth}}.add(_objRef{{field:nestedDepth}}); {{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/field:isFirstDepth?}}{{! }}{{/type:map?}}{{! List constants }}{{#type:list?}}{{! }}{{^type:javaType}}{{> BoxedType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}}new Array{{> BoxedType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{#type:javaType}}{{type:javaType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}} new {{type:javaType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{! }}{{#value:list_elements}} { {{field:setIsNested}}{{! }}{{#type:list_elem_type}}{{! }}{{#type:isContainer?}}{{field:nestedDepth++}}{{> DefaultValueContainer}}{{field:nestedDepth--}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}_objRef{{field:nestedDepth}}.add({{> DefaultValue}});{{/type:isContainer?}}{{! }}{{/type:list_elem_type}} }{{/value:list_elements}}{{! }}{{! }}{{^field:isFirstDepth?}} {{#type:isMapKey?}}_key{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}_val{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}_objRef{{field:prevNestedDepth}}.add(_objRef{{field:nestedDepth}}); {{/type:isMapValue?}}{{/type:isMapKey?}} {{/field:isFirstDepth?}}{{! }}{{/type:list?}}{{! Set constants }}{{#type:set?}}{{! }}{{^type:javaType}}{{> BoxedType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}}new Hash{{> BoxedType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{#type:javaType}}{{type:javaType}} _objRef{{field:nestedDepth}} = {{#field:isFirstDepth?}}this.{{field:javaName}};{{/field:isFirstDepth?}}{{! }}{{^field:isFirstDepth?}} new {{type:javaType}}();{{/field:isFirstDepth?}}{{/type:javaType}}{{! }}{{! }}{{#value:list_elements}} { {{field:setIsNested}}{{! }}{{#type:set_elem_type}}{{! }}{{#type:isContainer?}}{{field:nestedDepth++}}{{> DefaultValueContainer}}{{field:nestedDepth--}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}_objRef{{field:nestedDepth}}.add({{> DefaultValue}});{{/type:isContainer?}}{{! }}{{/type:set_elem_type}} }{{/value:list_elements}}{{! }}{{! }}{{^field:isFirstDepth?}} {{#type:isMapKey?}}_key{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}_val{{field:prevNestedDepth}} = _objRef{{field:nestedDepth}};{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}_objRef{{field:prevNestedDepth}}.add(_objRef{{field:nestedDepth}}); {{/type:isMapValue?}}{{/type:isMapKey?}} {{/field:isFirstDepth?}}{{! }}{{/type:set?}}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // java/Enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#enum:enums_compat?}}{{! }}{{#enum:enum_type_open?}}{{> enum/OpenEnum}}{{/enum:enum_type_open?}}{{! }}{{^enum:enum_type_open?}}{{> enum/ClosedEnum}}{{/enum:enum_type_open?}}{{! }}{{/enum:enums_compat?}}{{! }}{{^enum:enums_compat?}}{{! }}{{> enum/ClosedEnum}}{{! }}{{/enum:enums_compat?}})__FBTHRIFT_TAG__", // java/Exception.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{struct:javaPackage}}; import com.facebook.swift.codec.*; import com.facebook.swift.codec.ThriftField.Requiredness; import com.facebook.swift.codec.ThriftField.Recursiveness; import java.util.*; import javax.annotation.Nullable; import org.apache.thrift.*; import org.apache.thrift.transport.*; import org.apache.thrift.protocol.*; import com.google.common.collect.*; @SwiftGenerated @com.facebook.swift.codec.ThriftStruct("{{struct:name}}"){{> common/ObjectCustomAnnotation}} public final class {{struct:javaCapitalName}} extends org.apache.thrift.TBaseException implements com.facebook.thrift.payload.ThriftSerializable { private static final long serialVersionUID = 1L; {{> struct/AdapterDefinition}} public static final Map NAMES_TO_IDS = new HashMap(); public static final Map THRIFT_NAMES_TO_IDS = new HashMap(); public static final Map FIELD_METADATA = new HashMap<>(); private static final TStruct STRUCT_DESC = new TStruct("{{struct:name}}"); {{#struct:fields}} private {{^struct:hasWrapper?}}final {{/struct:hasWrapper?}}{{> FieldType}} {{field:javaName}}; public static final int _{{field:javaAllCapsName}} = {{field:key}}; private static final TField {{field:javaTFieldName}} = new TField("{{#field:FieldNameUnmangled?}}{{field:name}}{{/field:FieldNameUnmangled?}}{{^field:FieldNameUnmangled?}}{{field:javaName}}{{/field:FieldNameUnmangled?}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/struct:fields}} static { {{#struct:fields}} NAMES_TO_IDS.put("{{field:javaName}}", {{field:key}}); THRIFT_NAMES_TO_IDS.put("{{field:name}}", {{field:key}}); FIELD_METADATA.put({{field:key}}, {{field:javaTFieldName}}); {{/struct:fields}} {{#struct:thrift_uri}} com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( new com.facebook.thrift.type.UniversalName("{{struct:thrift_uri}}"), {{struct:javaCapitalName}}.class, {{struct:javaCapitalName}}::read0)); {{/struct:thrift_uri}} } {{> struct/ThriftConstructor}} {{> struct/StructBuilder}} {{#struct:fields}} {{> struct/FieldGetter}} {{/struct:fields}} {{#struct:needsExceptionMessage?}} {{> ExceptionMessage}} {{/struct:needsExceptionMessage?}} {{> struct/StructRead}} {{> struct/StructWrite}} {{> Default}} } )__FBTHRIFT_TAG__", // java/ExceptionMessage.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @java.lang.Override public String getMessage() { return {{struct:exceptionMessage}}; } )__FBTHRIFT_TAG__", // java/FieldType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasWrapper?}}{{field:wrapperType}}{{/field:hasWrapper?}}{{! }}{{^field:hasWrapper?}}{{! }}{{#field:hasAdapter?}}{{! }}{{#field:hasFieldAdapter?}}{{field:fieldAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{^field:hasFieldAdapter?}}{{field:typeAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:optional?}}{{#field:type}}{{> BoxedType}}{{/field:type}}{{/field:optional?}}{{! }}{{^field:optional?}}{{#field:type}}{{> Type}}{{/field:type}}{{/field:optional?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:hasWrapper?}})__FBTHRIFT_TAG__", // java/FieldTypeNoWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasAdapter?}}{{! }}{{#field:hasFieldAdapter?}}{{field:fieldAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{^field:hasFieldAdapter?}}{{field:typeAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:optional?}}{{#field:type}}{{> BoxedType}}{{/field:type}}{{/field:optional?}}{{! }}{{^field:optional?}}{{#field:type}}{{> Type}}{{/field:type}}{{/field:optional?}}{{! }}{{/field:hasAdapter?}} )__FBTHRIFT_TAG__", // java/FromThriftEnd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasFieldAdapter?}}{{! }}){{! }}{{/field:hasFieldAdapter?}}{{! }}{{#field:hasTypeAdapter?}}{{! }}){{! }}{{/field:hasTypeAdapter?}})__FBTHRIFT_TAG__", // java/FromThriftStart.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasFieldAdapter?}}{{! }}_{{field:javaName}}_Adapter.fromThrift({{! }}{{/field:hasFieldAdapter?}}{{! }}{{#field:hasTypeAdapter?}}{{! }}__{{#field:type}}{{type:name}}{{/field:type}}_Adapter.fromThrift({{! }}{{/field:hasTypeAdapter?}})__FBTHRIFT_TAG__", // java/GetterName.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type}}{{#type:bool?}}is{{/type:bool?}}{{^type:bool?}}get{{/type:bool?}}{{/field:type}}{{field:javaCapitalName}} )__FBTHRIFT_TAG__", // java/KeyValue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{^type:isAdapterSet?}}{{! }}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}{{! }}{{/type:isAdapterSet?}})__FBTHRIFT_TAG__", // java/Object.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:union?}}{{> Union}}{{/struct:union?}}{{! }}{{#struct:exception?}}{{> Exception}}{{/struct:exception?}}{{! }}{{#struct:plain?}}{{> Struct}}{{/struct:plain?}} )__FBTHRIFT_TAG__", // java/ReactiveAsyncWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; {{#service:disableReactive?}}// Generation of this class is disabled using (java.swift.disable_reactive){{/service:disableReactive?}}{{^service:disableReactive?}} import java.util.*; public class {{service:javaCapitalName}}ReactiveAsyncWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}ReactiveAsyncWrapper{{/service:extends}} implements {{service:javaCapitalName}}.Async { private {{service:javaCapitalName}}.Reactive _delegate; public {{service:javaCapitalName}}ReactiveAsyncWrapper({{service:javaCapitalName}}.Reactive _delegate) { {{#service:extends}}super(_delegate);{{/service:extends}} this._delegate = _delegate; } public {{service:javaCapitalName}}ReactiveAsyncWrapper(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, Map _headers, Map _persistentHeaders) { this(new {{service:javaCapitalName}}ReactiveClient(_protocolId, _rpcClient, _headers, _persistentHeaders)); } @java.lang.Override public void close() { _delegate.dispose(); } {{#service:singleRequestFunctions}} @java.lang.Override public com.google.common.util.concurrent.ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return com.facebook.thrift.util.FutureUtil.toListenableFuture(_delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } @java.lang.Override public com.google.common.util.concurrent.ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions) { return com.facebook.thrift.util.FutureUtil.toListenableFuture(_delegate.{{function:javaName}}({{#function:args}}{{field:javaName}},{{/function:args}} rpcOptions)); } @java.lang.Override public com.google.common.util.concurrent.ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions) { return com.facebook.thrift.util.FutureUtil.toListenableFuture(_delegate.{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}} rpcOptions)); } {{/service:singleRequestFunctions}} {{#service:interactions}} public class {{service:name}}Impl implements {{service:name}} { {{#service:singleRequestFunctions}} @java.lang.Override public com.google.common.util.concurrent.ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException("Interactions are not yet supported on ReactiveAsyncWrapper Interfaces!"); } @java.lang.Override public com.google.common.util.concurrent.ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions) { throw new UnsupportedOperationException("Interactions are not yet supported on ReactiveAsyncWrapper Interfaces!"); } @java.lang.Override public com.google.common.util.concurrent.ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions) { throw new UnsupportedOperationException("Interactions are not yet supported on ReactiveAsyncWrapper Interfaces!"); } {{/service:singleRequestFunctions}} @java.lang.Override public void close() {} } public {{service:name}} create{{service:name}}() { return new {{service:name}}Impl(); } {{^last?}} {{/last?}} {{/service:interactions}} } {{/service:disableReactive?}} )__FBTHRIFT_TAG__", // java/ReactiveBlockingWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; {{#service:disableReactive?}}// Generation of this class is disabled using (java.swift.disable_reactive){{/service:disableReactive?}}{{^service:disableReactive?}} import java.util.*; public class {{service:javaCapitalName}}ReactiveBlockingWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}ReactiveBlockingWrapper{{/service:extends}} implements {{service:javaCapitalName}} { private final {{service:javaCapitalName}}.Reactive _delegate; public {{service:javaCapitalName}}ReactiveBlockingWrapper({{service:javaCapitalName}}.Reactive _delegate) { {{#service:extends}}super(_delegate);{{/service:extends}} this._delegate = _delegate; } public {{service:javaCapitalName}}ReactiveBlockingWrapper(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, Map _headers, Map _persistentHeaders) { this(new {{service:javaCapitalName}}ReactiveClient(_protocolId, _rpcClient, _headers, _persistentHeaders)); } @java.lang.Override public void close() { _delegate.dispose(); } {{#service:singleRequestFunctions}} @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:voidType}} {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}com.facebook.thrift.client.RpcOptions.EMPTY); {{/function:voidType}} {{^function:voidType}} return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}com.facebook.thrift.client.RpcOptions.EMPTY).getData(); {{/function:voidType}} } @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:voidType}} {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}}rpcOptions); {{/function:voidType}} {{^function:voidType}} return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}}rpcOptions).getData(); {{/function:voidType}} } @java.lang.Override public com.facebook.thrift.client.ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} com.facebook.thrift.client.RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { try { return _delegate.{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions).block(); } catch (Throwable t) { {{#function:exceptions}} if (t instanceof {{#field:type}}{{> BoxedType}}{{/field:type}}) { throw ({{#field:type}}{{> BoxedType}}{{/field:type}})t; } {{/function:exceptions}} throw com.facebook.thrift.util.ExceptionUtil.wrap(t); } } {{/service:singleRequestFunctions}} {{#service:interactions}} public {{service:name}} create{{service:name}}() { throw new UnsupportedOperationException("Interactions are not yet supported on ReactiveBlockingWrapper Interfaces!"); } {{^last?}} {{/last?}} {{/service:interactions}} } {{/service:disableReactive?}})__FBTHRIFT_TAG__", // java/ReactiveClient.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import static com.facebook.swift.service.SwiftConstants.STICKY_HASH_KEY; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; import org.apache.thrift.protocol.*; import org.apache.thrift.ClientPushMetadata; import org.apache.thrift.InteractionCreate; import org.apache.thrift.InteractionTerminate; import com.facebook.thrift.client.ResponseWrapper; import com.facebook.thrift.client.RpcOptions; import com.facebook.thrift.util.Readers; public class {{service:javaCapitalName}}ReactiveClient {{#service:extends}}extends {{service:javaPackage}}.{{service:javaCapitalName}}ReactiveClient{{/service:extends}} implements {{service:javaCapitalName}}.Reactive { private static final AtomicLong _interactionCounter = new AtomicLong(0); {{^service:extends}} protected final org.apache.thrift.ProtocolId _protocolId; protected final reactor.core.publisher.Mono _rpcClient; protected final reactor.core.publisher.Mono> _headersMono; protected final reactor.core.publisher.Mono> _persistentHeadersMono; protected final Set _activeInteractions; {{/service:extends}} {{#service:singleRequestFunctions}} {{#function:args}} private static final TField _{{function:javaName}}_{{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/function:args}} private static final java.util.Map _{{function:javaName}}_EXCEPTION_READERS = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} {{#function:exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} {{#function:args}} private static final TField _{{function:javaName}}_{{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/function:args}} private static final java.util.Map _{{function:javaName}}_EXCEPTION_READERS = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} private static final java.util.Map _{{function:javaName}}_STREAM_EXCEPTION_READERS = {{#function:stream_exceptions?}}new HashMap<>();{{/function:stream_exceptions?}}{{^function:stream_exceptions?}}java.util.Collections.emptyMap();{{/function:stream_exceptions?}} {{#function:exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{#function:stream_exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_STREAM_EXCEPTION_READER{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:stream_exceptions}} {{/service:streamingFunctions}} {{#service:sinkFunctions}} {{#function:args}} private static final TField _{{function:javaName}}_{{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/function:args}} {{#function:return_type}}{{#function:sink_elem_type}} private static final TField _{{function:javaName}}_SINK_TFIELD = new TField("payload", TType.{{> TType}}, (short)0); {{/function:sink_elem_type}}{{/function:return_type}} private static final java.util.Map _{{function:javaName}}_EXCEPTION_READERS = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} private static final java.util.Map _{{function:javaName}}_STREAM_EXCEPTION_READERS = {{#function:sink_final_response_exceptions?}}new HashMap<>();{{/function:sink_final_response_exceptions?}}{{^function:sink_final_response_exceptions?}}java.util.Collections.emptyMap();{{/function:sink_final_response_exceptions?}} {{#function:exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{#function:sink_final_response_exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_STREAM_EXCEPTION_READER{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:sink_final_response_exceptions}} {{/service:sinkFunctions}} {{#service:interactions}} {{#service:singleRequestFunctions}} {{#function:args}} private static final TField _{{function:javaName}}_{{field:javaTFieldName}}_INT = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/function:args}} private static final java.util.Map _{{function:javaName}}_EXCEPTION_READERS_INT = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} {{#function:exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER_INT{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} {{#function:args}} private static final TField _{{function:javaName}}_{{field:javaTFieldName}}_INT = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/function:args}} private static final java.util.Map _{{function:javaName}}_EXCEPTION_READERS_INT = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} private static final java.util.Map _{{function:javaName}}_STREAM_EXCEPTION_READERS_INT = {{#function:stream_exceptions?}}new HashMap<>();{{/function:stream_exceptions?}}{{^function:stream_exceptions?}}java.util.Collections.emptyMap();{{/function:stream_exceptions?}} {{#function:exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER_INT{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{#function:stream_exceptions}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_STREAM_EXCEPTION_READER_INT{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:stream_exceptions}} {{/service:streamingFunctions}} {{/service:interactions}} static { {{#service:singleRequestFunctions}}{{#function:exceptions}} _{{function:javaName}}_EXCEPTION_READERS.put((short){{field:key}}, _{{function:javaName}}_EXCEPTION_READER{{field:index}}); {{/function:exceptions}}{{/service:singleRequestFunctions}} {{#service:streamingFunctions}}{{#function:exceptions}} _{{function:javaName}}_EXCEPTION_READERS.put((short){{field:key}}, _{{function:javaName}}_EXCEPTION_READER{{field:index}}); {{/function:exceptions}}{{#function:stream_exceptions}} _{{function:javaName}}_STREAM_EXCEPTION_READERS.put((short){{field:key}}, _{{function:javaName}}_STREAM_EXCEPTION_READER{{field:index}}); {{/function:stream_exceptions}}{{/service:streamingFunctions}} {{#service:sinkFunctions}}{{#function:exceptions}} _{{function:javaName}}_EXCEPTION_READERS.put((short){{field:key}}, _{{function:javaName}}_EXCEPTION_READER{{field:index}}); {{/function:exceptions}}{{#function:sink_final_response_exceptions}} _{{function:javaName}}_STREAM_EXCEPTION_READERS.put((short){{field:key}}, _{{function:javaName}}_STREAM_EXCEPTION_READER{{field:index}}); {{/function:sink_final_response_exceptions}}{{/service:sinkFunctions}} } public {{service:javaCapitalName}}ReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient) { {{#service:extends}}super(_protocolId, _rpcClient);{{/service:extends}} {{^service:extends}} this._protocolId = _protocolId; this._rpcClient = _rpcClient; this._headersMono = reactor.core.publisher.Mono.empty(); this._persistentHeadersMono = reactor.core.publisher.Mono.empty(); this._activeInteractions = ConcurrentHashMap.newKeySet(); {{/service:extends}} } public {{service:javaCapitalName}}ReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, Map _headers, Map _persistentHeaders) { this(_protocolId, _rpcClient, reactor.core.publisher.Mono.just(_headers != null ? _headers : java.util.Collections.emptyMap()), reactor.core.publisher.Mono.just(_persistentHeaders != null ? _persistentHeaders : java.util.Collections.emptyMap()), new AtomicLong(), ConcurrentHashMap.newKeySet()); } public {{service:javaCapitalName}}ReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, reactor.core.publisher.Mono> _headersMono, reactor.core.publisher.Mono> _persistentHeadersMono) { this(_protocolId, _rpcClient, _headersMono, _persistentHeadersMono, new AtomicLong(), ConcurrentHashMap.newKeySet()); } public {{service:javaCapitalName}}ReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, Map _headers, Map _persistentHeaders, AtomicLong interactionCounter, Set activeInteractions) { this(_protocolId,_rpcClient, reactor.core.publisher.Mono.just(_headers != null ? _headers : java.util.Collections.emptyMap()), reactor.core.publisher.Mono.just(_persistentHeaders != null ? _persistentHeaders : java.util.Collections.emptyMap()), interactionCounter, activeInteractions); } public {{service:javaCapitalName}}ReactiveClient(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono _rpcClient, reactor.core.publisher.Mono> _headersMono, reactor.core.publisher.Mono> _persistentHeadersMono, AtomicLong interactionCounter, Set activeInteractions) { {{#service:extends}}super(_protocolId, _rpcClient, _headersMono, _persistentHeadersMono, interactionCounter, activeInteractions);{{/service:extends}} {{^service:extends}} this._protocolId = _protocolId; this._rpcClient = _rpcClient; this._headersMono = _headersMono; this._persistentHeadersMono = _persistentHeadersMono; this._activeInteractions = activeInteractions; {{/service:extends}} } @java.lang.Override public void dispose() {} {{#service:singleRequestFunctions}} private com.facebook.thrift.payload.Writer _create{{function:javaName}}Writer({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return oprot -> { try { {{#function:args}} {{#field:type}} { oprot.writeFieldBegin(_{{function:javaName}}_{{field:javaTFieldName}}); {{> FieldType}} _iter0 = {{field:javaName}}; {{#field:type}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:type}} {{/function:args}} } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{> TypeReader }}{{/function:return_type}}{{/function:void?}}; @java.lang.Override public reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return _rpcClient .flatMap(_rpc -> getHeaders(rpcOptions).flatMap(headers -> { org.apache.thrift.RequestRpcMetadata _metadata = new org.apache.thrift.RequestRpcMetadata.Builder() .setName("{{function:name}}") .setKind(org.apache.thrift.RpcKind.{{#function:oneway?}}SINGLE_REQUEST_NO_RESPONSE{{/function:oneway?}}{{^function:oneway?}}SINGLE_REQUEST_SINGLE_RESPONSE{{/function:oneway?}}) .setOtherMetadata(headers) .setProtocol(_protocolId) .build(); com.facebook.thrift.payload.ClientRequestPayload<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _crp = com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}Writer({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}), _{{function:javaName}}_READER, _{{function:javaName}}_EXCEPTION_READERS, _metadata, java.util.Collections.emptyMap()); return _rpc {{#function:oneway?}}.singleRequestNoResponse(_crp, rpcOptions).thenReturn(ResponseWrapper.create(null, java.util.Collections.emptyMap(), java.util.Collections.emptyMap())){{/function:oneway?}}{{! }}{{^function:oneway?}}.singleRequestSingleResponse(_crp, rpcOptions).transform(com.facebook.thrift.util.MonoPublishingTransformer.getInstance()).doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}){{/function:oneway?}}; })); } @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} rpcOptions){{#function:oneway?}}.then(){{/function:oneway?}}{{! }}{{^function:oneway?}}{{^function:voidType}}.map(_p -> _p.getData()){{/function:voidType}}{{/function:oneway?}}{{! }}{{^function:oneway?}}{{#function:voidType}}.then(){{/function:voidType}}{{/function:oneway?}}; } @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Ty)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(pe}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}} com.facebook.thrift.client.RpcOptions.EMPTY); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} private com.facebook.thrift.payload.Writer _create{{function:javaName}}Writer({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return oprot -> { try { {{#function:args}} {{#field:type}} { oprot.writeFieldBegin(_{{function:javaName}}_{{field:javaTFieldName}}); {{> FieldType}} _iter0 = {{field:javaName}}; {{#field:type}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:type}} {{/function:args}} } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:stream_elem_type}}{{> TypeReader }}{{/function:stream_elem_type}}{{/function:return_type}}{{/function:void?}}; {{#function:return_type}}{{#function:stream_has_first_response?}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_FIRST_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:stream_first_response_type}}{{> TypeReader }}{{/function:stream_first_response_type}}{{/function:return_type}}{{/function:void?}}; {{/function:stream_has_first_response?}}{{/function:return_type}} @java.lang.Override public reactor.core.publisher.Flux StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return _rpcClient .flatMapMany(_rpc -> getHeaders(rpcOptions).flatMapMany(headers -> { org.apache.thrift.RequestRpcMetadata _metadata = new org.apache.thrift.RequestRpcMetadata.Builder() .setName("{{function:name}}") .setKind(org.apache.thrift.RpcKind.SINGLE_REQUEST_STREAMING_RESPONSE) .setOtherMetadata(headers) .setProtocol(_protocolId) .build(); com.facebook.thrift.payload.ClientRequestPayload<{{#function:return_type}}{{#function:stream_elem_type}}{{> BoxedType}}{{/function:stream_elem_type}}{{/function:return_type}}> _crp = com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}Writer({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}), _{{function:javaName}}_READER,{{#function:return_type}}{{#function:stream_has_first_response?}} _{{function:javaName}}_FIRST_READER,{{/function:stream_has_first_response?}}{{/function:return_type}} _{{function:javaName}}_EXCEPTION_READERS, _{{function:javaName}}_STREAM_EXCEPTION_READERS, _metadata, java.util.Collections.emptyMap()); return _rpc .singleRequestStreamingResponse(_crp, rpcOptions) .doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}){{#function:return_type}}{{^function:stream_has_first_response?}} .filter((_p) -> ((com.facebook.thrift.model.StreamResponse)_p.getData()).isSetData()){{/function:stream_has_first_response?}}{{/function:return_type}} .map(_p -> ResponseWrapper.create((({{#function:return_type}}{{> StreamResponseGeneric}}{{/function:return_type}})_p.getData()){{#function:return_type}}{{^function:stream_has_first_response?}}.getData(){{/function:stream_has_first_response?}}{{/function:return_type}}, _p.getHeaders(), _p.getBinaryHeaders())); })); } @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} rpcOptions).map(_p -> _p.getData()); } @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}} com.facebook.thrift.client.RpcOptions.EMPTY); } {{/service:streamingFunctions}} {{#service:sinkFunctions}} private com.facebook.thrift.payload.Writer _create{{function:javaName}}Writer({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return oprot -> { try { {{#function:args}} {{#field:type}} { oprot.writeFieldBegin(_{{function:javaName}}_{{field:javaTFieldName}}); {{> FieldType}} _iter0 = {{field:javaName}}; {{#field:type}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:type}} {{/function:args}} } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private com.facebook.thrift.payload.Writer _create{{function:javaName}}SinkWriter({{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}} _p{{/function:sink_elem_type}}{{/function:return_type}}) { return oprot -> { try { oprot.writeFieldBegin(_{{function:javaName}}_SINK_TFIELD); {{#function:return_type}}{{#function:sink_elem_type}} {{> WriteSinkPayloadType}} {{/function:sink_elem_type}}{{/function:return_type}} oprot.writeFieldEnd(); } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:sink_final_response_type}}{{> TypeReader }}{{/function:sink_final_response_type}}{{/function:return_type}}{{/function:void?}}; {{#function:return_type}}{{#function:sink_has_first_response?}} private static final com.facebook.thrift.payload.Reader _{{function:javaName}}_FIRST_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:sink_first_response_type}}{{> TypeReader }}{{/function:sink_first_response_type}}{{/function:return_type}}{{/function:void?}}; {{/function:sink_has_first_response?}}{{/function:return_type}} @java.lang.Override public {{#function:return_type}}{{> SinkWrapperReturnType}}{{/function:return_type}} {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads, com.facebook.thrift.client.RpcOptions rpcOptions) { return _rpcClient .flatMapMany(_rpc -> getHeaders(rpcOptions).flatMapMany(headers -> { org.apache.thrift.RequestRpcMetadata _metadata = new org.apache.thrift.RequestRpcMetadata.Builder() .setName("{{function:name}}") .setKind(org.apache.thrift.RpcKind.SINK) .setOtherMetadata(headers) .setProtocol(_protocolId) .build(); com.facebook.thrift.payload.ClientRequestPayload<{{#function:return_type}}{{#function:sink_final_response_type}}{{> BoxedType}}{{/function:sink_final_response_type}}{{/function:return_type}}> _crp = com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}Writer({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}), _{{function:javaName}}_READER,{{#function:return_type}}{{#function:sink_has_first_response?}} _{{function:javaName}}_FIRST_READER,{{/function:sink_has_first_response?}}{{/function:return_type}} _{{function:javaName}}_EXCEPTION_READERS, _{{function:javaName}}_STREAM_EXCEPTION_READERS, _metadata, java.util.Collections.emptyMap()); reactor.core.publisher.Flux BoxedType}}{{/function:sink_final_response_type}}{{/function:return_type}}>> _sink = reactor.core.publisher.Mono.just(_crp).concatWith(reactor.core.publisher.Flux.from(payloads) .map(_p -> com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}SinkWriter(_p), _{{function:javaName}}_READER,{{#function:return_type}}{{#function:sink_has_first_response?}} _{{function:javaName}}_FIRST_READER,{{/function:sink_has_first_response?}}{{/function:return_type}} _{{function:javaName}}_EXCEPTION_READERS, _{{function:javaName}}_STREAM_EXCEPTION_READERS, _metadata, java.util.Collections.emptyMap()))); return _rpc .streamingRequestStreamingResponse(_sink, rpcOptions) .doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}){{#function:return_type}}{{^function:sink_has_first_response?}} .filter((_p) -> ((com.facebook.thrift.model.StreamResponse)_p.getData()).isSetData()){{/function:sink_has_first_response?}}{{/function:return_type}} .map(_p -> ResponseWrapper.create((({{#function:return_type}}{{> SinkResponseGeneric}}{{/function:return_type}})_p.getData()){{#function:return_type}}{{^function:sink_has_first_response?}}.getData(){{/function:sink_has_first_response?}}{{/function:return_type}}, _p.getHeaders(), _p.getBinaryHeaders())); })){{#function:return_type}}{{^function:sink_has_first_response?}}.single(){{/function:sink_has_first_response?}}{{/function:return_type}}; } @java.lang.Override public {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads, com.facebook.thrift.client.RpcOptions rpcOptions) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} payloads, rpcOptions).map(_p -> _p.getData()); } @java.lang.Override public {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}} payloads, com.facebook.thrift.client.RpcOptions.EMPTY); } {{/service:sinkFunctions}} {{#service:interactions}} public class {{service:name}}Impl implements {{service:name}} { private final long interactionId; {{service:name}}Impl(long interactionId) { this.interactionId = interactionId; com.facebook.thrift.client.ThriftClientStatsHolder.getThriftClientStats().interactionCreated("{{service:name}}"); } {{#service:singleRequestFunctions}} private final java.util.Map _{{function:javaName}}_EXCEPTION_READERS = {{#function:exceptions?}}new HashMap<>();{{/function:exceptions?}}{{^function:exceptions?}}java.util.Collections.emptyMap();{{/function:exceptions?}} {{#function:exceptions}} private final com.facebook.thrift.payload.Reader _{{function:javaName}}_EXCEPTION_READER_INT{{field:index}} = Readers.wrap({{#field:type}}{{> BoxedType}}.asReader());{{/field:type}} {{/function:exceptions}} {{/service:singleRequestFunctions}} {{#service:singleRequestFunctions}} private com.facebook.thrift.payload.Writer _create{{function:javaName}}Writer({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return oprot -> { try { {{#function:args}} {{#field:type}} { oprot.writeFieldBegin(_{{function:javaName}}_{{field:javaTFieldName}}_INT); {{> FieldType}} _iter0 = {{field:javaName}}; {{#field:type}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:type}} {{/function:args}} } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private final com.facebook.thrift.payload.Reader _{{function:javaName}}_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{> TypeReader }}{{/function:return_type}}{{/function:void?}}; public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} com.facebook.thrift.client.RpcOptions.EMPTY){{#function:oneway?}}.then(){{/function:oneway?}}{{! }}{{^function:oneway?}}{{^function:voidType}}.map(_p -> _p.getData()){{/function:voidType}}{{/function:oneway?}}{{! }}{{^function:oneway?}}{{#function:voidType}}.then(){{/function:voidType}}{{/function:oneway?}}; } @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} rpcOptions){{#function:oneway?}}.then(){{/function:oneway?}}{{! }}{{^function:oneway?}}{{^function:voidType}}.map(_p -> _p.getData()){{/function:voidType}}{{/function:oneway?}}{{! }}{{^function:oneway?}}{{#function:voidType}}.then(){{/function:voidType}}{{/function:oneway?}}; } @java.lang.Override public reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#functio)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(n:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { return _rpcClient .contextWrite(ctx -> ctx.put(STICKY_HASH_KEY, interactionId)) .flatMap(_rpc -> getHeaders(rpcOptions).flatMap(headers -> { String interactionName = "{{service:name}}.{{function:name}}"; org.apache.thrift.RequestRpcMetadata.Builder _metadataBuilder = new org.apache.thrift.RequestRpcMetadata.Builder() .setName(interactionName) .setKind(org.apache.thrift.RpcKind.{{#function:oneway?}}SINGLE_REQUEST_NO_RESPONSE{{/function:oneway?}}{{^function:oneway?}}SINGLE_REQUEST_SINGLE_RESPONSE{{/function:oneway?}}) .setOtherMetadata(headers) .setProtocol(_protocolId); if (_activeInteractions.contains(interactionId)) { _metadataBuilder.setInteractionId(interactionId); } else { _metadataBuilder.setInteractionCreate( new InteractionCreate.Builder() .setInteractionId(interactionId) .setInteractionName("{{service:name}}") .build()); _metadataBuilder.setInteractionId(0L); _activeInteractions.add(interactionId); } org.apache.thrift.RequestRpcMetadata _metadata = _metadataBuilder.build(); com.facebook.thrift.payload.ClientRequestPayload<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _crp = com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}Writer({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}), _{{function:javaName}}_READER, _{{function:javaName}}_EXCEPTION_READERS_INT, _metadata, java.util.Collections.emptyMap()); return _rpc {{#function:oneway?}}.singleRequestNoResponse(_crp, rpcOptions).thenReturn(ResponseWrapper.create(null, java.util.Collections.emptyMap(), java.util.Collections.emptyMap())){{/function:oneway?}}{{! }}{{^function:oneway?}}.singleRequestSingleResponse(_crp, rpcOptions).doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}){{/function:oneway?}}; })); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} private com.facebook.thrift.payload.Writer _create{{function:javaName}}Writer({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return oprot -> { try { {{#function:args}} {{#field:type}} { oprot.writeFieldBegin(_{{function:javaName}}_{{field:javaTFieldName}}_INT); {{> FieldType}} _iter0 = {{field:javaName}}; {{#field:type}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:type}} {{/function:args}} } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } private final com.facebook.thrift.payload.Reader _{{function:javaName}}_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:stream_elem_type}}{{> TypeReader }}{{/function:stream_elem_type}}{{/function:return_type}}{{/function:void?}}; {{#function:return_type}}{{#function:stream_has_first_response?}} private final com.facebook.thrift.payload.Reader _{{function:javaName}}_FIRST_READER = {{! }}{{#function:void?}}Readers.voidReader(){{/function:void?}}{{! }}{{^function:void?}}{{#function:return_type}}{{#function:stream_first_response_type}}{{> TypeReader }}{{/function:stream_first_response_type}}{{/function:return_type}}{{/function:void?}}; {{/function:stream_has_first_response?}}{{/function:return_type}} @java.lang.Override public reactor.core.publisher.Flux StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return _rpcClient .contextWrite(ctx -> ctx.put(STICKY_HASH_KEY, interactionId)) .flatMapMany(_rpc -> getHeaders(rpcOptions).flatMapMany(headers -> { String interactionName = "{{service:name}}.{{function:name}}"; org.apache.thrift.RequestRpcMetadata.Builder _metadataBuilder = new org.apache.thrift.RequestRpcMetadata.Builder() .setName(interactionName) .setKind(org.apache.thrift.RpcKind.SINGLE_REQUEST_STREAMING_RESPONSE) .setOtherMetadata(headers) .setProtocol(_protocolId); if (_activeInteractions.contains(interactionId)) { _metadataBuilder.setInteractionId(interactionId); } else { _metadataBuilder.setInteractionCreate( new InteractionCreate.Builder() .setInteractionId(interactionId) .setInteractionName("{{service:name}}") .build()); _metadataBuilder.setInteractionId(0L); _activeInteractions.add(interactionId); } com.facebook.thrift.payload.ClientRequestPayload<{{#function:return_type}}{{#function:stream_elem_type}}{{> BoxedType}}{{/function:stream_elem_type}}{{/function:return_type}}> _crp = com.facebook.thrift.payload.ClientRequestPayload.create( "{{service:name}}", _create{{function:javaName}}Writer({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}), _{{function:javaName}}_READER,{{#function:return_type}}{{#function:stream_has_first_response?}} _{{function:javaName}}_FIRST_READER,{{/function:stream_has_first_response?}}{{/function:return_type}} _{{function:javaName}}_EXCEPTION_READERS_INT, _{{function:javaName}}_STREAM_EXCEPTION_READERS_INT, _metadataBuilder.build(), java.util.Collections.emptyMap()); return _rpc .singleRequestStreamingResponse(_crp, rpcOptions) .transform(com.facebook.thrift.util.FluxPublishingTransformer.getInstance()) .doOnNext(_p -> {if(_p.getException() != null) throw reactor.core.Exceptions.propagate(_p.getException());}){{#function:return_type}}{{^function:stream_has_first_response?}} .filter((_p) -> ((com.facebook.thrift.model.StreamResponse)_p.getData()).isSetData()){{/function:stream_has_first_response?}}{{/function:return_type}} .map(_p -> ResponseWrapper.create((({{#function:return_type}}{{> StreamResponseGeneric}}{{/function:return_type}})_p.getData()){{#function:return_type}}{{^function:stream_has_first_response?}}.getData(){{/function:stream_has_first_response?}}{{/function:return_type}}, _p.getHeaders(), _p.getBinaryHeaders())); })); } @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} final com.facebook.thrift.client.RpcOptions rpcOptions) { return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}} rpcOptions).map(_p -> _p.getData()); } @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}} com.facebook.thrift.client.RpcOptions.EMPTY); } {{/service:streamingFunctions}} @java.lang.Override public void dispose() { com.facebook.thrift.client.ThriftClientStatsHolder.getThriftClientStats().interactionDisposed("{{service:name}}"); _activeInteractions.remove(interactionId); _rpcClient .contextWrite(ctx -> ctx.put(STICKY_HASH_KEY, interactionId)) .flatMap(_rpc -> { InteractionTerminate term = new InteractionTerminate.Builder().setInteractionId(interactionId).build(); ClientPushMetadata metadata = ClientPushMetadata.fromInteractionTerminate(term); return _rpc.metadataPush(metadata, com.facebook.thrift.client.RpcOptions.EMPTY); }).subscribe(); } } public {{service:name}} create{{service:name}}() { return new {{service:name}}Impl(_interactionCounter.incrementAndGet()); } {{^last?}} {{/last?}} {{/service:interactions}} private reactor.core.publisher.Mono> getHeaders(com.facebook.thrift.client.RpcOptions rpcOptions) { Map requestHeaders = new HashMap<>(); if (rpcOptions.getRequestHeaders() != null && !rpcOptions.getRequestHeaders().isEmpty()) { requestHeaders.putAll(rpcOptions.getRequestHeaders()); } return _headersMono.defaultIfEmpty(java.util.Collections.emptyMap()).zipWith(_persistentHeadersMono.defaultIfEmpty(java.util.Collections.emptyMap()), (headers, persistentHeaders) -> { Map result = new HashMap<>(); result.putAll(requestHeaders); result.putAll(headers); result.putAll(persistentHeaders); return result; }); } } )__FBTHRIFT_TAG__", // java/ReadType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isAdapterSet?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{type:setAdapter}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{type:setAdapter}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{type:setAdapter}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:isAdapterSet?}}{{! }}{{^type:isAdapterSet?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> ReadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:isAdapterSet?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}{{> ReadTypeContainer}}{{/type:set?}}{{! }}{{#type:list?}}{{> ReadTypeContainer}}{{/type:list?}}{{! }}{{#type:map?}}{{> ReadTypeContainer}}{{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#field:isNested?}}{{> BoxedType}}.read0(oprot){{/field:isNested?}}{{! }}{{^field:isNested?}}{{#field:hasAdapter?}}{{> ThriftBoxedType}} {{field:javaName}} = {{> ThriftBoxedType}}.read0(oprot);{{/field:hasAdapter?}}{{^field:hasAdapter?}}{{> FieldType}} {{field:javaName}} = {{> ThriftBoxedType}}.read0(oprot);{{/field:hasAdapter?}}{{/field:isNested?}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#field:isNested?}}{{> BoxedType}}.fromInteger(oprot.readI32()){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = {{> ThriftFieldType}}.fromInteger(oprot.readI32());{{/field:isNested?}}{{! }}{{/type:enum?}}{{! }}{{#type:binary?}}{{! }}{{#field:isNested?}}{{! }}{{> ReadTypeBinary}}{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}{{! }}{{#field:type}}{{#type:hasAdapter?}}{{> ThriftBoxedType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> BoxedType}}{{/type:hasAdapter?}}{{/field:type}} {{field:javaName}} = {{! }}{{> ReadTypeBinary}};{{! }}{{/field:isNested?}}{{! }}{{/type:binary?}}{{! }}{{#type:string?}}{{! }}{{#field:isNested?}}{{! }}{{#type:isBinaryString?}}{{! }}{{> ReadTypeBinary}}{{! }}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}{{! }}oprot.readString({{> Utf8Validation}}){{! }}{{/type:isBinaryString?}}{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}{{! }}{{#type:isBinaryString?}}{{! }}{{#field:type}}{{#type:hasAdapter?}}{{> ThriftBoxedType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> BoxedType}}{{/type:hasAdapter?}}{{/field:type}} {{field:javaName}} = {{! }}{{> ReadTypeBinary}};{{! }}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}{{> ThriftFieldType}} {{field:javaName}} = {{! }}oprot.readString({{> Utf8Validation}});{{! }}{{/type:isBinaryString?}}{{! }}{{/field:isNested?}}{{! }}{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#field:isNested?}}oprot.readBool(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readBool();{{/field:isNested?}}{{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}{{#field:isNested?}}oprot.readByte(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readByte();{{/field:isNested?}}{{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}{{#field:isNested?}}oprot.readI16(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readI16();{{/field:isNested?}}{{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}{{#field:isNested?}}oprot.readI32(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readI32();{{/field:isNested?}}{{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}{{#field:isNested?}}oprot.readI64(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readI64();{{/field:isNested?}}{{! }}{{/type:i64?}}{{! }}{{#type:float?}}{{! }}{{#field:isNested?}}oprot.readFloat(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readFloat();{{/field:isNested?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#field:isNested?}}oprot.readDouble(){{/field:isNested?}}{{! }}{{^field:isNested?}}{{> ThriftFieldType}} {{field:javaName}} = oprot.readDouble();{{/field:isNested?}}{{! }}{{/type:double?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/ReadTypeBinary.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:isAdapterSet?}}{{! }}org.apache.thrift.protocol.TProtocolUtil.readBinaryAsByteBuf(oprot){{! }}{{/type:isAdapterSet?}}{{! }}{{^type:isAdapterSet?}}{{! }}{{#field:hasAdapter?}}{{! }}org.apache.thrift.protocol.TProtocolUtil.readBinaryAsByteBuf(oprot){{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}oprot.readBinary(){{^type:javaType}}.array(){{/type:javaType}}{{! }}{{/field:hasAdapter?}}{{! }}{{/type:isAdapterSet?}})__FBTHRIFT_TAG__", // java/ReadTypeContainer.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> ReadTypeContainer}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> ReadTypeContainer}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> ReadTypeContainer}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}{{! }}{{> BoxedType}} {{field:javaName}}; { TSet _set = oprot.readSetBegin(); {{^type:javaType}}{{field:javaName}} = new Hash{{> BoxedType}}(Math.max(0, _set.size));{{/type:javaType}}{{! }}{{#type:javaType}}{{field:javaName}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i = 0; (_set.size < 0) ? oprot.peekSet() : (_i < _set.size); _i++) { {{field:setIsNested}} {{#type:set_elem_type}} {{#type:isContainer?}} {{> ReadTypeContainerNestedValue }} {{/type:isContainer?}} {{^type:isContainer?}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value1 = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{/type:isContainer?}}{{! }}{{field:javaName}}.add({{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value1){{#type:hasAdapter?}}){{/type:hasAdapter?}}; {{/type:set_elem_type}} } oprot.readSetEnd(); }{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}{{> BoxedType}} {{field:javaName}}; { TList _list = oprot.readListBegin(); {{^type:javaType}}{{field:javaName}} = new Array{{> BoxedType}}(Math.max(0, _list.size));{{/type:javaType}}{{! }}{{#type:javaType}}{{field:javaName}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i = 0; (_list.size < 0) ? oprot.peekList() : (_i < _list.size); _i++) { {{field:setIsNested}} {{#type:list_elem_type}} {{#type:isContainer?}} {{> ReadTypeContainerNestedValue }} {{/type:isContainer?}} {{^type:isContainer?}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value1 = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{/type:isContainer?}}{{! }}{{field:javaName}}.add({{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value1){{#type:hasAdapter?}}){{/type:hasAdapter?}}; {{/type:list_elem_type}} } oprot.readListEnd(); }{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}{{> BoxedType}} {{field:javaName}}; { TMap _map = oprot.readMapBegin(); {{^type:javaType}}{{field:javaName}} = new Hash{{> BoxedType}}(Math.max(0, _map.size));{{/type:javaType}}{{! }}{{#type:javaType}}{{field:javaName}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i = 0; (_map.size < 0) ? oprot.peekMap() : (_i < _map.size); _i++) { {{field:setIsNested}} {{#type:key_type}} {{#type:isContainer?}} {{> ReadTypeContainerNestedKey }} {{/type:isContainer?}} {{^type:isContainer?}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _key1 = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{/type:isContainer?}} {{/type:key_type}} {{#type:value_type}} {{#type:isContainer?}} {{> ReadTypeContainerNestedValue }} {{/type:isContainer?}} {{^type:isContainer?}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value1 = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{/type:isContainer?}} {{/type:value_type}} {{field:javaName}}.put({{! }}{{#type:key_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_key1{{#type:hasAdapter?}}){{/type:hasAdapter?}}, {{/type:key_type}}{{! }}{{#type:value_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value1{{#type:hasAdapter?}}){{/type:hasAdapter?}});{{/type:value_type}} } } oprot.readMapEnd();{{! }}{{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/ReadTypeContainerNestedKey.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}{{! }}{{> BoxedType}} _key{{field:nestedDepth}}; { TSet _set{{field:nestedDepth}} = oprot.readSetBegin(); {{^type:javaType}}_key{{field:nestedDepth}} = new Hash{{> BoxedType}}(Math.max(0, _set{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_key{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_set{{field:nestedDepth}}.size < 0) ? oprot.peekSet() : (_i{{field:nestedDepth}} < _set{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:set_elem_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}}{{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}};{{field:nestedDepth--}} {{/type:isContainer?}} {{field:nestedDepth++}}_key{{field:prevNestedDepth}}.add(_value{{field:nestedDepth}});{{field:nestedDepth--}} {{/type:set_elem_type}} } oprot.readSetEnd(); } {{/type:set?}}{{! }}{{#type:list?}}{{! }}{{> BoxedType}} _key{{field:nestedDepth}}; { TList _list{{field:nestedDepth}} = oprot.readListBegin(); {{^type:javaType}}_key{{field:nestedDepth}} = new Array{{> BoxedType}}(Math.max(0, _list{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_key{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_list{{field:nestedDepth}}.size < 0) ? oprot.peekList() : (_i{{field:nestedDepth}} < _list{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:list_elem_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}}{{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}};{{field:nestedDepth--}} {{/type:isContainer?}} {{field:nestedDepth++}}_key{{field:prevNestedDepth}}.add(_value{{field:nestedDepth}});{{field:nestedDepth--}} {{/type:list_elem_type}} } oprot.readListEnd(); } {{/type:list?}}{{! }}{{#type:map?}}{{! }}{{> BoxedType}} _key{{field:nestedDepth}}; { TMap _map{{field:nestedDepth}} = oprot.readMapBegin(); {{^type:javaType}}_key{{field:nestedDepth}} = new Hash{{> BoxedType}}(Math.max(0, _map{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_key{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_map{{field:nestedDepth}}.size < 0) ? oprot.peekMap() : (_i{{field:nestedDepth}} < _map{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:key_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedKey }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}}{{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _key{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}};{{field:nestedDepth--}} {{/type:isContainer?}} {{/type:key_type}} {{#type:value_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}}{{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}};{{field:nestedDepth--}} {{/type:isContainer?}} {{field:nestedDepth++}}_key{{field:prevNestedDepth}}.put(_key{{field:nestedDepth}}, _value{{field:nestedDepth}});{{field:nestedDepth--}} {{/type:value_type}} } oprot.readMapEnd(); } {{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/ReadTypeContainerNestedValue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> ReadTypeContainerNestedValue}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}{{! }}{{> BoxedType}} _value{{field:nestedDepth}}; { TSet _set{{field:nestedDepth}} = oprot.readSetBegin(); {{^type:javaType}}_value{{field:nestedDepth}} = new Hash{{> BoxedType}}(Math.max(0, _set{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_value{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_set{{field:nestedDepth}}.size < 0) ? oprot.peekSet() : (_i{{field:nestedDepth}} < _set{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:set_elem_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{field:nestedDepth--}} {{/type:isContainer?}} {{field:nestedDepth++}} _value{{field:prevNestedDepth}}.add({{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value{{field:nestedDepth}}){{#type:hasAdapter?}}){{/type:hasAdapter?}}; {{field:nestedDepth--}} {{/type:set_elem_type}} } oprot.readSetEnd(); } {{/type:set?}}{{! }}{{#type:list?}}{{! }}{{> BoxedType}} _value{{field:nestedDepth}}; { TList _list{{field:nestedDepth}} = oprot.readListBegin(); {{^type:javaType}}_value{{field:nestedDepth}} = new Array{{> BoxedType}}(Math.max(0, _list{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_value{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_list{{field:nestedDepth}}.size < 0) ? oprot.peekList() : (_i{{field:nestedDepth}} < _list{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:list_elem_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{field:nestedDepth--}} {{/type:isContainer?}} {{field:nestedDepth++}} _value{{field:prevNestedDepth}}.add({{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value{{field:nestedDepth}}){{#type:hasAdapter?}}){{/type:hasAdapter?}}; {{field:nestedDepth--}} {{/type:list_elem_type}} } oprot.readListEnd(); } {{/type:list?}}{{! }}{{#type:map?}}{{! }}{{> BoxedType}} _value{{field:nestedDepth}}; { TMap _map{{field:nestedDepth}} = oprot.readMapBegin(); {{^type:javaType}}_value{{field:nestedDepth}} = new Hash{{> BoxedType}}(Math.max(0, _map{{field:nestedDepth}}.size));{{/type:javaType}}{{! }}{{#type:javaType}}_value{{field:nestedDepth}} = new {{type:javaType}}();{{/type:javaType}}{{! }} for (int _i{{field:nestedDepth}} = 0; (_map{{field:nestedDepth}}.size < 0) ? oprot.peekMap() : (_i{{field:nestedDepth}} < _map{{field:nestedDepth}}.size); _i{{field:nestedDepth}}++) { {{field:setIsNested}} {{#type:key_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedKey }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _key{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{field:nestedDepth--}} {{/type:isContainer?}} {{/type:key_type}} {{#type:value_type}} {{#type:isContainer?}} {{field:nestedDepth++}}{{> ReadTypeContainerNestedValue }}{{field:nestedDepth--}} {{/type:isContainer?}} {{^type:isContainer?}} {{field:nestedDepth++}} {{#type:hasAdapter?}}{{> ThriftType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> Type}}{{/type:hasAdapter?}} _value{{field:nestedDepth}} = {{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> ReadType}}; {{field:nestedDepth--}} {{/type:isContainer?}} {{/type:value_type}} {{field:nestedDepth++}} _value{{field:prevNestedDepth}}.put({{! }}{{#type:key_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_key{{field:nestedDepth}}{{#type:hasAdapter?}}){{/type:hasAdapter?}}, {{/type:key_type}}{{! }}{{#type:value_type}}{{#type:hasAdapter?}}__{{type:name}}_Adapter.fromThrift({{/type:hasAdapter?}}_value{{field:nestedDepth}}{{#type:hasAdapter?}}){{/type:hasAdapter?}});{{/type:value_type}} {{field:nestedDepth--}} } } oprot.readMapEnd(); {{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/Requiredness.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:required?}}Requiredness.REQUIRED{{/field:required?}}{{! }}{{#field:optional?}}Requiredness.OPTIONAL{{/field:optional?}}{{! }}{{#field:opt_in_req_out?}}Requiredness.NONE{{/field:opt_in_req_out?}}{{! }}{{#field:terse?}}Requiredness.TERSE{{/field:terse?}})__FBTHRIFT_TAG__", // java/RpcServerHandler.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import java.util.*; import org.apache.thrift.protocol.*; import com.facebook.thrift.util.Readers; public class {{service:javaCapitalName}}RpcServerHandler {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}RpcServerHandler{{/service:extends}} implements com.facebook.thrift.server.RpcServerHandler { private final java.util.Map _methodMap; private final {{service:javaCapitalName}}.Reactive _delegate; {{#service:singleRequestFunctions}} private final java.util.List _{{function:javaName}}Readers; {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} private final java.util.List _{{function:javaName}}Readers; private final com.facebook.thrift.server.generated.SingleRequestStreamResponseDelegate<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> _delegate_{{function:javaName}}; {{^function:stream_has_first_response?}} private final com.facebook.thrift.server.generated.StreamResponseHandler<{{#function:return_type}}{{#function:stream_elem_type}}{{> BoxedType}}{{/function:stream_elem_type}}{{/function:return_type}}> _handler_{{function:javaName}}; {{/function:stream_has_first_response?}} {{#function:stream_has_first_response?}} private final com.facebook.thrift.server.generated.StreamWithFirstResponseHandler<{{#function:return_type}}{{#function:stream_first_response_type}}{{> BoxedType}}{{/function:stream_first_response_type}},{{#function:stream_elem_type}}{{> BoxedType}}{{/function:stream_elem_type}}{{/function:return_type}}> _handler_{{function:javaName}}; {{/function:stream_has_first_response?}} {{/service:streamingFunctions}} private final java.util.List _eventHandlers; public {{service:javaCapitalName}}RpcServerHandler({{service:javaCapitalName}} _delegate, java.util.List _eventHandlers) { this(new {{service:javaCapitalName}}BlockingReactiveWrapper(_delegate), _eventHandlers); } public {{service:javaCapitalName}}RpcServerHandler({{service:javaCapitalName}}.Async _delegate, java.util.List _eventHandlers) { this(new {{service:javaCapitalName}}AsyncReactiveWrapper(_delegate), _eventHandlers); } public {{service:javaCapitalName}}RpcServerHandler({{service:javaCapitalName}}.Reactive _delegate, java.util.List _eventHandlers) { {{#service:extends}}super(_delegate, _eventHandlers);{{/service:extends}} this._methodMap = new java.util.HashMap<>(); this._delegate = _delegate; this._eventHandlers = _eventHandlers; {{#service:singleRequestFunctions}} _methodMap.put("{{function:javaName}}", this); _{{function:javaName}}Readers = _create_{{function:javaName}}_request_readers(); {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} _methodMap.put("{{function:javaName}}", this); _{{function:javaName}}Readers = _create_{{function:javaName}}_request_readers(); _delegate_{{function:javaName}} = (java.util.List _list) -> { java.util.Iterator _iterator = _list.iterator(); {{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}} = ({{#field:type}}{{> Type}}{{/field:type}}) _iterator.next(); {{/function:args}} return _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); }; _handler_{{function:javaName}} = {{^function:stream_has_first_response?}} new com.facebook.thrift.server.generated.StreamResponseHandler<>( _delegate_{{function:javaName}}, _ResponseWriterFactory_{{function:javaName}}, _{{function:javaName}}Readers, "{{function:javaName}}", new Class[]{ {{#function:exceptions?}}{{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}.class{{^last?}},{{/last?}}{{/function:exceptions}}{{/function:exceptions?}} }, new Integer[]{ {{#function:exceptions?}}{{#function:exceptions}}{{field:key}}{{^last?}},{{/last?}}{{/function:exceptions}}{{/function:exceptions?}} }, new Class[]{ {{#function:stream_exceptions?}}{{#function:stream_exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}.class{{^last?}},{{/last?}}{{/function:stream_exceptions}}{{/function:stream_exceptions?}} }, new Integer[]{ {{#function:stream_exceptions?}}{{#function:stream_exceptions}}{{field:key}}{{^last?}},{{/last?}}{{/function:stream_exceptions}}{{/function:stream_exceptions?}} } ); {{/function:stream_has_first_response?}} {{#function:stream_has_first_response?}} new com.facebook.thrift.server.generated.StreamWithFirstResponseHandler<>( _delegate_{{function:javaName}}, _first_ResponseWriterFactory_{{function:javaName}}, _ResponseWriterFactory_{{function:javaName}}, _{{function:javaName}}Readers, "{{function:javaName}}", new Class[]{ {{#function:exceptions?}}{{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}.class{{^last?}},{{/last?}}{{/function:exceptions}}{{/function:exceptions?}} }, new Integer[]{ {{#function:exceptions?}}{{#function:exceptions}}{{field:key}}{{^last?}},{{/last?}}{{/function:exceptions}}{{/function:exceptions?}} }, new Class[]{ {{#function:stream_exceptions?}}{{#function:stream_exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}.class{{^last?}},{{/last?}}{{/function:stream_exceptions}}{{/function:stream_exceptions?}} }, new Integer[]{ {{#function:stream_exceptions?}}{{#function:stream_exceptions}}{{field:key}}{{^last?}},{{/last?}}{{/function:stream_exceptions}}{{/function:stream_exceptions?}} } ); {{/function:stream_has_first_response?}} {{/service:streamingFunctions}} } {{#service:streamingFunctions}} private final static java.util.List _create_{{function:javaName}}_request_readers() { java.util.List _readerList = new java.util.ArrayList<>(); {{#function:args}} {{function:unsetIsNested}} _readerList.add({{#field:type}}{{> TypeReader }}{{/field:type}}); {{/function:args}} return _readerList; } private final static com.facebook.thrift.server.generated.ResponseWriterFactory _ResponseWriterFactory_{{function:javaName}} = (java.lang.Object _o, com.facebook.swift.service.ContextChain _chain, com.facebook.thrift.payload.ServerRequestPayload _requestPayload) -> { return oprot -> { try { oprot.writeStructBegin(com.facebook.thrift.util.RpcPayloadUtil.TSTRUCT); {{function:unsetIsNested}} {{^function:voidType}} {{#function:return_type}} {{#function:stream_elem_type}} {{> Type}} _iter0 = ({{> Type}})_o; {{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/function:stream_elem_type}} oprot.writeFieldEnd(); {{/function:return_type}} {{/function:voidType}} oprot.writeFieldStop(); oprot.writeStructEnd(); _chain.postWrite(_o); } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; }; {{#function:stream_has_first_response?}} private final static com.facebook.thrift.server.generated.ResponseWriterFactory _first_ResponseWriterFactory_{{function:javaName}} = (java.lang.Object _o, com.facebook.swift.service.ContextChain _chain, com.facebook.thrift.payload.ServerRequestPayload _requestPayload) -> { return oprot -> { try { oprot.writeStructBegin(com.facebook.thrift.util.RpcPayloadUtil.TSTRUCT); {{function:unsetIsNested}} {{^function:voidType}} {{#function:return_type}} {{#function:stream_first_response_type}} {{> Type}} _iter0 = ({{> Type}})_o; {{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/function:stream_first_response_type}} oprot.writeFieldEnd(); {{/function:return_type}} {{/function:voidType}} oprot.writeFieldStop(); oprot.writeStructEnd(); _chain.postWrite(_o); } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; }; {{/function:stream_has_first_response?}} {{/service:streamingFunctions}} {{#service:requestResponseFunctions}} private static java.util.List _create_{{function:javaName}}_request_readers() { java.util.List _readerList = new java.util.ArrayList<>(); {{#function:args}} {{function:unsetIsNested}} _readerList.add({{#field:type}}{{> TypeReader }}{{/field:type}}); {{/function:args}} return _readerList; } private static com.facebook.thrift.payload.Writer _create_{{function:javaName}}_response_writer( final java.lang.Object _r, final com.facebook.swift.service.ContextChain _chain, final int _seqId) { return oprot -> { try { oprot.writeStructBegin(com.facebook.thrift.util.RpcPayloadUtil.TSTRUCT); {{function:unsetIsNested}} {{^function:voidType}} {{#function:return_type}} {{> Type}} _iter0 = ({{> Type}})_r; {{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} oprot.writeFieldEnd(); {{/function:return_type}} {{/function:voidType}} oprot.writeFieldStop(); oprot.writeStructEnd(); _chain.postWrite(_r); } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } {{#function:exceptions?}} private static com.facebook.thrift.payload.Writer _create_{{function:javaName}}_exception_writer( final Throwable _t, final com.facebook.swift.service.ContextChain _chain, final int _seqId, final short _fieldId) { return oprot -> { try { _chain.declaredUserException(_t); oprot.writeStructBegin(com.facebook.thrift.util.RpcPayloadUtil.TSTRUCT); oprot.writeFieldBegin( new TField("responseField", TType.STRUCT, _fieldId)); com.facebook.thrift.payload.ThriftSerializable _iter0 = (com.facebook.thrift.payload.ThriftSerializable)_t; _iter0.write0(oprot); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); _chain.postWriteException(_t); } catch (Throwable _e) { com.facebook.thrift.util.NettyUtil.releaseIfByteBufTProtocol(oprot); throw reactor.core.Exceptions.propagate(_e); } }; } {{/function:exceptions?}} private static reactor.core.publisher.Mono _do{{function:javaName}}( {{service:javaCapitalName}}.Reactive _delegate, com.facebook.thrift.payload.ServerRequestPayload _payload, java.util.List _readers, com.facebook.swift.service.ContextChain _chain) { _chain.preRead(); java.util.List_data = _payload.getData(_readers); java.util.Iterator _iterator = _data.iterator(); {{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}} = ({{#field:type}}{{> Type}}{{/field:type}}) _iterator.next(); {{/function:args}} _chain.postRead(_data); reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _delegateResponse = _delegate .{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) .doFirst(() -> com.facebook.nifty.core.RequestContexts.setCurrentContext(_payload.getRequestContext())); reactor.core.publisher.Mono _internalResponse = _delegateResponse.map(_response -> { _chain.preWrite(_response); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.createServerResponsePayload( _payload, _create_{{function:javaName}}_response_writer(_response, _chain, _payload.getMessageSeqId())); return _serverResponsePayload; }) .switchIfEmpty( reactor.core.publisher.Mono.fromSupplier( () -> { {{^function:voidType}} org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "method {{function:javaName}} returned null"); return com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); {{/function:voidType}} {{#function:voidType}} _chain.preWrite(null); return com.facebook.thrift.util.RpcPayloadUtil.createServerResponsePayload( _payload, _create_{{function:javaName}}_response_writer(null, _chain, _payload.getMessageSeqId())); {{/function:voidType}} } ) ) .onErrorResume(_t -> { _chain.preWriteException(_t); {{#function:exceptions}} if (_t instanceof {{#field:type}}{{> Type}}{{/field:type}}) { com.facebook.thrift.payload.Writer _exceptionWriter = _create_{{function:javaName}}_exception_writer(_t, _chain, _payload.getMessageSeqId(), (short) {{field:key}}); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.createServerResponsePayload( _payload, _exceptionWriter, _t.getMessage()); return reactor.core.publisher.Mono.just(_serverResponsePayload); } {{/function:exceptions}} {{#function:exceptions?}} else { {{/function:exceptions?}} // exception is not of user declared type String _errorMessage = String.format("Internal error processing {{function:javaName}}: %s", _t.getMessage() == null ? "" : _t.getMessage()); org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, _errorMessage); _tApplicationException.initCause(_t); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); return reactor.core.publisher.Mono.just(_serverResponsePayload); )__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__( {{#function:exceptions?}} } {{/function:exceptions?}} }) .doFinally(__ -> { _chain.done(); }); return _internalResponse; } {{/service:requestResponseFunctions}} {{#service:onewayFunctions}} private static java.util.List _create_{{function:javaName}}_request_readers() { java.util.List _readerList = new java.util.ArrayList<>(); {{#function:args}} {{function:unsetIsNested}} _readerList.add({{#field:type}}{{> TypeReader }}{{/field:type}}); {{/function:args}} return _readerList; } private static reactor.core.publisher.Mono _do{{function:javaName}}( {{service:javaCapitalName}}.Reactive _delegate, com.facebook.thrift.payload.ServerRequestPayload _payload, java.util.List _readers, com.facebook.swift.service.ContextChain _chain) { _chain.preRead(); java.util.List_data = _payload.getData(_readers); java.util.Iterator _iterator = _data.iterator(); {{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}} = ({{#field:type}}{{> Type}}{{/field:type}}) _iterator.next(); {{/function:args}} _chain.postRead(_data); reactor.core.publisher.Mono _internalResponse = _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); return _internalResponse; } {{/service:onewayFunctions}} @java.lang.Override public reactor.core.publisher.Flux singleRequestStreamingResponse(com.facebook.thrift.payload.ServerRequestPayload _payload) { final String _name = _payload.getRequestRpcMetadata().getName(); reactor.core.publisher.Flux _retVal = reactor.core.publisher.Flux.defer(() -> { com.facebook.swift.service.ContextChain _chain; try { _chain = new com.facebook.swift.service.ContextChain(_eventHandlers, _name, _payload.getRequestContext()); } catch (Throwable _t) { org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(_t.getMessage()); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), null); return reactor.core.publisher.Flux.just(_serverResponsePayload); } reactor.core.publisher.Flux _result; try { switch(_name) { {{#service:streamingFunctions}} case "{{function:javaName}}": _result = _handler_{{function:javaName}}.handleStream(_payload, _chain); break; {{/service:streamingFunctions}} default: { {{#service:extends}} _result = super.singleRequestStreamingResponse(_payload); {{/service:extends}} {{^service:extends}} _chain.preRead(); org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.UNKNOWN_METHOD, "no method found with name " + _name); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); return reactor.core.publisher.Flux.just(_serverResponsePayload); {{/service:extends}} } } } catch (org.apache.thrift.TApplicationException _tApplicationException) { com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); return reactor.core.publisher.Flux.just(_serverResponsePayload); } catch (Throwable _t) { _result = reactor.core.publisher.Flux.error(_t); } return _result; }); if (com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _retVal = _retVal.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _retVal; } @java.lang.Override public reactor.core.publisher.Mono singleRequestSingleResponse(com.facebook.thrift.payload.ServerRequestPayload _payload) { final String _name = _payload.getRequestRpcMetadata().getName(); reactor.core.publisher.Mono _retVal = reactor.core.publisher.Mono.defer(() -> { com.facebook.swift.service.ContextChain _chain; try { _chain = new com.facebook.swift.service.ContextChain(_eventHandlers, _name, _payload.getRequestContext()); } catch (Throwable _t) { org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(_t.getMessage()); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), null); return reactor.core.publisher.Mono.just(_serverResponsePayload); } reactor.core.publisher.Mono _result; try { switch (_name) { {{#service:requestResponseFunctions}} case "{{function:javaName}}": _result = _do{{function:javaName}}(_delegate, _payload, _{{function:javaName}}Readers, _chain); break; {{/service:requestResponseFunctions}} default: { {{#service:extends}} _result = super.singleRequestSingleResponse(_payload); {{/service:extends}} {{^service:extends}} _chain.preRead(); org.apache.thrift.TApplicationException _tApplicationException = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.UNKNOWN_METHOD, "no method found with name " + _name); com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); return reactor.core.publisher.Mono.just(_serverResponsePayload); {{/service:extends}} } } } catch (org.apache.thrift.TApplicationException _tApplicationException) { com.facebook.thrift.payload.ServerResponsePayload _serverResponsePayload = com.facebook.thrift.util.RpcPayloadUtil.fromTApplicationException(_tApplicationException, _payload.getRequestRpcMetadata(), _chain); return reactor.core.publisher.Mono.just(_serverResponsePayload); } catch (Throwable _t) { _result = reactor.core.publisher.Mono.error(_t); } return _result; }); if (com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _retVal = _retVal.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _retVal; } @java.lang.Override public reactor.core.publisher.Mono singleRequestNoResponse(com.facebook.thrift.payload.ServerRequestPayload _payload) { final String _name = _payload.getRequestRpcMetadata().getName(); reactor.core.publisher.Mono _retVal = reactor.core.publisher.Mono.defer(() -> { com.facebook.swift.service.ContextChain _chain; try { _chain = new com.facebook.swift.service.ContextChain(_eventHandlers, _name, _payload.getRequestContext()); } catch (Throwable _t) { return reactor.core.publisher.Mono.error(_t); } reactor.core.publisher.Mono _result; try { switch (_name) { {{#service:onewayFunctions}} case "{{function:javaName}}": _result = _do{{function:javaName}}(_delegate, _payload, _{{function:javaName}}Readers, _chain); break; {{/service:onewayFunctions}} default: { {{#service:extends}} _result = super.singleRequestNoResponse(_payload); {{/service:extends}} {{^service:extends}} _result = reactor.core.publisher.Mono.error(new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.UNKNOWN_METHOD, "no method found with name " + _name)); {{/service:extends}} } } } catch (Throwable _t) { _result = reactor.core.publisher.Mono.error(_t); } return _result; }); if (com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _retVal = _retVal.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _retVal; } public java.util.Map getMethodMap() { {{#service:extends}} java.util.Map _combined = new java.util.HashMap(); _combined.putAll(_methodMap); _combined.putAll(super.getMethodMap()); return _combined; {{/service:extends}} {{^service:extends}} return _methodMap; {{/service:extends}} } } )__FBTHRIFT_TAG__", // java/Service.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.swift.codec.*; import com.facebook.swift.codec.ThriftField.Requiredness; import com.facebook.swift.service.*; import com.facebook.thrift.client.*; import com.google.common.util.concurrent.ListenableFuture; import java.io.*; import java.util.*; import reactor.core.publisher.Mono; @SwiftGenerated @com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}") public interface {{service:javaCapitalName}} extends java.io.Closeable, com.facebook.thrift.util.BlockingService{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}{{/service:extends}} { static com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}> serverHandlerBuilder({{service:javaCapitalName}} _serverImpl) { return new com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}>(_serverImpl) { @java.lang.Override public com.facebook.thrift.server.RpcServerHandler build() { return new {{service:javaCapitalName}}RpcServerHandler(impl, eventHandlers); } }; } static com.facebook.thrift.client.ClientBuilder<{{service:javaCapitalName}}> clientBuilder() { return new ClientBuilder<{{service:javaCapitalName}}>() { @java.lang.Override public {{service:javaCapitalName}} build(Mono rpcClientMono) { {{service:javaCapitalName}}.Reactive _delegate = new {{service:javaCapitalName}}ReactiveClient(protocolId, rpcClientMono, headersMono, persistentHeadersMono); return new {{service:javaCapitalName}}ReactiveBlockingWrapper(_delegate); } }; } @com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}") public interface Async extends java.io.Closeable, com.facebook.thrift.util.AsyncService{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}.Async{{/service:extends}} { static com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}.Async> serverHandlerBuilder({{service:javaCapitalName}}.Async _serverImpl) { return new com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}.Async>(_serverImpl) { @java.lang.Override public com.facebook.thrift.server.RpcServerHandler build() { return new {{service:javaCapitalName}}RpcServerHandler(impl, eventHandlers); } }; } static com.facebook.thrift.client.ClientBuilder<{{service:javaCapitalName}}.Async> clientBuilder() { return new ClientBuilder<{{service:javaCapitalName}}.Async>() { @java.lang.Override public {{service:javaCapitalName}}.Async build(Mono rpcClientMono) { {{service:javaCapitalName}}.Reactive _delegate = new {{service:javaCapitalName}}ReactiveClient(protocolId, rpcClientMono, headersMono, persistentHeadersMono); return new {{service:javaCapitalName}}ReactiveAsyncWrapper(_delegate); } }; } @java.lang.Override void close(); {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}); default ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } default ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{^last?}} {{/last?}} {{/service:singleRequestFunctions}} {{#service:interactions}} @com.facebook.swift.service.ThriftInteraction("{{service:name}}") public interface {{service:name}} extends java.io.Closeable { {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}); ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions); ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions); {{/service:singleRequestFunctions}} @java.lang.Override void close(); } public {{service:name}} create{{service:name}}(); {{^last?}} {{/last?}} {{/service:interactions}} } @java.lang.Override void close(); {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException; default {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { throw new UnsupportedOperationException(); } default ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { throw new UnsupportedOperationException(); } {{/service:singleRequestFunctions}} @com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}") interface Reactive extends reactor.core.Disposable, com.facebook.thrift.util.ReactiveService{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}.Reactive{{/service:extends}} { static com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}.Reactive> serverHandlerBuilder({{service:javaCapitalName}}.Reactive _serverImpl) { return new com.facebook.thrift.server.RpcServerHandlerBuilder<{{service:javaCapitalName}}.Reactive>(_serverImpl) { @java.lang.Override public com.facebook.thrift.server.RpcServerHandler build() { return new {{service:javaCapitalName}}RpcServerHandler(impl, eventHandlers); } }; } static com.facebook.thrift.client.ClientBuilder<{{service:javaCapitalName}}.Reactive> clientBuilder() { return new ClientBuilder<{{service:javaCapitalName}}.Reactive>() { @java.lang.Override public {{service:javaCapitalName}}.Reactive build(Mono rpcClientMono) { return new {{service:javaCapitalName}}ReactiveClient(protocolId, rpcClientMono, headersMono, persistentHeadersMono); } }; } {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); default reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } default reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); default reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } default reactor.core.publisher.Flux StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} {{#service:sinkFunctions}} {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads); default {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads, RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } default {{#function:return_type}}{{> SinkWrapperReturnType}}{{/function:return_type}} {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads, RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:sinkFunctions}} {{#service:interactions}} @com.facebook.swift.service.ThriftInteraction("{{service:name}}") public interface {{service:name}} extends reactor.core.Disposable { {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(^last?}},{{/last?}}{{/function:args}}); reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions); reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions); {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); default reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } default reactor.core.publisher.Flux StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} @java.lang.Override void dispose(); } public {{service:name}} create{{service:name}}(); {{^last?}} {{/last?}} {{/service:interactions}} } {{#service:interactions}} @com.facebook.swift.service.ThriftInteraction("{{service:name}}") public interface {{service:name}} extends java.io.Closeable { {{#service:singleRequestFunctions}} @ThriftMethod(value = "{{function:name}}"{{#function:oneway?}}, oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}}, exception = { {{/first?}} @ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}} }{{/last?}}{{/function:exceptions}}) {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException; {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException; ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}} @com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException; {{/service:singleRequestFunctions}} @java.lang.Override void close(); } {{service:name}} create{{service:name}}(); {{^last?}} {{/last?}} {{/service:interactions}} } )__FBTHRIFT_TAG__", // java/SetterName.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}set{{field:javaCapitalName}} )__FBTHRIFT_TAG__", // java/SinkResponseGeneric.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:sink?}}{{! }}{{#function:sink_has_first_response?}}com.facebook.thrift.model.StreamResponse<{{! }}{{#function:sink_first_response_type}}{{ >BoxedType}}{{/function:sink_first_response_type}},{{! }}{{#function:sink_final_response_type}}{{ >BoxedType}}{{/function:sink_final_response_type}}>{{! }}{{/function:sink_has_first_response?}}{{! }}{{^function:sink_has_first_response?}}{{! }}{{#function:sink_final_response_type}}com.facebook.thrift.model.StreamResponseBoxedType}}>{{/function:sink_final_response_type }}{{! }}{{/function:sink_has_first_response?}}{{! }}{{/function:sink?}} )__FBTHRIFT_TAG__", // java/SinkReturnType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:sink?}}{{! }}{{#function:sink_has_first_response?}}reactor.core.publisher.FluxBoxedType}}{{/function:sink_first_response_type}},{{! }}{{#function:sink_final_response_type}}{{ >BoxedType}}{{/function:sink_final_response_type}}>>{{! }}{{/function:sink_has_first_response?}}{{! }}{{^function:sink_has_first_response?}}{{! }}{{#function:sink_final_response_type}}reactor.core.publisher.Mono<{{ >BoxedType}}>{{/function:sink_final_response_type}}{{! }}{{/function:sink_has_first_response?}}{{! }}{{/function:sink?}} )__FBTHRIFT_TAG__", // java/SinkWrapperReturnType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:sink?}}{{! }}{{#function:sink_has_first_response?}}reactor.core.publisher.FluxBoxedType}}{{/function:sink_first_response_type}},{{! }}{{#function:sink_final_response_type}}{{ >BoxedType}}{{/function:sink_final_response_type}}>>>{{! }}{{/function:sink_has_first_response?}}{{! }}{{^function:sink_has_first_response?}}{{! }}{{#function:sink_final_response_type}}reactor.core.publisher.MonoBoxedType}}>>{{/function:sink_final_response_type}}{{! }}{{/function:sink_has_first_response?}}{{! }}{{/function:sink?}} )__FBTHRIFT_TAG__", // java/StreamResponseGeneric.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}com.facebook.thrift.model.StreamResponse<{{! }}{{#function:stream_first_response_type}}{{ >BoxedType}}{{/function:stream_first_response_type}},{{! }}{{#function:stream_elem_type}}{{ >BoxedType}}{{/function:stream_elem_type}}>{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}com.facebook.thrift.model.StreamResponseBoxedType}}>{{/function:stream_elem_type}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // java/StreamReturnType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}com.facebook.thrift.model.StreamResponse<{{! }}{{#function:stream_first_response_type}}{{ >BoxedType}}{{/function:stream_first_response_type}},{{! }}{{#function:stream_elem_type}}{{ >BoxedType}}{{/function:stream_elem_type}}>{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >BoxedType}}{{/function:stream_elem_type}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // java/Struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{struct:javaPackage}}; import com.facebook.swift.codec.*; import com.facebook.swift.codec.ThriftField.Requiredness; import com.facebook.swift.codec.ThriftField.Recursiveness; import com.google.common.collect.*; import java.util.*; import javax.annotation.Nullable; import org.apache.thrift.*; import org.apache.thrift.transport.*; import org.apache.thrift.protocol.*; import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.MoreObjects.ToStringHelper; @SwiftGenerated {{#struct:asBean?}} @com.facebook.swift.codec.ThriftStruct("{{struct:name}}"){{> common/ObjectCustomAnnotation}} {{/struct:asBean?}} {{^struct:asBean?}} @com.facebook.swift.codec.ThriftStruct(value="{{struct:name}}", builder={{struct:javaCapitalName}}.Builder.class){{> common/ObjectCustomAnnotation}} {{/struct:asBean?}} public final class {{struct:javaCapitalName}} implements com.facebook.thrift.payload.ThriftSerializable { {{> struct/ThriftConstructor}} {{> struct/StructBuilder}} {{> struct/AdapterDefinition}} public static final Map NAMES_TO_IDS = new HashMap(); public static final Map THRIFT_NAMES_TO_IDS = new HashMap(); public static final Map FIELD_METADATA = new HashMap<>(); private static final TStruct STRUCT_DESC = new TStruct("{{struct:name}}"); {{#struct:fields}}{{! }}{{#struct:asBean?}} {{#field:isSensitive?}} @org.apache.thrift.annotations.Sensitive {{/field:isSensitive?}} private {{> FieldType}} {{field:javaName}}; public static final int _{{field:javaAllCapsName}} = {{field:key}}; private static final TField {{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/struct:asBean?}}{{! }}{{^struct:asBean?}} {{#field:isSensitive?}} @org.apache.thrift.annotations.Sensitive {{/field:isSensitive?}} {{#field:javaAnnotations?}}{{field:javaAnnotations}} {{/field:javaAnnotations?}}private {{^struct:isBigStruct?}}{{^struct:hasWrapper?}}final {{/struct:hasWrapper?}}{{/struct:isBigStruct?}}{{> FieldType}} {{field:javaName}}; public static final int _{{field:javaAllCapsName}} = {{field:key}}; private static final TField {{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/struct:asBean?}} {{/struct:fields}}{{! }}static { {{#struct:fields}} NAMES_TO_IDS.put("{{field:javaName}}", {{field:key}}); THRIFT_NAMES_TO_IDS.put("{{field:name}}", {{field:key}}); FIELD_METADATA.put({{field:key}}, {{field:javaTFieldName}}); {{/struct:fields}} {{#struct:thrift_uri}} com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( new com.facebook.thrift.type.UniversalName("{{struct:thrift_uri}}"), {{struct:javaCapitalName}}.class, {{struct:javaCapitalName}}::read0)); {{/struct:thrift_uri}} }{{! }}{{#struct:fields}} {{> struct/FieldGetter}}{{! }}{{#struct:asBean?}} {{> struct/FieldSetter}} {{/struct:asBean?}}{{! }} {{/struct:fields}} {{> struct/StructToString}} {{> struct/StructEquals}} {{> struct/StructHashCode}} {{> struct/StructRead}} {{> struct/StructWrite}} {{^struct:asBean?}} {{> Default}} {{/struct:asBean?}} } )__FBTHRIFT_TAG__", // java/TType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{>TType}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:void?}}VOID{{/type:void?}}{{! }}{{#type:string?}}STRING{{/type:string?}}{{! }}{{#type:binary?}}STRING{{/type:binary?}}{{! }}{{#type:bool?}}BOOL{{/type:bool?}}{{! }}{{#type:byte?}}BYTE{{/type:byte?}}{{! }}{{#type:i16?}}I16{{/type:i16?}}{{! }}{{#type:i32?}}I32{{/type:i32?}}{{! }}{{#type:i64?}}I64{{/type:i64?}}{{! }}{{#type:float?}}FLOAT{{/type:float?}}{{! }}{{#type:double?}}DOUBLE{{/type:double?}}{{! }}{{#type:struct?}}STRUCT{{/type:struct?}}{{! }}{{#type:enum?}}I32{{/type:enum?}}{{! }}{{#type:list?}}LIST{{/type:list?}}{{! }}{{#type:set?}}SET{{/type:set?}}{{! }}{{#type:map?}}MAP{{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/ThriftBoxedType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:typedef?}}{{! }}{{#type:hasAdapter?}}{{! }}{{#type:typedef_type}}{{type:setAdapter}}{{> ThriftBoxedType}}{{type:unsetAdapter}}{{/type:typedef_type}}{{! }}{{/type:hasAdapter?}}{{! }}{{^type:hasAdapter?}}{{! }}{{#type:isAdapterSet?}}{{! }}{{#type:typedef_type}}{{type:setAdapter}}{{> ThriftBoxedType}}{{/type:typedef_type}}{{! }}{{/type:isAdapterSet?}}{{! }}{{^type:isAdapterSet?}}{{! }}{{#type:typedef_type}}{{> ThriftBoxedType}}{{/type:typedef_type}}{{! }}{{/type:isAdapterSet?}}{{! }}{{/type:hasAdapter?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:void?}}Void{{/type:void?}}{{! }}{{#type:bool?}}Boolean{{/type:bool?}}{{! }}{{#type:byte?}}Byte{{/type:byte?}}{{! }}{{#type:i16?}}Short{{/type:i16?}}{{! }}{{#type:i32?}}Integer{{/type:i32?}}{{! }}{{#type:i64?}}Long{{/type:i64?}}{{! }}{{#type:double?}}Double{{/type:double?}}{{! }}{{#type:float?}}Float{{/type:float?}}{{! }}{{#type:string?}}{{! }}{{#type:isBinaryString?}}{{#type:isAdapterSet?}}io.netty.buffer.ByteBuf{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}{{#field:hasAdapter?}}io.netty.buffer.ByteBuf{{/field:hasAdapter?}}{{^field:hasAdapter?}}byte[]{{/field:hasAdapter?}}{{/type:isAdapterSet?}}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}String{{/type:isBinaryString?}}{{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{#type:isAdapterSet?}}io.netty.buffer.ByteBuf{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}{{#field:hasAdapter?}}io.netty.buffer.ByteBuf{{/field:hasAdapter?}}{{^field:hasAdapter?}}byte[]{{/field:hasAdapter?}}{{/type:isAdapterSet?}}{{/type:binary?}}{{! }}{{#type:map?}}{{! }}Map<{{#type:key_type}}{{> ThriftBoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> ThriftBoxedType}}{{/type:value_type}}>{{! }}{{/type:map?}}{{! }}{{#type:list?}}{{! }}List<{{#type:list_elem_type}}{{> ThriftBoxedType}}{{/type:list_elem_type}}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}Set<{{#type:set_elem_type}}{{> ThriftBoxedType}}{{/type:set_elem_type}}>{{! }}{{/type:set?}}{{! }}{{#type:struct?}}{{! }}{{#type:struct}}{{struct:javaPackage}}.{{struct:javaCapitalName}}{{/type:struct}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#type:enum}}{{enum:javaPackage}}.{{enum:javaCapitalName}}{{/type:enum}}{{! }}{{/type:enum?}}{{! }}{{/type:typedef?}}{{! }}{{/type:javaType}})__FBTHRIFT_TAG__", // java/ThriftFieldAnnotation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}@com.facebook.swift.codec.ThriftField(value={{field:key}}, name="{{field:name}}", {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}requiredness={{> Requiredness}}{{! }}{{#field:recursive?}}, isRecursive=Recursiveness.TRUE{{/field:recursive?}}) )__FBTHRIFT_TAG__", // java/ThriftFieldType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:optional?}}{{#field:type}}{{#type:hasAdapter?}}{{> AdaptedBoxedType}}{{/type:hasAdapter?}}{{^type:hasAdapter?}}{{> BoxedType}}{{/type:hasAdapter?}} {{/field:type}}{{/field:optional?}}{{! }}{{^field:optional?}}{{#field:type}}{{> Type}}{{/field:type}}{{/field:optional?}} )__FBTHRIFT_TAG__", // java/ThriftType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:typedef?}}{{! }}{{#type:hasAdapter?}}{{! }}{{#type:typedef_type}}{{type:setAdapter}}{{> ThriftType}}{{type:unsetAdapter}}{{/type:typedef_type}}{{! }}{{/type:hasAdapter?}}{{! }}{{^type:hasAdapter?}}{{! }}{{#type:isAdapterSet?}}{{! }}{{#type:typedef_type}}{{type:setAdapter}}{{> ThriftType}}{{/type:typedef_type}}{{! }}{{/type:isAdapterSet?}}{{! }}{{^type:isAdapterSet?}}{{! }}{{#type:typedef_type}}{{> ThriftType}}{{/type:typedef_type}}{{! }}{{/type:isAdapterSet?}}{{! }}{{/type:hasAdapter?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{> Type}}{{! }}{{/type:typedef?}}{{! }}{{/type:javaType}})__FBTHRIFT_TAG__", // java/ToThriftEnd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasTypeAdapter?}}{{! }}){{! }}{{/field:hasTypeAdapter?}}{{! }}{{#field:hasFieldAdapter?}}{{! }}){{! }}{{/field:hasFieldAdapter?}}{{! }}{{#field:hasWrapper?}}{{! }}){{! }}{{/field:hasWrapper?}})__FBTHRIFT_TAG__", // java/ToThriftStart.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#field:hasTypeAdapter?}}{{! }}__{{#field:type}}{{type:name}}{{/field:type}}_Adapter.toThrift({{! }}{{/field:hasTypeAdapter?}}{{! }}{{#field:hasFieldAdapter?}}{{! }}_{{field:javaName}}_Adapter.toThrift({{! }}{{/field:hasFieldAdapter?}}{{! }}{{#field:hasWrapper?}}{{! }}_{{field:javaName}}_Wrapper.toThrift({{! }}{{/field:hasWrapper?}})__FBTHRIFT_TAG__", // java/Type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:javaType}}{{! }}{{type:javaType}}{{! }}{{/type:javaType}}{{! }}{{^type:javaType}}{{! }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{> Type}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:void?}}void{{/type:void?}}{{! }}{{#type:bool?}}boolean{{/type:bool?}}{{! }}{{#type:byte?}}byte{{/type:byte?}}{{! }}{{#type:i16?}}short{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}long{{/type:i64?}}{{! }}{{#type:double?}}double{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{^type:numeric_or_void?}}{{^type:typedef?}}{{! }}{{> BoxedType}}{{! }}{{/type:typedef?}}{{/type:numeric_or_void?}}{{! }}{{/type:typedef?}}{{! }}{{/type:javaType}} )__FBTHRIFT_TAG__", // java/TypeCap.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{>TypeCap}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:void?}}Void{{/type:void?}}{{! }}{{#type:string?}}String{{/type:string?}}{{! }}{{#type:binary?}}Binary{{/type:binary?}}{{! }}{{#type:bool?}}Bool{{/type:bool?}}{{! }}{{#type:byte?}}Byte{{/type:byte?}}{{! }}{{#type:i16?}}I16{{/type:i16?}}{{! }}{{#type:i32?}}I32{{/type:i32?}}{{! }}{{#type:i64?}}I64{{/type:i64?}}{{! }}{{#type:float?}}Float{{/type:float?}}{{! }}{{#type:double?}}Double{{/type:double?}}{{! }}{{#type:struct?}}Struct{{/type:struct?}}{{! }}{{#type:enum?}}I32{{/type:enum?}}{{! }}{{#type:list?}}List{{/type:list?}}{{! }}{{#type:set?}}Set{{/type:set?}}{{! }}{{#type:map?}}Map{{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/TypeList.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{program:javaPackage}}; import com.facebook.thrift.type.TypeList; import java.util.ArrayList; import java.util.List; public class __fbthrift_TypeList_{{program:typeListHash}} implements TypeList { private static List list = new ArrayList<>(); private static void add(String uri, String className) { list.add(new TypeList.TypeMapping(uri, className)); } {{#program:typeList}} private static void addToList{{typeList:index}}() { {{#typeList:batch}} add("{{typeList:uri}}", "{{typeList:className}}"); {{/typeList:batch}} } {{/program:typeList}} {{#program:typeList}} static { addToList{{typeList:index}}(); } {{/program:typeList}} @java.lang.Override public List getTypes() { return list; } } )__FBTHRIFT_TAG__", // java/TypeReader.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{> TypeReader }}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:list?}}Readers.listReader({{! }}{{#type:list_elem_type}}{{> TypeReader }}{{/type:list_elem_type}}{{ }}){{/type:list?}}{{ }}{{#type:map?}}Readers.mapReader({{! }}{{#type:key_type}}{{> TypeReader }}{{/type:key_type}},{{#type:value_type}}{{> TypeReader }}{{/type:value_type}}{{ }}){{/type:map?}}{{ }}{{#type:set?}}Readers.setReader({{! }}{{#type:set_elem_type}}{{> TypeReader }}{{/type:set_elem_type}}{{ }}){{/type:set?}}{{ }}{{#type:struct?}}Readers.wrap({{> BoxedType}}.asReader()){{/type:struct?}}{{! }}{{#type:enum?}}Readers.wrap({{> BoxedType}}.asReader()){{/type:enum?}}{{! }}{{#type:binary?}}Readers.binaryReader(){{/type:binary?}}{{! }}{{#type:string?}}Readers.stringReader(){{/type:string?}}{{! }}{{#type:bool?}}Readers.booleanReader(){{/type:bool?}}{{! }}{{#type:byte?}}Readers.byteReader(){{/type:byte?}}{{! }}{{#type:i16?}}Readers.i16Reader(){{/type:i16?}}{{! }}{{#type:i32?}}Readers.i32Reader(){{/type:i32?}}{{! }}{{#type:i64?}}Readers.i64Reader(){{/type:i64?}}{{! }}{{#type:float?}}Readers.floatReader(){{/type:float?}}{{! }}{{#type:double?}}Readers.doubleReader(){{/type:double?}}{{! }}{{#type:void?}}Readers.voidReader(){{/type:void?}}{{! }}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // java/Union.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{struct:javaPackage}}; import com.facebook.swift.codec.*; import com.facebook.swift.codec.ThriftField.Requiredness; import com.facebook.swift.codec.ThriftField.Recursiveness; import java.util.*; import org.apache.thrift.*; import org.apache.thrift.transport.*; import org.apache.thrift.protocol.*; import static com.google.common.base.MoreObjects.toStringHelper; @SwiftGenerated @ThriftUnion("{{struct:name}}"){{> common/ObjectCustomAnnotation}} public final class {{struct:javaCapitalName}} implements com.facebook.thrift.payload.ThriftSerializable { {{> struct/AdapterDefinition}} private static final boolean allowNullFieldValues = System.getProperty("thrift.union.allow-null-field-values", "false").equalsIgnoreCase("true"); private static final TStruct STRUCT_DESC = new TStruct("{{struct:name}}"); private static final Map NAMES_TO_IDS = new HashMap(); public static final Map THRIFT_NAMES_TO_IDS = new HashMap(); private static final Map FIELD_METADATA = new HashMap<>(); private static final {{struct:javaCapitalName}} _DEFAULT = new {{struct:javaCapitalName}}(); {{#struct:fields}} public static final int _{{field:javaAllCapsName}} = {{field:key}}; private static final TField {{field:javaTFieldName}} = new TField("{{#field:FieldNameUnmangled?}}{{field:name}}{{/field:FieldNameUnmangled?}}{{^field:FieldNameUnmangled?}}{{field:javaName}}{{/field:FieldNameUnmangled?}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}}); {{/struct:fields}} static { {{#struct:fields}} NAMES_TO_IDS.put("{{field:javaName}}", {{field:key}}); THRIFT_NAMES_TO_IDS.put("{{field:name}}", {{field:key}}); FIELD_METADATA.put({{field:key}}, {{field:javaTFieldName}}); {{/struct:fields}} {{#struct:thrift_uri}} com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type( new com.facebook.thrift.type.UniversalName("{{struct:thrift_uri}}"), {{struct:javaCapitalName}}.class, {{struct:javaCapitalName}}::read0)); {{/struct:thrift_uri}} } private java.lang.Object value; private short id; public static {{struct:javaCapitalName}} from(int _id, java.lang.Object _field) { return from((short) _id, _field); } public static {{struct:javaCapitalName}} from(short _id, java.lang.Object _field) { java.util.Objects.requireNonNull(_field); if (!FIELD_METADATA.containsKey(Integer.valueOf(_id))) { throw new java.lang.IllegalArgumentException("unknown field " + _id); } {{struct:javaCapitalName}} _u = new {{struct:javaCapitalName}}(); try { switch(_id) { {{#struct:fields}} case {{field:key}}: _u.id = _id; _u.value = ({{> FieldType}}) _field; return _u; {{/struct:fields}} default: throw new IllegalArgumentException("invalid type " + _field.getClass().getName() + " for field " + _id); } } catch (java.lang.Exception t) { throw new IllegalArgumentException("invalid type " + _field.getClass().getName() + " for field " + _id); } } {{> union/UnionBuilder}} {{^struct:unionFieldTypeUnique?}}{{! TODO: remove unionFieldTypeUnique related check and use builder pattern If union fields are not unique, we cannot generate thrift constructors, therefore setters are needed. }}{{> union/UnionSetter}}{{! }}{{/struct:unionFieldTypeUnique?}} {{#struct:fields}} {{> ThriftFieldAnnotation}} public {{> FieldType}} {{> GetterName}}() { if (this.id != {{field:key}}) { throw new IllegalStateException("Not a {{field:name}} element!"); } return ({{> FieldType}}) value; } public boolean isSet{{field:javaCapitalName}}() { return this.id == {{field:key}}; } {{/struct:fields}} @ThriftUnionId public short getThriftId() { return this.id; } public String getThriftName() { TField tField = (TField) FIELD_METADATA.get((int) this.id); if (tField == null) { return "null"; } else { return tField.name; } } public void accept(Visitor visitor) { {{#struct:fields}} if (isSet{{field:javaCapitalName}}()) { visitor.visit{{field:javaCapitalName}}({{> GetterName}}()); return; } {{/struct:fields}} } @java.lang.Override public String toString() { return toStringHelper(this) .add("value", value) .add("id", id) .add("name", getThriftName()) .add("type", value == null ? "" : value.getClass().getSimpleName()) .toString(); } @java.lang.Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } {{struct:javaCapitalName}} other = ({{struct:javaCapitalName}})o; return Objects.equals(this.id, other.id) && Objects.deepEquals(this.value, other.value); } @java.lang.Override public int hashCode() { return Arrays.deepHashCode(new java.lang.Object[] { id, value, }); } public interface Visitor { {{#struct:fields}} void visit{{field:javaCapitalName}}({{> FieldType}} {{field:javaName}}); {{/struct:fields}} } {{> union/UnionWrite}} {{> union/UnionRead}} public static {{struct:javaCapitalName}} defaultInstance() { return _DEFAULT; } } )__FBTHRIFT_TAG__", // java/Utf8Validation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Facebook, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:strings_compat?}}{{! }}{{#field:coding_error_action_report?}}com.facebook.thrift.compatibility.Utf8CodingErrorAction.REPORT{{/field:coding_error_action_report?}}{{! }}{{/field:strings_compat?}})__FBTHRIFT_TAG__", // java/WriteNestedType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#type:isAdapterSet?}}{{! }}__{{type:getTypeName}}_Adapter.toThrift({{! }}{{/type:isAdapterSet?}}{{! }}_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}{{! }}{{#type:isAdapterSet?}}{{! }}){{! }}{{/type:isAdapterSet?}})__FBTHRIFT_TAG__", // java/WriteRequestType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> WriteRequestType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> WriteRequestType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> WriteRequestType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}oprot.writeSetBegin(new TSet(TType.{{#type:set_elem_type}}{{> TType}}{{/type:set_elem_type}}, _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:set_elem_type}}{{> Type}}{{/type:set_elem_type}} _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{field:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:set_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteRequestType}} {{/type:isContainer?}}{{/type:set_elem_type}} } oprot.writeSetEnd();{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}oprot.writeListBegin(new TList(TType.{{#type:list_elem_type}}{{> TType}}{{/type:list_elem_type}}, _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:list_elem_type}}{{> Type}}{{/type:list_elem_type}} _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{field:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:list_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteRequestType}} {{/type:isContainer?}}{{/type:list_elem_type}} } oprot.writeListEnd();{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}oprot.writeMapBegin(new TMap(TType.{{#type:key_type}}{{> TType}}{{/type:key_type}}, TType.{{#type:value_type}}{{> TType}}{{/type:value_type}}, _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for (Map.Entry<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}> _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.entrySet()) { {{field:setIsNested}}{{! }}{{#type:key_type}}{{type:setIsMapKey}}{{! }}{{#type:isContainer?}}{{! }}{{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteRequestType}} {{/type:isContainer?}}{{/type:key_type}}{{! }}{{#type:value_type}}{{type:setIsMapValue}}{{! }}{{#type:isContainer?}} {{field:nestedDepth++}}{{> WriteRequestType}}{{field:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteRequestType}}{{! }}{{/type:isContainer?}}{{/type:value_type}} } oprot.writeMapEnd();{{! }}{{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#field:isNested?}}_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.write0(oprot); {{/field:isNested?}}{{! }}{{^field:isNested?}}_iter0.write0(oprot);{{/field:isNested?}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#field:isNested?}}oprot.writeI32(_iter{{field:nestedDepth}} == null ? 0 : _iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.getValue()); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI32({{field:javaName}} == null ? 0 : {{field:javaName}}.getValue());{{/field:isNested?}}{{! }}{{/type:enum?}}{{! }}{{#type:binary?}}{{! }}{{#field:isNested?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}})); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}({{field:javaName}}));{{/field:isNested?}}{{! }}{{/type:binary?}}{{! }}{{#type:string?}}{{! }}{{#field:isNested?}}oprot.writeString(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeString({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#field:isNested?}}oprot.writeBool(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeBool({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}{{#field:isNested?}}oprot.writeByte(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeByte({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}{{#field:isNested?}}oprot.writeI16(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI16({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}{{#field:isNested?}}oprot.writeI32(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI32({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}{{#field:isNested?}}oprot.writeI64(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI64({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i64?}}{{! }}{{#type:float?}}{{! }}{{#field:isNested?}}oprot.writeFloat(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeFloat({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#field:isNested?}}oprot.writeDouble(_iter{{field:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeDouble({{field:javaName}});{{/field:isNested?}}{{! }}{{/type:double?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/WriteResponseType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> WriteResponseType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> WriteResponseType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> WriteResponseType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}{{^function:isNested?}}oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.SET_FIELD);{{/function:isNested?}} oprot.writeSetBegin(new TSet(TType.{{#type:set_elem_type}}{{> TType}}{{/type:set_elem_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:set_elem_type}}{{> Type}}{{/type:set_elem_type}} _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{function:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:set_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteResponseType}} {{/type:isContainer?}}{{/type:set_elem_type}} } oprot.writeSetEnd();{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}{{^function:isNested?}}oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.LIST_FIELD);{{/function:isNested?}} oprot.writeListBegin(new TList(TType.{{#type:list_elem_type}}{{> TType}}{{/type:list_elem_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:list_elem_type}}{{> Type}}{{/type:list_elem_type}} _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{function:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:list_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteResponseType}} {{/type:isContainer?}}{{/type:list_elem_type}} } oprot.writeListEnd();{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}{{^function:isNested?}}oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.MAP_FIELD);{{/function:isNested?}} oprot.writeMapBegin(new TMap(TType.{{#type:key_type}}{{> TType}}{{/type:key_type}}, TType.{{#type:value_type}}{{> TType}}{{/type:value_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for (Map.Entry<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}> _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.entrySet()) { {{function:setIsNested}}{{! }}{{#type:key_type}}{{type:setIsMapKey}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteResponseType}} {{/type:isContainer?}}{{/type:key_type}}{{! }}{{#type:value_type}}{{type:setIsMapValue}}{{! }}{{#type:isContainer?}} {{function:nestedDepth++}}{{> WriteResponseType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteResponseType}}{{! }}{{/type:isContainer?}}{{/type:value_type}} } oprot.writeMapEnd();{{! }}{{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#function:isNested?}}_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.write0(oprot); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.STRUCT_FIELD); {{^struct:isUnion?}}{{/struct:isUnion?}}_iter0.write0(oprot);{{/function:isNested?}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#function:isNested?}}oprot.writeI32(_iter{{function:nestedDepth}} == null ? 0 : _iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.getValue()); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.I32_FIELD); oprot.writeI32({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0 == null ? 0 : {{^struct:isUnion?}}{{/struct:isUnion?}}_iter0.getValue());{{/function:isNested?}}{{! }}{{/type:enum?}}{{! }}{{#type:binary?}}{{! }}{{#function:isNested?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}})); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.STRING_FIELD); oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0));{{/function:isNested?}}{{! }}{{/type:binary?}}{{! }}{{#type:string?}}{{! }}{{#function:isNested?}}oprot.writeString(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.STRING_FIELD); oprot.writeString({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#function:isNested?}}oprot.writeBool(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.BOOL_FIELD); oprot.writeBool({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}{{#function:isNested?}}oprot.writeByte(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.BYTE_FIELD); oprot.writeByte({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}{{#function:isNested?}}oprot.writeI16(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.I16_FIELD); oprot.writeI16({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}{{#function:isNested?}}oprot.writeI32(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.I32_FIELD); oprot.writeI32({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}{{#function:isNested?}}oprot.writeI64(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.I64_FIELD); oprot.writeI64({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:i64?}}{{! }}{{#type:float?}}{{! }}{{#function:isNested?}}oprot.writeFloat(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.FLOAT_FIELD); oprot.writeFloat({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#function:isNested?}}oprot.writeDouble(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}} oprot.writeFieldBegin(com.facebook.thrift.util.RpcPayloadUtil.DOUBLE_FIELD); oprot.writeDouble({{^struct:isUnion?}}{{/struct:isUnion?}}_iter0);{{/function:isNested?}}{{! }}{{/type:double?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/WriteSinkPayloadType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> WriteSinkPayloadType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> WriteSinkPayloadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> WriteSinkPayloadType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}oprot.writeSetBegin(new TSet(TType.{{#type:set_elem_type}}{{> TType}}{{/type:set_elem_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:set_elem_type}}{{> Type}}{{/type:set_elem_type}} _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{function:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:set_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteSinkPayloadType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteSinkPayloadType}} {{/type:isContainer?}}{{/type:set_elem_type}} } oprot.writeSetEnd();{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}oprot.writeListBegin(new TList(TType.{{#type:list_elem_type}}{{> TType}}{{/type:list_elem_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for ({{#type:list_elem_type}}{{> Type}}{{/type:list_elem_type}} _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}) { {{function:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:list_elem_type}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteSinkPayloadType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteSinkPayloadType}} {{/type:isContainer?}}{{/type:list_elem_type}} } oprot.writeListEnd();{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}oprot.writeMapBegin(new TMap(TType.{{#type:key_type}}{{> TType}}{{/type:key_type}}, TType.{{#type:value_type}}{{> TType}}{{/type:value_type}}, _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.size())); for (Map.Entry<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}> _iter{{function:nestedDepth}} : _iter{{function:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.entrySet()) { {{function:setIsNested}}{{! }}{{#type:key_type}}{{type:setIsMapKey}}{{! }}{{#type:isContainer?}}{{! }}{{function:nestedDepth++}}{{> WriteSinkPayloadType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteSinkPayloadType}} {{/type:isContainer?}}{{/type:key_type}}{{! }}{{#type:value_type}}{{type:setIsMapValue}}{{! }}{{#type:isContainer?}} {{function:nestedDepth++}}{{> WriteSinkPayloadType}}{{function:nestedDepth--}} {{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{> WriteSinkPayloadType}}{{! }}{{/type:isContainer?}}{{/type:value_type}} } oprot.writeMapEnd();{{! }}{{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#function:isNested?}}_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.write0(oprot); {{/function:isNested?}}{{! }}{{^function:isNested?}}_p.write0(oprot);{{/function:isNested?}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#function:isNested?}}oprot.writeI32(_iter{{function:nestedDepth}} == null ? 0 : _iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}.getValue()); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeI32(_p == null ? 0 : _p.getValue());{{/function:isNested?}}{{! }}{{/type:enum?}}{{! }}{{#type:binary?}}{{! }}{{#function:isNested?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}})); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}(_p));{{/function:isNested?}}{{! }}{{/type:binary?}}{{! }}{{#type:string?}}{{! }}{{#function:isNested?}}oprot.writeString(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeString(_p);{{/function:isNested?}}{{! }}{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#function:isNested?}}oprot.writeBool(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeBool(_p);{{/function:isNested?}}{{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}{{#function:isNested?}}oprot.writeByte(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeByte(_p);{{/function:isNested?}}{{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}{{#function:isNested?}}oprot.writeI16(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeI16(_p);{{/function:isNested?}}{{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}{{#function:isNested?}}oprot.writeI32(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeI32(_p);{{/function:isNested?}}{{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}{{#function:isNested?}}oprot.writeI64(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeI64(_p);{{/function:isNested?}}{{! }}{{/type:i64?}}{{! }}{{#type:float?}}{{! }}{{#function:isNested?}}oprot.writeFloat(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeFloat(_p);{{/function:isNested?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#function:isNested?}}oprot.writeDouble(_iter{{function:nestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{/function:isNested?}}{{! }}{{^function:isNested?}}oprot.writeDouble(_p);{{/function:isNested?}}{{! }}{{/type:double?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // java/WriteType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#type:typedef?}}{{! }}{{type:setTypeName}}{{! }}{{#type:isAdapterSet?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{type:setAdapter}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{type:setAdapter}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{type:setAdapter}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:isAdapterSet?}}{{! }}{{^type:isAdapterSet?}}{{! }}{{#type:isMapKey?}}{{#type:typedef_type}}{{type:setIsMapKey}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapKey?}}{{! }}{{#type:isMapValue?}}{{#type:typedef_type}}{{type:setIsMapValue}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{! }}{{^type:isMapKey?}}{{^type:isMapValue?}}{{#type:typedef_type}}{{> WriteType}}{{/type:typedef_type}}{{/type:isMapValue?}}{{/type:isMapKey?}}{{! }}{{/type:isAdapterSet?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:set?}}oprot.writeSetBegin(new TSet(TType.{{#type:set_elem_type}}{{> TType}}{{/type:set_elem_type}}, _iter{{field:prevNestedDepth}}{{> KeyValue}}.size())); for ({{#type:set_elem_type}}{{> AdaptedType}}{{/type:set_elem_type}} _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{> KeyValue}}) { {{field:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:set_elem_type}}{{! }}{{#type:isContainer?}}{{> WriteTypeAdapter}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> WriteType}}{{! }}{{/type:isContainer?}}{{/type:set_elem_type}} } oprot.writeSetEnd();{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}oprot.writeListBegin(new TList(TType.{{#type:list_elem_type}}{{> TType}}{{/type:list_elem_type}}, _iter{{field:prevNestedDepth}}{{> KeyValue}}.size())); for ({{#type:list_elem_type}}{{> AdaptedType}}{{/type:list_elem_type}} _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{> KeyValue}}) { {{field:setIsNested}}{{type:setIsNotMap}}{{! }}{{#type:list_elem_type}}{{! }}{{#type:isContainer?}}{{> WriteTypeAdapter}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> WriteType}}{{! }}{{/type:isContainer?}}{{/type:list_elem_type}} } oprot.writeListEnd();{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}oprot.writeMapBegin(new TMap(TType.{{#type:key_type}}{{> TType}}{{/type:key_type}}, TType.{{#type:value_type}}{{> TType}}{{/type:value_type}}, _iter{{field:prevNestedDepth}}{{> KeyValue}}.size())); for (Map.Entry<{{#type:key_type}}{{> BoxedType}}{{/type:key_type}}, {{#type:value_type}}{{> BoxedType}}{{/type:value_type}}> _iter{{field:nestedDepth}} : _iter{{field:prevNestedDepth}}{{> KeyValue}}.entrySet()) { {{field:setIsNested}}{{! }}{{#type:key_type}}{{type:setIsMapKey}}{{! }}{{#type:isContainer?}}{{> WriteTypeAdapter}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> WriteType}}{{! }}{{/type:isContainer?}}{{/type:key_type}} {{! }}{{#type:value_type}}{{type:setIsMapValue}}{{! }}{{#type:isContainer?}}{{> WriteTypeAdapter}}{{/type:isContainer?}}{{! }}{{^type:isContainer?}}{{#type:hasAdapter?}}{{type:setAdapter}}{{/type:hasAdapter?}}{{> WriteType}}{{! }}{{/type:isContainer?}}{{/type:value_type}} } oprot.writeMapEnd();{{! }}{{/type:map?}}{{! }}{{#type:struct?}}{{! }}{{#field:isNested?}}{{> WriteNestedType}}.write0(oprot);{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}{{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}}.write0(oprot);{{/field:isNested?}}{{! }}{{/type:struct?}}{{! }}{{#type:enum?}}{{! }}{{#field:isNested?}}oprot.writeI32(_iter{{field:nestedDepth}} == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue({{> WriteNestedType}}));{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI32({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}} == null ? 0 : com.facebook.thrift.util.EnumUtil.getValue({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}}));{{/field:isNested?}}{{! }}{{/type:enum?}}{{! }}{{#type:binary?}}{{! }}{{#field:isNested?}}{{! }}{{^field:hasAdapterOrWrapper?}}{{#type:isAdapterSet?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{> WriteNestedType}});{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}({{> WriteNestedType}}));{{/type:isAdapterSet?}}{{/field:hasAdapterOrWrapper?}}{{! }}{{#field:hasAdapterOrWrapper?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{> WriteNestedType}});{{/field:hasAdapterOrWrapper?}}{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}{{! }}{{^field:hasAdapterOrWrapper?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}({{^struct:isUnion?}}this.{{/struct:isUnion?}}{{field:javaName}}));{{/field:hasAdapterOrWrapper?}}{{! }}{{#field:hasAdapterOrWrapper?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{field:javaName}});{{/field:hasAdapterOrWrapper?}}{{! }}{{/field:isNested?}}{{! }}{{/type:binary?}}{{! }}{{#type:string?}}{{! }}{{#field:isNested?}}{{! }}{{#type:isBinaryString?}}{{! }}{{^field:hasAdapterOrWrapper?}}{{#type:isAdapterSet?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{> WriteNestedType}});{{/type:isAdapterSet?}}{{^type:isAdapterSet?}}oprot.writeBinary(java.nio.ByteBuffer.wrap({{> WriteNestedType}}));{{/type:isAdapterSet?}}{{/field:hasAdapterOrWrapper?}}{{! }}{{#field:hasAdapterOrWrapper?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{> WriteNestedType}});{{/field:hasAdapterOrWrapper?}}{{! }}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}{{! }}oprot.writeString({{> WriteNestedType}});{{! }}{{/type:isBinaryString?}}{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}{{! }}{{#type:isBinaryString?}}{{! }}{{^field:hasAdapterOrWrapper?}}oprot.writeBinary({{^type:javaType}}java.nio.ByteBuffer.wrap{{/type:javaType}}({{^struct:isUnion?}}this.{{/struct:isUnion?}}{{field:javaName}}));{{/field:hasAdapterOrWrapper?}}{{! }}{{#field:hasAdapterOrWrapper?}}org.apache.thrift.protocol.TProtocolUtil.writeBinary(oprot, {{field:javaName}});{{/field:hasAdapterOrWrapper?}}{{! }}{{/type:isBinaryString?}}{{! }}{{^type:isBinaryString?}}{{! }}oprot.writeString({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{! }}{{/type:isBinaryString?}}{{! }}{{/field:isNested?}}{{! }}{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#field:isNested?}}oprot.writeBool({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeBool({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}{{#field:isNested?}}oprot.writeByte({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeByte({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}{{#field:isNested?}}oprot.writeI16({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI16({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}{{#field:isNested?}}oprot.writeI32({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI32({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}{{#field:isNested?}}oprot.writeI64({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeI64({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:i64?}}{{! }}{{#type:float?}}{{! }}{{#field:isNested?}}oprot.writeFloat({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeFloat({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#field:isNested?}}oprot.writeDouble({{> WriteNestedType}});{{! }}{{/field:isNested?}}{{! }}{{^field:isNested?}}oprot.writeDouble({{^struct:isUnion?}}{{^field:hasAdapterOrWrapper?}}this.{{/field:hasAdapterOrWrapper?}}{{/struct:isUnion?}}{{field:javaName}});{{/field:isNested?}}{{! }}{{/type:double?}}{{! }}{{/type:typedef?}})__FBTHRIFT_TAG__", // java/WriteTypeAdapter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{field:nestedDepth++}}{{! }}{{#type:hasAdapter?}}{{! }}{{type:setAdapter}}{{! }}{{> AdaptedBoxedType}} _iter{{field:nestedDepth}} = __{{type:name}}_Adapter{{! }}.toThrift(_iter{{field:prevNestedDepth}}{{#type:isMapKey?}}.getKey(){{/type:isMapKey?}}{{#type:isMapValue?}}.getValue(){{/type:isMapValue?}}); {{field:nestedDepth++}}{{! }}{{/type:hasAdapter?}}{{! }}{{> WriteType}}{{! }}{{field:nestedDepth--}})__FBTHRIFT_TAG__", // java/common/ObjectCustomAnnotation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#struct:javaAnnotations?}} {{struct:javaAnnotations}} {{/struct:javaAnnotations?}} )__FBTHRIFT_TAG__", // java/deprecated/ServiceAsyncClient.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.nifty.client.RequestChannel; import com.facebook.swift.codec.*; import com.facebook.swift.service.*; import com.facebook.swift.service.metadata.*; import com.facebook.thrift.client.*; import com.facebook.thrift.util.FutureUtil; import com.google.common.util.concurrent.ListenableFuture; import java.io.*; import java.lang.reflect.Method; import java.util.*; import org.apache.thrift.ProtocolId; import reactor.core.publisher.Mono; @SwiftGenerated @Deprecated public class {{service:javaCapitalName}}AsyncClientImpl extends {{^service:extends}}AbstractThriftClient{{/service:extends}}{{#service:extends}}{{service:javaPackage}}.{{service:javaCapitalName}}AsyncClientImpl{{/service:extends}} implements {{service:javaCapitalName}}.Async { // Method Handlers {{#service:singleRequestFunctions}} private ThriftMethodHandler {{function:javaName}}MethodHandler; {{/service:singleRequestFunctions}} // Method Exceptions {{#service:singleRequestFunctions}} private static final Class[] {{function:javaName}}Exceptions = new Class[] { {{#function:exceptions}}{{#field:type}}{{> BoxedType}}.class{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException.class}; {{/service:singleRequestFunctions}} public {{service:javaCapitalName}}AsyncClientImpl( RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { this("{{service:name}}", channel, methods, headers, persistentHeaders, eventHandlers); } public {{service:javaCapitalName}}AsyncClientImpl( String serviceName, RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { {{^service:extends}}super(serviceName, channel, headers, persistentHeaders, eventHandlers);{{/service:extends}}{{#service:extends}}super(serviceName, channel, methods, headers, persistentHeaders, eventHandlers);{{/service:extends}} Map methodHandlerMap = new HashMap<>(); methods.forEach( (key, value) -> { methodHandlerMap.put(key.getName(), value); }); // Set method handlers {{#service:singleRequestFunctions}} {{function:javaName}}MethodHandler = methodHandlerMap.get("{{function:javaName}}"); {{/service:singleRequestFunctions}} } @java.lang.Override public void close() { super.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}}RpcOptions.EMPTY); } @java.lang.Override public ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { return FutureUtil.transform({{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions)); } @java.lang.Override public ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { try { return executeWrapperWithOptions({{function:javaName}}MethodHandler, {{function:javaName}}Exceptions, rpcOptions{{#function:args}}, {{field:javaName}}{{/function:args}}); } catch (Throwable t) { throw new RuntimeTException(t.getMessage(), t); } } {{/service:singleRequestFunctions}} {{#service:interactions}} public {{service:name}} create{{service:name}}() { throw new RuntimeException("create interaction is not supported"); } {{/service:interactions}} } )__FBTHRIFT_TAG__", // java/deprecated/ServiceClient.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.nifty.client.RequestChannel; import com.facebook.swift.codec.*; import com.facebook.swift.service.*; import com.facebook.swift.service.metadata.*; import com.facebook.thrift.client.*; import com.facebook.thrift.util.FutureUtil; import java.io.*; import java.lang.reflect.Method; import java.util.*; import org.apache.thrift.ProtocolId; import reactor.core.publisher.Mono; @SwiftGenerated @Deprecated public class {{service:javaCapitalName}}ClientImpl extends {{^service:extends}}AbstractThriftClient{{/service:extends}}{{#service:extends}}{{service:javaPackage}}.{{service:javaCapitalName}}ClientImpl{{/service:extends}} implements {{service:javaCapitalName}} { // Method Handlers {{#service:singleRequestFunctions}} private ThriftMethodHandler {{function:javaName}}MethodHandler; {{/service:singleRequestFunctions}} // Method Exceptions {{#service:singleRequestFunctions}} private static final Class[] {{function:javaName}}Exceptions = new Class[] { {{#function:exceptions}}{{#field:type}}{{> BoxedType}}.class{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException.class}; {{/service:singleRequestFunctions}} public {{service:javaCapitalName}}ClientImpl( RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { this("{{service:name}}", channel, methods, headers, persistentHeaders, eventHandlers); } protected {{service:javaCapitalName}}ClientImpl( String serviceName, RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { {{^service:extends}}super(serviceName, channel, headers, persistentHeaders, eventHandlers);{{/service:extends}}{{#service:extends}}super(serviceName, channel, methods, headers, persistentHeaders, eventHandlers);{{/service:extends}} Map methodHandlerMap = new HashMap<>(); methods.forEach( (key, value) -> { methodHandlerMap.put(key.getName(), value); }); // Set method handlers {{#service:singleRequestFunctions}} {{function:javaName}}MethodHandler = methodHandlerMap.get("{{function:javaName}}"); {{/service:singleRequestFunctions}} } @java.lang.Override public void close() { super.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:return_type}}{{^type:void?}}return {{/type:void?}}{{/function:return_type}}{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}RpcOptions.EMPTY).getData(); } @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:return_type}}{{^type:void?}}return {{/type:void?}}{{/function:return_type}}{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions).getData(); } @java.lang.Override public ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { try { return FutureUtil.get(executeWrapperWithOptions({{function:javaName}}MethodHandler, {{function:javaName}}Exceptions, rpcOptions{{#function:args}}, {{field:javaName}}{{/function:args}})); } catch (Throwable t) { if (t instanceof org.apache.thrift.TException) { throw (org.apache.thrift.TException) t; } {{#function:exceptions}} if (t instanceof {{#field:type}}{{> BoxedType}}{{/field:type}}) { throw ({{#field:type}}{{> BoxedType}}{{/field:type}}) t; } {{/function:exceptions}} throw new org.apache.thrift.TException(t); } } {{/service:singleRequestFunctions}} {{#service:interactions}} public {{service:name}} create{{service:name}}() { throw new RuntimeException("create interaction is not supported"); } {{/service:interactions}} } )__FBTHRIFT_TAG__", // java/enum/ClosedEnum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{enum:javaPackage}}; import com.facebook.swift.codec.*; import org.apache.thrift.TException; import org.apache.thrift.protocol.TProtocol; @SwiftGenerated public {{#enum:skipEnumNameMap?}}class{{/enum:skipEnumNameMap?}}{{^enum:skipEnumNameMap?}}enum{{/enum:skipEnumNameMap?}} {{enum:javaCapitalName}}{{#enum:skipEnumNameMap?}} extends IntEnum{{/enum:skipEnumNameMap?}} implements com.facebook.thrift.enums.BaseEnum, com.facebook.thrift.payload.ThriftSerializable { {{^enum:skipEnumNameMap?}} {{#enum:values}} {{enum_value:javaConstantName}}({{enum_value:value}}){{^last?}},{{/last?}}{{#last?}};{{/last?}} {{/enum:values}} {{! semicolon here is required for Java Enum definition, see Java Language Spec section 8.9.1 https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9.1}} {{^enum:values}} ; {{/enum:values}} {{/enum:skipEnumNameMap?}} private final int value; {{enum:javaCapitalName}}(int value) { this.value = value; } {{#enum:skipEnumNameMap?}} @java.lang.Override {{/enum:skipEnumNameMap?}} @ThriftEnumValue public int getValue() { return value; } {{#enum:skipEnumNameMap?}} @ThriftIntEnumResolver {{/enum:skipEnumNameMap?}} public static {{enum:javaCapitalName}} fromInteger(int n) { {{^enum:skipEnumNameMap?}} switch (n) { {{#enum:values}} case {{enum_value:value}}: return {{enum_value:javaConstantName}}; {{/enum:values}} default: return null; } {{/enum:skipEnumNameMap?}} {{#enum:skipEnumNameMap?}} return new {{enum:javaCapitalName}}(n); {{/enum:skipEnumNameMap?}} } {{#enum:thrift_uri}} static { com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(new com.facebook.thrift.type.UniversalName("{{enum:thrift_uri}}"), {{enum:javaCapitalName}}.class, {{enum:javaCapitalName}}::read0)); } {{/enum:thrift_uri}} public static com.facebook.thrift.payload.Reader<{{enum:javaCapitalName}}> asReader() { return {{enum:javaCapitalName}}::read0; } public static {{enum:javaCapitalName}} read0(TProtocol iprot) throws TException { return {{enum:javaCapitalName}}.fromInteger(iprot.readI32()); } public void write0(TProtocol oprot) throws TException { oprot.writeI32(getValue()); } {{#enum:skipEnumNameMap?}} @java.lang.Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } {{enum:javaCapitalName}} other = ({{enum:javaCapitalName}})o; return this.value == other.value; } @java.lang.Override public int hashCode() { return value; } {{/enum:skipEnumNameMap?}} })__FBTHRIFT_TAG__", // java/enum/OpenEnum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{enum:javaPackage}}; import com.facebook.swift.codec.*; import org.apache.thrift.TException; import org.apache.thrift.protocol.TProtocol; import com.facebook.thrift.enums.ThriftEnum; import com.google.common.base.MoreObjects; import java.util.HashMap; import java.util.Map; @SwiftGenerated public class {{enum:javaCapitalName}} extends ThriftEnum<{{enum:javaCapitalName}}> { {{#enum:values}} public static final {{enum:javaCapitalName}} {{enum_value:javaConstantName}} = new {{enum:javaCapitalName}}({{enum_value:value}}); {{/enum:values}} {{#enum:values}} public static final int {{enum_value:javaConstantName}}_VALUE = {{enum_value:value}}; {{/enum:values}} public static final int UNRECOGNIZED_VALUE = {{enum:unused}}; private static final Map hm = new HashMap<>(); private static void init() { {{#enum:values}} hm.put({{enum_value:value}}, new Value({{enum:ordinal++}}, "{{enum_value:javaConstantName}}", {{enum_value:javaConstantName}})); {{/enum:values}} hm.put(UNRECOGNIZED_VALUE, new Value({{enum:ordinal++}}, "UNRECOGNIZED", null)); } static { init(); {{#enum:thrift_uri}} com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(new com.facebook.thrift.type.UniversalName("{{enum:thrift_uri}}"), {{enum:javaCapitalName}}.class, {{enum:javaCapitalName}}::read0)); {{/enum:thrift_uri}} } private {{enum:javaCapitalName}}(int value) { this.value = value; } private {{enum:javaCapitalName}}(int value, int unrecognizedValue) { this.value = value; this.unrecognizedValue = unrecognizedValue; } @Override public boolean isValueUnrecognized() { return value == UNRECOGNIZED_VALUE; } @Override public int ordinal() { return hm.get(getValue()).ordinal; } @Override public String name() { return hm.get(getValue()).name; } private static final class Value { private int ordinal; private String name; private {{enum:javaCapitalName}} instance; public Value(int ordinal, String name, {{enum:javaCapitalName}} instance) { this.ordinal = ordinal; this.name = name; this.instance = instance; } } public static {{enum:javaCapitalName}} fromInteger(int n) { Value value = hm.get(n); if (value == null) { return new {{enum:javaCapitalName}}(UNRECOGNIZED_VALUE, n); } return value.instance; } @Override public String toString() { MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this); helper.add("value", this.value); helper.add("unrecognizedValue", this.unrecognizedValue); return helper.toString(); } public static com.facebook.thrift.payload.Reader<{{enum:javaCapitalName}}> asReader() { return {{enum:javaCapitalName}}::read0; } public static {{enum:javaCapitalName}} read0(TProtocol iprot) throws TException { return {{enum:javaCapitalName}}.fromInteger(iprot.readI32()); } })__FBTHRIFT_TAG__", // java/struct/AdapterDefinition.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Facebook, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{struct:clearAdapter}}{{! }}{{#struct:fields}}{{! }}{{#field:hasFieldAdapter?}} private static final com.facebook.thrift.adapter.TypeAdapter<{{#field:type}}{{> BoxedType}}{{/field:type}}, {{field:fieldAdapterTypeClassName}}> _{{field:javaName}}_Adapter = new {{field:fieldAdapterClassName}}(); {{/field:hasFieldAdapter?}}{{! }}{{#field:hasWrapper?}} private static final com.facebook.thrift.adapter.Wrapper<{{! }}{{#field:hasAdapter?}}{{! }}{{#field:hasFieldAdapter?}}{{field:fieldAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{^field:hasFieldAdapter?}}{{field:typeAdapterTypeClassName}}{{/field:hasFieldAdapter?}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:type}}{{> BoxedType}}{{/field:type}}{{! }}{{/field:hasAdapter?}}{{! }}, {{field:wrapperType}}, com.facebook.thrift.payload.ThriftSerializable> _{{field:javaName}}_Wrapper = new {{field:wrapper}}(); {{/field:hasWrapper?}}{{! }}{{#field:type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/field:type}}{{! }}{{/struct:fields}})__FBTHRIFT_TAG__", // java/struct/CreateStruct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{struct:javaCapitalName}} result = new {{struct:javaCapitalName}}(); {{#struct:fields}} {{#field:hasWrapper?}} result.{{field:javaName}} = this.{{field:javaName}} == null ? _{{field:javaName}}_Wrapper.fromThrift(_{{field:javaName}}, new com.facebook.thrift.adapter.FieldContext({{field:key}}, result)) : this.{{field:javaName}}; {{/field:hasWrapper?}} {{^field:hasWrapper?}} result.{{field:javaName}} = this.{{field:javaName}}; {{/field:hasWrapper?}} {{/struct:fields}} return result; )__FBTHRIFT_TAG__", // java/struct/FieldGetter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> struct/FieldNullability}} {{> ThriftFieldAnnotation}} public {{> FieldType}} {{#field:hasWrapper?}}get{{field:javaCapitalName}}{{/field:hasWrapper?}}{{^field:hasWrapper?}}{{> GetterName}}{{/field:hasWrapper?}}() { return {{field:javaName}}; } {{! terminate with newline }})__FBTHRIFT_TAG__", // java/struct/FieldNullability.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:optional?}}@Nullable{{/field:optional?}}{{^field:optional?}}{{^field:required?}}{{^field:isNumericOrVoid?}}@Nullable{{/field:isNumericOrVoid?}}{{/field:required?}}{{/field:optional?}} )__FBTHRIFT_TAG__", // java/struct/FieldSetter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @com.facebook.swift.codec.ThriftField public {{struct:javaCapitalName}} {{> SetterName}}({{> FieldType}} {{field:javaName}}) { this.{{field:javaName}} = {{field:javaName}}; return this; } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/FieldValue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^field:value}}{{! }}{{#field:terse?}}{{! }}{{#field:hasAdapter?}}{{! }}{{> FromThriftStart}}{{#field:isObject?}}{{#field:type}}{{> ThriftBoxedType}}{{/field:type}}.defaultInstance(){{/field:isObject?}}{{^field:isObject?}}{{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}}{{/field:isObject?}}{{> FromThriftEnd}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:isObject?}}{{! }}{{> FieldType}}.defaultInstance(){{! }}{{/field:isObject?}}{{! }}{{^field:isObject?}}{{! }}{{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}}{{! }}{{/field:isObject?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:terse?}}{{! }}{{^field:terse?}}{{! }}{{#field:hasAdapter?}}{{! }}null{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:hasWrapper?}}null{{/field:hasWrapper?}}{{! }}{{^field:hasWrapper?}}{{field:javaDefaultValue}}{{/field:hasWrapper?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:terse?}}{{! }}{{/field:value}}{{! }}{{#field:value}}{{! }}{{#field:hasAdapter?}}{{! }}{{> FromThriftStart}}{{#field:hasInitialValue?}}{{#field:type}}{{field:nestedDepth++}}{{> DefaultValue}}{{field:nestedDepth--}}{{/field:type}}{{/field:hasInitialValue?}}{{^field:hasInitialValue?}}{{field:javaDefaultValue}}{{/field:hasInitialValue?}}{{> FromThriftEnd}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:hasInitialValue?}}{{#field:type}}{{field:nestedDepth++}}{{> DefaultValue}}{{field:nestedDepth--}}{{/field:type}}{{/field:hasInitialValue?}}{{^field:hasInitialValue?}}{{field:javaDefaultValue}}{{/field:hasInitialValue?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:value}})__FBTHRIFT_TAG__", // java/struct/FieldValueNoWrapper.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^field:value}}{{! }}{{#field:terse?}}{{! }}{{#field:hasAdapter?}}{{! }}{{> FromThriftStart}}{{#field:isObject?}}{{#field:type}}{{> BoxedType}}{{/field:type}}.defaultInstance(){{/field:isObject?}}{{^field:isObject?}}{{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}}{{/field:isObject?}}{{> FromThriftEnd}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:isObject?}}{{! }}{{> FieldType}}.defaultInstance(){{! }}{{/field:isObject?}}{{! }}{{^field:isObject?}}{{! }}{{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}}{{! }}{{/field:isObject?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:terse?}}{{! }}{{^field:terse?}}{{! }}{{#field:hasAdapter?}}{{! }}null{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{field:javaDefaultValue}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:terse?}}{{! }}{{/field:value}}{{! }}{{#field:value}}{{! }}{{#field:hasAdapter?}}{{! }}{{> FromThriftStart}}{{#field:hasInitialValue?}}{{#field:type}}{{field:nestedDepth++}}{{> DefaultValue}}{{field:nestedDepth--}}{{/field:type}}{{/field:hasInitialValue?}}{{^field:hasInitialValue?}}{{field:javaDefaultValue}}{{/field:hasInitialValue?}}{{> FromThriftEnd}}{{! }}{{/field:hasAdapter?}}{{! }}{{^field:hasAdapter?}}{{! }}{{#field:hasInitialValue?}}{{#field:type}}{{field:nestedDepth++}}{{> DefaultValue}}{{field:nestedDepth--}}{{/field:type}}{{/field:hasInitialValue?}}{{^field:hasInitialValue?}}{{field:javaDefaultValue}}{{/field:hasInitialValue?}}{{! }}{{/field:hasAdapter?}}{{! }}{{/field:value}})__FBTHRIFT_TAG__", // java/struct/IntrinsicDefault.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#type:typedef?}}{{! }}{{#type:typedef_type}}{{> struct/IntrinsicDefault}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! Integer constants }}{{#type:byte?}}(byte)0{{/type:byte?}}{{! }}{{#type:i16?}}(short)0{{/type:i16?}}{{! }}{{#type:i32?}}0{{/type:i32?}}{{! }}{{#type:i64?}}0L{{/type:i64?}}{{! Boolean constants }}{{#type:bool?}}false{{/type:bool?}}{{! Floating point constants }}{{#type:double?}}0.{{/type:double?}}{{! }}{{#type:float?}}0.f{{/type:float?}}{{! String constants }}{{#type:string?}}{{^type:isBinaryString?}}com.facebook.thrift.util.IntrinsicDefaults.defaultString(){{/type:isBinaryString?}}{{! }}{{#type:isBinaryString?}}{{#field:hasAdapter?}}com.facebook.thrift.util.IntrinsicDefaults.defaultByteBuf(){{/field:hasAdapter?}}{{^field:hasAdapter?}}com.facebook.thrift.util.IntrinsicDefaults.defaultByteArray(){{/field:hasAdapter?}}{{/type:isBinaryString?}}{{! }}{{/type:string?}}{{! Binary constants }}{{#type:binary?}}{{#field:hasAdapter?}}com.facebook.thrift.util.IntrinsicDefaults.defaultByteBuf(){{/field:hasAdapter?}}{{^field:hasAdapter?}}com.facebook.thrift.util.IntrinsicDefaults.defaultByteArray(){{/field:hasAdapter?}}{{/type:binary?}}{{! Map constants }}{{#type:map?}}com.facebook.thrift.util.IntrinsicDefaults.defaultMap(){{/type:map?}}{{! List constants }}{{#type:list?}}com.facebook.thrift.util.IntrinsicDefaults.defaultList(){{/type:list?}}{{! Set constants }}{{#type:set?}}com.facebook.thrift.util.IntrinsicDefaults.defaultSet(){{/type:set?}}{{! Enum Constants }}{{#type:enum?}}{{> BoxedType}}.fromInteger(0){{/type:enum?}}{{! }}{{! }}{{/type:typedef?}} )__FBTHRIFT_TAG__", // java/struct/NestedAdapterDefinition.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:hasAdapter?}}{{! }}{{^type:adapterDefined?}}{{type:addAdapter}}private static final com.facebook.thrift.adapter.TypeAdapter<{{> AdaptedBoxedType}}, {{type:typeClassName}}> __{{type:name}}_Adapter = new {{type:adapterClassName}}(); {{/type:adapterDefined?}}{{! }}{{/type:hasAdapter?}}{{! }}{{#type:typedef_type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{#type:set?}}{{! }}{{#type:set_elem_type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/type:set_elem_type}}{{! }}{{/type:set?}}{{! }}{{#type:list?}}{{! }}{{#type:list_elem_type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/type:list_elem_type}}{{! }}{{/type:list?}}{{! }}{{#type:map?}}{{! }}{{#type:key_type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/type:key_type}}{{! }}{{#type:value_type}}{{! }}{{> struct/NestedAdapterDefinition}}{{! }}{{/type:value_type}}{{! }}{{/type:map?}})__FBTHRIFT_TAG__", // java/struct/StructBuilder.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} public static class Builder { {{#struct:fields}} private {{> FieldType}} {{field:javaName}} = {{#field:hasWrapper?}}null{{/field:hasWrapper?}}{{^field:hasWrapper?}}{{> struct/FieldValue}}{{/field:hasWrapper?}}; {{#field:hasWrapper?}} private {{> FieldTypeNoWrapper}} _{{field:javaName}} = {{> struct/FieldValueNoWrapper}}; {{/field:hasWrapper?}} {{/struct:fields}} {{#struct:fields}} {{#field:isSensitive?}} @org.apache.thrift.annotations.Sensitive {{/field:isSensitive?}} {{> ThriftFieldAnnotation}}{{#field:javaAnnotation?}} @{{field:javaAnnotation}}{{/field:javaAnnotation?}} {{#field:hasWrapper?}} public Builder {{> SetterName}}({{field:wrapperType}} {{field:javaName}}) { this.{{field:javaName}} = {{field:javaName}}; return this; } private Builder _{{> SetterName}}({{> FieldTypeNoWrapper}} {{field:javaName}}) { this._{{field:javaName}} = {{field:javaName}}; return this; } {{/field:hasWrapper?}} {{^field:hasWrapper?}} public Builder {{> SetterName}}({{> FieldType}} {{field:javaName}}) { this.{{field:javaName}} = {{field:javaName}}; return this; } {{/field:hasWrapper?}} public {{> FieldType}} {{> GetterName}}() { return {{field:javaName}}; } {{/struct:fields}}{{! }}public Builder() { } public Builder({{struct:javaCapitalName}} other) { {{#struct:fields}} this.{{field:javaName}} = other.{{field:javaName}}; {{/struct:fields}} } @ThriftConstructor public {{struct:javaCapitalName}} build() { {{^struct:isBigStruct?}}{{^struct:asBean?}}{{^struct:hasWrapper?}} {{struct:javaCapitalName}} result = new {{struct:javaCapitalName}} ( {{#struct:fields}} this.{{field:javaName}}{{^last?}},{{/last?}} {{/struct:fields}} ); return result; {{/struct:hasWrapper?}} {{#struct:hasWrapper?}} {{> struct/CreateStruct}} {{/struct:hasWrapper?}} {{/struct:asBean?}}{{! }}{{#struct:asBean?}} {{> struct/CreateStruct}} {{/struct:asBean?}} {{/struct:isBigStruct?}}{{! }}{{#struct:isBigStruct?}} {{> struct/CreateStruct}} {{/struct:isBigStruct?}}{{! }} } } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/StructEquals.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @java.lang.Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } {{struct:javaCapitalName}} other = ({{struct:javaCapitalName}})o; return {{#struct:fields}} {{#field:hasWrapper?}} _{{field:javaName}}_Wrapper.equals({{field:javaName}}, other.{{field:javaName}}) && {{/field:hasWrapper?}} {{^field:hasWrapper?}} {{#field:hasFieldAdapter?}} _{{field:javaName}}_Adapter.equals({{field:javaName}}, other.{{field:javaName}}) && {{/field:hasFieldAdapter?}} {{^field:hasFieldAdapter?}} {{#field:hasTypeAdapter?}} __{{#field:type}}{{type:name}}{{/field:type}}_Adapter.equals({{field:javaName}}, other.{{field:javaName}}) && {{/field:hasTypeAdapter?}} {{^field:hasTypeAdapter?}} {{#field:type}}{{^type:javaType}}{{#type:binary?}}Arrays{{/type:binary?}}{{^type:binary?}}Objects{{/type:binary?}}{{/type:javaType}}{{! }}{{#type:javaType}}Objects{{/type:javaType}}{{/field:type}}.equals({{field:javaName}}, other.{{field:javaName}}) && {{/field:hasTypeAdapter?}} {{/field:hasFieldAdapter?}} {{/field:hasWrapper?}} {{/struct:fields}} true; } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/StructHashCode.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @java.lang.Override public int hashCode() { return Arrays.deepHashCode(new java.lang.Object[] { {{#struct:fields}} {{field:javaName}}{{^last?}},{{/last?}} {{/struct:fields}} }); } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/StructRead.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} public static com.facebook.thrift.payload.Reader<{{struct:javaCapitalName}}> asReader() { return {{struct:javaCapitalName}}::read0; } public static {{struct:javaCapitalName}} read0(TProtocol oprot) throws TException { TField __field; oprot.readStructBegin({{struct:javaCapitalName}}.NAMES_TO_IDS, {{struct:javaCapitalName}}.THRIFT_NAMES_TO_IDS, {{struct:javaCapitalName}}.FIELD_METADATA); {{struct:javaCapitalName}}.Builder builder = new {{struct:javaCapitalName}}.Builder(); {{#struct:fields}} {{#field:terse?}} {{#field:value}} {{#field:hasAdapter?}} builder.{{> SetterName}}({{> FromThriftStart}}{{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}}{{> FromThriftEnd}}); {{/field:hasAdapter?}} {{^field:hasAdapter?}} {{^field:isObject?}}builder.{{> SetterName}}({{#field:type}}{{> struct/IntrinsicDefault}}{{/field:type}});{{/field:isObject?}} {{/field:hasAdapter?}} {{/field:value}} {{/field:terse?}} {{/struct:fields}} while (true) { __field = oprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { {{#struct:fields}} case _{{field:javaAllCapsName}}: if (__field.type == TType.{{#field:type}}{{> TType}}{{/field:type}}) { {{#field:type}} {{field:nestedDepth++}}{{> ReadType}}{{field:nestedDepth--}} {{/field:type}} {{#field:hasAdapter?}} builder.{{#field:hasWrapper?}}_{{/field:hasWrapper?}}{{> SetterName}}({{> FromThriftStart}}{{field:javaName}}{{> FromThriftEnd}}); {{/field:hasAdapter?}} {{^field:hasAdapter?}} builder.{{#field:hasWrapper?}}_{{/field:hasWrapper?}}{{> SetterName}}({{field:javaName}}); {{/field:hasAdapter?}} } else { TProtocolUtil.skip(oprot, __field.type); } break; {{/struct:fields}} default: TProtocolUtil.skip(oprot, __field.type); break; } oprot.readFieldEnd(); } oprot.readStructEnd(); return builder.build(); } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/StructToString.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @java.lang.Override public String toString() { ToStringHelper helper = toStringHelper(this); {{#struct:fields}} helper.add("{{field:javaName}}", {{#field:isSensitive?}}""{{/field:isSensitive?}}{{^field:isSensitive?}}{{field:javaName}}{{/field:isSensitive?}}); {{/struct:fields}} return helper.toString(); } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/StructWrite.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} public void write0(TProtocol oprot) throws TException { oprot.writeStructBegin(STRUCT_DESC); {{#struct:hasTerseField?}} int structStart = 0; int pos = 0; com.facebook.thrift.protocol.ByteBufTProtocol p = (com.facebook.thrift.protocol.ByteBufTProtocol) oprot; {{/struct:hasTerseField?}} {{#struct:fields_in_serialization_order}} {{#field:hasAdapterOrWrapper?}} {{#field:type}}{{> AdaptedBoxedType}}{{/field:type}} {{field:javaName}} = {{> ToThriftStart}}this.{{field:javaName}}{{> ToThriftEnd}}; {{/field:hasAdapterOrWrapper?}} {{#field:isNullableOrOptionalNotEnum?}} {{#field:terse?}} java.util.Objects.requireNonNull({{field:javaName}}, "{{field:javaName}} must not be null"); {{#field:isObject?}}structStart = p.mark();{{/field:isObject?}} {{^field:isObject?}} if (!com.facebook.thrift.util.IntrinsicDefaults.isDefault({{field:javaName}})) { {{/field:isObject?}} oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:isContainer?}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/field:isContainer?}}{{! }}{{#type:typedef_type}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/type:typedef_type}}{{! }}{{#field:type}} {{#field:isObject?}} pos = p.mark(); {{/field:isObject?}} {{#field:type}}{{field:nestedDepth++}}{{> WriteType}}{{field:nestedDepth--}}{{/field:type}} {{/field:type}}{{! }} {{#field:isObject?}} if (p.mark() - pos > p.getEmptyStructSize()) { p.writeFieldEnd(); } else { p.rollback(structStart); } {{/field:isObject?}} {{^field:isObject?}} oprot.writeFieldEnd(); {{/field:isObject?}} {{^field:isObject?}} } {{/field:isObject?}} {{/field:terse?}} {{^field:terse?}} if ({{field:javaName}} != null) { oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:isContainer?}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/field:isContainer?}}{{! }}{{#type:typedef_type}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/type:typedef_type}}{{! }}{{#field:type}} {{field:nestedDepth++}}{{> WriteType}}{{field:nestedDepth--}} {{/field:type}}{{! }}oprot.writeFieldEnd(); } {{/field:terse?}} {{/field:isNullableOrOptionalNotEnum?}}{{! }}{{^field:isNullableOrOptionalNotEnum?}} {{#field:terse?}} {{#field:isEnum?}} java.util.Objects.requireNonNull({{field:javaName}}, "{{field:javaName}} must not be null"); if (!com.facebook.thrift.util.IntrinsicDefaults.isDefault(com.facebook.thrift.util.EnumUtil.getValue({{field:javaName}}))) { {{/field:isEnum?}} {{^field:isEnum?}} if (!com.facebook.thrift.util.IntrinsicDefaults.isDefault({{field:javaName}})) { {{/field:isEnum?}} oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:type}} {{field:nestedDepth++}}{{> WriteType}}{{field:nestedDepth--}} {{/field:type}}{{! }}oprot.writeFieldEnd(); }; {{/field:terse?}} {{^field:terse?}} {{#field:hasAdapterOrWrapper?}} if ({{field:javaName}} != null) { oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:type}} {{field:nestedDepth++}}{{> WriteType}}{{field:nestedDepth--}} {{/field:type}}{{! }}oprot.writeFieldEnd(); } {{/field:hasAdapterOrWrapper?}} {{^field:hasAdapterOrWrapper?}} oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:type}} {{field:nestedDepth++}}{{> WriteType}}{{field:nestedDepth--}} {{/field:type}}{{! }}oprot.writeFieldEnd(); {{/field:hasAdapterOrWrapper?}}{{! }}{{/field:terse?}}{{! }}{{/field:isNullableOrOptionalNotEnum?}} {{/struct:fields_in_serialization_order}} oprot.writeFieldStop(); oprot.writeStructEnd(); } {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/struct/ThriftConstructor.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#struct:asBean?}} @ThriftConstructor public {{struct:javaCapitalName}}() { {{#struct:fields}} this.{{field:javaName}} = {{#field:hasWrapper?}}null{{/field:hasWrapper?}}{{^field:hasWrapper?}}{{> struct/FieldValue}}{{/field:hasWrapper?}}; {{/struct:fields}} } {{/struct:asBean?}} {{^struct:asBean?}} {{^struct:isBigStruct?}} @ThriftConstructor public {{struct:javaCapitalName}}( {{#struct:fields}} {{> ThriftFieldAnnotation}} final {{> FieldType}} {{field:javaName}}{{^last?}},{{/last?}} {{/struct:fields}} ) { {{#struct:fields}} this.{{field:javaName}} = {{field:javaName}}; {{/struct:fields}} } {{/struct:isBigStruct?}} {{#struct:fields?}} @ThriftConstructor protected {{struct:javaCapitalName}}() { {{#struct:fields}} this.{{field:javaName}} = {{#field:hasWrapper?}}null{{/field:hasWrapper?}}{{^field:hasWrapper?}}{{> struct/FieldValue}}{{/field:hasWrapper?}}; {{/struct:fields}} }{{/struct:fields?}} {{/struct:asBean?}} {{! terminate with newline }} )__FBTHRIFT_TAG__", // java/union/UnionBuilder.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} @ThriftConstructor public {{struct:javaCapitalName}}() { } {{#struct:unionFieldTypeUnique?}} {{#struct:fields}} @ThriftConstructor @Deprecated public {{struct:javaCapitalName}}(final {{> FieldType}} {{field:javaName}}) { {{^field:optional?}}{{^field:required?}}{{^field:isNumericOrVoid?}} if (!{{struct:javaCapitalName}}.allowNullFieldValues && {{field:javaName}} == null) { throw new TProtocolException("Cannot initialize Union field '{{struct:javaCapitalName}}.{{field:javaName}}' with null value!"); } {{/field:isNumericOrVoid?}}{{/field:required?}}{{/field:optional?}} this.value = {{field:javaName}}; this.id = {{field:key}}; } {{/struct:fields}} {{/struct:unionFieldTypeUnique?}} {{#struct:fields}} public static {{struct:javaCapitalName}} from{{field:javaCapitalName}}(final {{> FieldType}} {{field:javaName}}) { {{struct:javaCapitalName}} res = new {{struct:javaCapitalName}}(); {{^field:optional?}}{{^field:required?}}{{^field:isNumericOrVoid?}} if (!{{struct:javaCapitalName}}.allowNullFieldValues && {{field:javaName}} == null) { throw new TProtocolException("Cannot initialize Union field '{{struct:javaCapitalName}}.{{field:javaName}}' with null value!"); } {{/field:isNumericOrVoid?}}{{/field:required?}}{{/field:optional?}} res.value = {{field:javaName}}; res.id = {{field:key}}; return res; } {{/struct:fields}} )__FBTHRIFT_TAG__", // java/union/UnionRead.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} public static com.facebook.thrift.payload.Reader<{{struct:javaCapitalName}}> asReader() { return {{struct:javaCapitalName}}::read0; } public static {{struct:javaCapitalName}} read0(TProtocol oprot) throws TException { {{struct:javaCapitalName}} res = new {{struct:javaCapitalName}}(); res.value = null; res.id = (short) 0; oprot.readStructBegin({{struct:javaCapitalName}}.NAMES_TO_IDS, {{struct:javaCapitalName}}.THRIFT_NAMES_TO_IDS, {{struct:javaCapitalName}}.FIELD_METADATA); TField __field = oprot.readFieldBegin(); if (__field.type != TType.STOP) { switch (__field.id) { {{#struct:fields}} case _{{field:javaAllCapsName}}: if (__field.type == {{field:javaTFieldName}}.type) { {{#field:type}} {{field:nestedDepth++}}{{> ReadType}}{{field:nestedDepth--}} {{/field:type}} {{#field:hasAdapter?}} res.value = {{> FromThriftStart}}{{field:javaName}}{{> FromThriftEnd}}; {{/field:hasAdapter?}} {{^field:hasAdapter?}} res.value = {{field:javaName}}; {{/field:hasAdapter?}} } break; {{/struct:fields}} default: TProtocolUtil.skip(oprot, __field.type); } if (res.value != null) { res.id = __field.id; } oprot.readFieldEnd(); TField __stopField = oprot.readFieldBegin(); // Consume the STOP byte if (__stopField.type != TType.STOP) { throw new TProtocolException(TProtocolException.INVALID_DATA, "Union '{{struct:javaCapitalName}}' is missing a STOP byte"); } } oprot.readStructEnd(); return res; } )__FBTHRIFT_TAG__", // java/union/UnionSetter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#struct:fields}} @com.facebook.swift.codec.ThriftField @Deprecated public void {{> SetterName}}(final {{> FieldType}} {{field:javaName}}) { this.value = {{field:javaName}}; this.id = {{field:key}}; } {{/struct:fields}} )__FBTHRIFT_TAG__", // java/union/UnionWrite.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} public void write0(TProtocol oprot) throws TException { if (this.id != 0 && this.value == null ){ if(allowNullFieldValues) { // Warning: this path will generate corrupt serialized data! return; } else { throw new TProtocolException("Cannot write a Union with marked-as-set but null value!"); } } oprot.writeStructBegin(STRUCT_DESC); switch (this.id) { {{#struct:fields}} case _{{field:javaAllCapsName}}: { {{#field:hasAdapter?}} {{#field:type}}{{> AdaptedBoxedType}}{{/field:type}} {{field:javaName}} = {{> ToThriftStart}}({{> FieldType}})this.value{{> ToThriftEnd}}; if ({{field:javaName}} != null) { oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:isContainer?}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/field:isContainer?}}{{! }}{{#type:typedef_type}} {{> ThriftFieldType}} _iter{{field:nestedDepth}} = {{field:javaName}}; {{/type:typedef_type}}{{! }}{{^field:isContainer?}}{{^type:typedef_type}}{{! }}{{/type:typedef_type}}{{/field:isContainer?}}{{! }}{{#field:type}} {{field:nestedDepth++}}{{> WriteType }}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); } {{/field:hasAdapter?}} {{^field:hasAdapter?}} oprot.writeFieldBegin({{field:javaTFieldName}}); {{#field:isContainer?}} {{> FieldType}} _iter{{field:nestedDepth}} = ({{> FieldType}})this.value; {{/field:isContainer?}}{{! }}{{#type:typedef_type}} {{> FieldType}} _iter{{field:nestedDepth}} = ({{> FieldType}})this.value; {{/type:typedef_type}}{{! }}{{^field:isContainer?}}{{^type:typedef_type}} {{> FieldType}} {{field:javaName}} = ({{> FieldType}})this.value; {{/type:typedef_type}}{{/field:isContainer?}}{{! }}{{#field:type}} {{field:nestedDepth++}}{{> WriteType }}{{field:nestedDepth--}} {{/field:type}} oprot.writeFieldEnd(); {{/field:hasAdapter?}} break; } {{/struct:fields}} default: // ignore unknown field } oprot.writeFieldStop(); oprot.writeStructEnd(); } {{! terminate with newline }} )__FBTHRIFT_TAG__", // json/const_value.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#value:string?}}"{{value:value}}"{{/value:string?}}{{! }}{{^value:string?}}{{! }}{{#value:value}}{{! }}{{#value:string?}}"{{/value:string?}}{{value:value}}{{#value:string?}}"{{/value:string?}}{{! }}{{/value:value}}{{! }}{{#value:list?}}{{! }}[{{! }}{{#value:list_elements}}{{! }}{{> const_value}}{{^last?}},{{/last?}}{{! }}{{/value:list_elements}}{{! }}]{{! }}{{/value:list?}}{{! }}{{#value:map?}}{{! }}{{=<% %>=}}{<%={{ }}=%>{{! }}{{#value:map_elements}}{{! }}{{#element:key}}{{! }}{{#value:value}}{{! }}{{#value:string?}}"\"{{value:value}}\""{{/value:string?}}{{! }}{{^value:string?}}"{{value:value}}"{{/value:string?}}{{! }}{{/value:value}}{{! TODO(T20509094): support serialization of complex keys }}{{/element:key}} : {{! }}{{#element:value}}{{> const_value}}{{/element:value}}{{^last?}},{{/last?}}{{! }}{{/value:map_elements}}{{! }}{{=<% %>=}}}<%={{ }}=%>{{! }}{{/value:map?}}{{! }}{{/value:string?}} )__FBTHRIFT_TAG__", // json/enums.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#program:enums}} "{{enum:name}}" : { "name" : "{{enum:name}}", {{^enum:empty?}} "constants" : { {{#enum:values}} "{{enum_value:name}}" : { "name" : "{{enum_value:name}}", {{#enum_value:docstring?}} "docstring" : {{enum_value:docstring}}, {{/enum_value:docstring?}} "lineno" : {{enum_value:lineno}}, "value" : {{enum_value:value}} }{{^last?}},{{/last?}} {{/enum:values}} }, {{/enum:empty?}} {{#enum:docstring?}} "docstring" : {{enum:docstring}}, {{/enum:docstring?}} "lineno" : {{enum:lineno}} }{{^last?}},{{/last?}} {{/program:enums}} )__FBTHRIFT_TAG__", // json/return_type.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#function:return_type}}{{! }}{{^function:sink?}}{{> type}}{{/function:sink?}}{{! }}{{#function:sink?}}{ "type" : "sink", {{#function:sink_elem_type}} "inner_type" : {{> type}}, {{/function:sink_elem_type}} {{#function:sink_has_first_response?}} {{#function:sink_first_response_type}} "first_response_type" : {{> type}}, {{/function:sink_first_response_type}} {{/function:sink_has_first_response?}} {{#function:sink_final_response_type}} "final_response_type" : {{> type}} {{/function:sink_final_response_type}} }{{/function:sink?}}{{! }}{{#function:stream?}}{ "type" : "streamresponse", {{#function:stream_elem_type}} "inner_type" : {{> type}}{{! }}{{/function:stream_elem_type}}{{! }}{{#function:stream_has_first_response?}}, {{#function:stream_first_response_type}} "first_response_type" : {{> type}} {{/function:stream_first_response_type}} {{/function:stream_has_first_response?}} }{{/function:stream?}}{{! }}{{#type:service?}}{ "type" : "service", "name" : "{{type:name}}"{{#type:external?}}, "path" : "{{type:file_name}}"{{/type:external?}} }{{/type:service?}}{{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // json/services.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#program:services}} "{{service:name}}" : { {{#service:extends?}} {{#service:extends}} "extends" : { "name" : "{{service:name}}", "path" : "{{service:path}}" },{{/service:extends}}{{/service:extends?}} "name" : "{{service:name}}", "lineno" : {{service:lineno}}, {{#service:docstring?}} "docstring" : {{service:docstring}}, {{/service:docstring?}} "functions" : { {{#service:functions?}} {{#service:functions}} "{{function:name}}" : { "name" : "{{function:name}}", {{#function:docstring?}} "docstring" : {{function:docstring}}, {{/function:docstring?}} {{#function:args?}} "args" : { {{#function:args}} "{{field:name}}": { "name" : "{{field:name}}", "type" : {{#field:type}}{{> type}}{{/field:type}}, {{#field:value}} "default_value" : {{> const_value}}, {{/field:value}} {{#field:docstring?}} "docstring" : {{field:docstring}}, {{/field:docstring?}} "key" : {{field:key}}, "lineno" : {{field:lineno}}, {{#field:required?}} "required" : "required", {{/field:required?}} {{#field:optional?}} "required" : "optional", {{/field:optional?}} {{#field:opt_in_req_out?}} "required" : "opt-in-req-out" {{/field:opt_in_req_out?}} {{#field:structured_annotations?}}, "structured_annotations": { {{#field:structured_annotations}} {{> structured_annotations}} {{/field:structured_annotations}} } {{/field:structured_annotations?}} }{{^last?}},{{/last?}} {{/function:args}} }, {{/function:args?}} {{#function:exceptions?}} "exceptions" : { {{#function:exceptions}} "{{field:name}}" : { "name": "{{field:name}}", "type" : {{#field:type}}{{> type}}{{/field:type}}, "id" : {{field:key}}{{! }}{{#field:structured_annotations?}}, "structured_annotations": { {{#field:structured_annotations}} {{> structured_annotations}} {{/field:structured_annotations}} }{{/field:structured_annotations?}} }{{^last?}},{{/last?}} {{/function:exceptions}} }, {{/function:exceptions?}} "returnType" : {{> return_type}}, "lineno" : {{function:lineno}}{{! }}{{#function:structured_annotations?}}, "structured_annotations": { {{#function:structured_annotations}} {{> structured_annotations}} {{/function:structured_annotations}} }{{/function:structured_annotations?}} }{{^last?}},{{/last?}} {{/service:functions}} {{/service:functions?}} } {{#service:structured_annotations?}}, "structured_annotations": { {{#service:structured_annotations}} {{> structured_annotations}} {{/service:structured_annotations}} } {{/service:structured_annotations?}} }{{^last?}},{{/last?}} {{/program:services}} )__FBTHRIFT_TAG__", // json/structs.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#program:structs}} "{{struct:name}}" : { "name" : "{{struct:name}}", {{#struct:structured_annotations?}} "structured_annotations": { {{#struct:structured_annotations}} {{> structured_annotations}} {{/struct:structured_annotations}} }, {{/struct:structured_annotations?}} {{#struct:docstring?}} "docstring" : {{struct:docstring}}, {{/struct:docstring?}} {{#struct:fields?}} "fields" : { {{#struct:fields}} "{{field:name}}" : { "name" : "{{field:name}}", {{#field:value}} "default_value" : {{> const_value}}, {{/field:value}} {{#field:docstring?}} "docstring" : {{field:docstring}}, {{/field:docstring?}} "key" : {{field:key}}, "lineno" : {{field:lineno}}, {{#field:required?}} "required" : "required", {{/field:required?}} {{#field:optional?}} "required" : "optional", {{/field:optional?}} {{#field:opt_in_req_out?}} "required" : "opt-in-req-out", {{/field:opt_in_req_out?}} "type" : {{#field:type}}{{> type}}{{/field:type}} {{#field:structured_annotations?}}, "structured_annotations": { {{#field:structured_annotations}} {{> structured_annotations}} {{/field:structured_annotations}} } {{/field:structured_annotations?}} }{{^last?}},{{/last?}} {{/struct:fields}} }, {{/struct:fields?}} {{#struct:plain?}} "is_exception" : false, "is_union" : false, {{/struct:plain?}} {{#struct:exception?}} "is_exception" : true, "is_union" : false, {{/struct:exception?}} {{#struct:union?}} "is_exception" : false, "is_union" : true, {{/struct:union?}} "lineno" : {{struct:lineno}} }{{^last?}},{{/last?}} {{/program:structs}} )__FBTHRIFT_TAG__", // json/structured_annotations.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} "{{value:qualified_name}}" : { "type" : {{#constant:type}}{{> type}}{{/constant:type}}, "value" : {{value:string_value_any}} }{{^last?}},{{/last?}} {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} )__FBTHRIFT_TAG__", // json/thrift_ast.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> { "__fbthrift": "@{{%!%}}generated", "thrift_module" : "{{program:name}}",{{%! %}}{{#program:includes?}} "includes": { {{#program:includes}} "{{name}}": "{{path}}"{{^last?}},{{/last?}} {{/program:includes}} },{{/program:includes?}}{{%! %}}{{#program:namespaces?}} "namespaces": { {{#program:namespaces}} "{{key}}": "{{value}}"{{^last?}},{{/last?}} {{/program:namespaces}} },{{/program:namespaces?}} {{#program:package?}} "package": { {{#program:package}} "{{key}}": "{{value}}"{{^last?}},{{/last?}} {{/program:package}} },{{/program:package?}} {{#program:docstring?}} "global_docstring": {{program:docstring}},{{/program:docstring?}}{{%! %}}{{#program:typedefs?}} "typedefs": { {{#program:typedefs}} "{{typedef:name}}": { "name": "{{typedef:name}}", "type": {{#typedef:type}}{{> type}}{{/typedef:type}}, "is_exception": {{typedef:exception?}}, "lineno": {{typedef:lineno}} }{{^last?}},{{/last?}} {{/program:typedefs}} },{{/program:typedefs?}}{{%! %}}{{#program:constants?}} "constants": { {{#program:constants}} {{#constant:type}}{{#constant:value}} "{{constant:name}}": { "name": "{{constant:name}}", "type": "{{value:type_name}}", "value": {{value:string_value_any}},{{%! %}}{{#value:docstring?}} "docstring": {{value:docstring}},{{/value:docstring?}} "lineno": {{value:lineno}} }{{/constant:value}}{{/constant:type}}{{^last?}},{{/last?}} {{/program:constants}} },{{/program:constants?}}{{%! %}}{{#program:enums?}} "enumerations" : { {{> enums}} }, {{/program:enums?}} {{#program:structs?}} "structs" : { {{> structs}} }, {{/program:structs?}} {{#program:services?}} "services" : { {{> services}} }, {{/program:services?}} {{! rearrange to avoid trailing comma issue}} "source_path" : "{{program:normalized_include_prefix}}{{program:name}}", "py_namespace" : "{{program:py_namespace}}" } )__FBTHRIFT_TAG__", // json/type.mustache R"__FBTHRIFT_TAG__(<%={{ }}=%> {{#type:void?}}"void"{{/type:void?}}{{! }}{{#type:string?}}"string"{{/type:string?}}{{! }}{{#type:binary?}}"binary"{{/type:binary?}}{{! }}{{#type:bool?}}"bool"{{/type:bool?}}{{! }}{{#type:byte?}}"byte"{{/type:byte?}}{{! }}{{#type:i16?}}"i16"{{/type:i16?}}{{! }}{{#type:i32?}}"i32"{{/type:i32?}}{{! }}{{#type:i64?}}"i64"{{/type:i64?}}{{! }}{{#type:double?}}"double"{{/type:double?}}{{! }}{{#type:float?}}"float"{{/type:float?}}{{! }}{{#type:struct?}}{ "type" : "struct", "name" : "{{type:name}}"{{#type:external?}}, "path" : "{{type:path}}"{{/type:external?}} }{{/type:struct?}}{{! }}{{#type:enum?}}{ "type" : "enum", "name" : "{{type:name}}"{{#type:external?}}, "path" : "{{type:path}}"{{/type:external?}} }{{/type:enum?}}{{! }}{{#type:list?}}{ "type" : "list", {{#type:list_elem_type}} "inner_type" : {{> type}} {{/type:list_elem_type}} }{{/type:list?}}{{! }}{{#type:set?}}{ "type" : "set", {{#type:set_elem_type}} "inner_type" : {{> type}} {{/type:set_elem_type}} }{{/type:set?}}{{! }}{{#type:map?}}{ "type" : "map", {{#type:key_type}} "key_type" : {{> type}}, {{/type:key_type}} {{#type:value_type}} "value_type" : {{> type}} {{/type:value_type}} }{{/type:map?}} )__FBTHRIFT_TAG__", // py3/builders.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Builder class for every struct in the module. }} {{> common/auto_generated_py}} from cpython cimport bool as pbool, int as pint, float as pfloat cimport folly.iobuf as _fbthrift_iobuf cimport thrift.py3.builder {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}builders as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}builders {{/hasTypes?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:filtered_structs}} cdef class {{struct:name}}_Builder(thrift.py3.builder.StructBuilder): {{^struct:py3_fields?}} pass {{/struct:py3_fields?}} {{#struct:py3_fields}} cdef public {{#field:type}}{{! }}{{#type:list?}}list {{/type:list?}}{{! }}{{#type:map?}}dict {{/type:map?}}{{! }}{{#type:set?}}set {{/type:set?}}{{! }}{{#type:integer?}}pint {{/type:integer?}}{{! }}{{#type:floating_point?}}pfloat {{/type:floating_point?}}{{! }}{{#type:struct?}}object {{/type:struct?}}{{! }}{{#type:cythonTypeNoneable?}}{{^type:struct?}}{{! }}{{> types/cython_python_type}} {{! }}{{/type:struct?}}{{/type:cythonTypeNoneable?}}{{! }}{{/field:type}}{{field:py_name}}{{#field:hasModifiedName?}} "{{field:cppName}}"{{/field:hasModifiedName?}} {{/struct:py3_fields}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/builders.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template should always mirror builder.pyx but for python typing }} {{> common/auto_generated_py}} import typing as _typing import folly.iobuf as _fbthrift_iobuf import thrift.py3.builder {{#program:includeNamespaces}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types import {{#includeNamespace}}{{value}}.{{/includeNamespace}}builders as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}builders {{/hasTypes?}} {{/program:includeNamespaces}} import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:filtered_structs}} class {{struct:name}}_Builder(thrift.py3.builder.StructBuilder): {{#struct:py3_fields}} {{field:py_name}}: {{#field:type}}{{! }}{{#type:list?}}_typing.Optional[list]{{/type:list?}}{{! }}{{#type:map?}}_typing.Optional[dict]{{/type:map?}}{{! }}{{#type:set?}}_typing.Optional[set]{{/type:set?}}{{! }}{{#type:integer?}}_typing.Optional[int]{{/type:integer?}}{{! }}{{#type:floating_point?}}_typing.Optional[float]{{/type:floating_point?}}{{! }}{{#type:cythonTypeNoneable?}}{{^type:struct?}}{{! }}_typing.Optional[{{> types/pep484_type}}]{{! }}{{/type:struct?}}{{/type:cythonTypeNoneable?}}{{! }}{{#type:struct?}}_typing.Any{{/type:struct?}}{{! }}{{/field:type}} {{/struct:py3_fields}} def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Any]]: ... {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/builders.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Struct builder class implementation. }} {{> common/auto_generated_py}} {{#program:filtered_structs}} cdef class {{struct:name}}_Builder(thrift.py3.builder.StructBuilder): _struct_type = _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types.{{struct:name}} def __iter__(self): {{^struct:py3_fields?}} pass {{/struct:py3_fields?}} {{#struct:py3_fields}} yield "{{field:py_name}}", self.{{field:py_name}} {{/struct:py3_fields}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/clients.pxd.mustache R"__FBTHRIFT_TAG__({{#program:auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_clients cimport * {{/program:auto_migrate?}} {{^program:auto_migrate?}} {{> py3_clients.pxd }} {{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // py3/clients.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} {{^program:no_auto_migrate?}}from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{! }}thrift_clients import *{{/program:no_auto_migrate?}} {{#program:no_auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_clients import * {{/program:no_auto_migrate?}} )__FBTHRIFT_TAG__", // py3/clients.pyi.mustache R"__FBTHRIFT_TAG__({{> py3_clients.pyi }} )__FBTHRIFT_TAG__", // py3/clients.pyx.mustache R"__FBTHRIFT_TAG__({{> py3_clients.pyx }} )__FBTHRIFT_TAG__", // py3/clients/callback.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included from CythonClients.pyx, this file defines the core adapter between the C++ async future calls and Python asyncio futures. The C++ classes defined in ClientsWrapper.h and ClientsWrapper.cpp take these callbacks and call into them from the IO thread. The callbacks examine the result, extract the exception if one occurred, and then schedule setting the result on the future to be safely executed in the asyncio loop. }} {{#program:services}} {{#service:supportedFunctions}} cdef void {{service:name}}_{{function:name}}_callback( cFollyTry[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}]&& result, PyObject* userdata ) noexcept: {{> clients/callback_body}} {{/service:supportedFunctions}} {{#service:interactions}} {{#service:supportedFunctions}} cdef void {{service:parent_service_name}}_{{service:name}}_{{function:name}}_callback( cFollyTry[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}]&& result, PyObject* userdata ) noexcept: {{> clients/callback_body}} {{/service:supportedFunctions}} {{/service:interactions}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/clients/callback_body.mustache R"__FBTHRIFT_TAG__(client, pyfuture, options = userdata {{! so client lives on until we exit }} if {{#function:exceptions}}{{! }}result.hasException[{{#field:type}}{{> types/cython_cpp_type}}{{/field:type}}](): {{#field:type}} try: exc = {{> types/cython_python_type}}._fbthrift_create(try_make_shared_exception[{{> types/cython_cpp_type}}](result.exception())) except Exception as ex: {{! This is probably a UnicodeDecodeError }} pyfuture.set_exception(ex.with_traceback(None)) else: pyfuture.set_exception(exc) {{/field:type}} elif {{/function:exceptions}}{{! }}result.hasException(): pyfuture.set_exception(create_py_exception(result.exception(), <__RpcOptions>options)) else: try: pyfuture.set_result({{#function:return_type}}{{> clients/cython_cpp_value_to_return_value}}{{/function:return_type}}) except Exception as ex: {{! Most likely this is only ever unicode decode errors }} pyfuture.set_exception(ex.with_traceback(None)) )__FBTHRIFT_TAG__", // py3/clients/clients_wrapper.cpp_func_body.mustache R"__FBTHRIFT_TAG__(folly::Promise<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}> _promise; auto _future = _promise.getFuture(); {{^function:oneway?}} auto callback = std::make_unique<::thrift::py3::FutureCallback<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}>>( std::move(_promise), rpcOptions, client->recv_wrapped_{{function:cppName}}, channel_); {{/function:oneway?}} {{#function:oneway?}} {{! oneway functions have no recv they are special cased}} auto callback = std::make_unique<::apache::thrift::OneWayFutureCallback>( std::move(_promise), channel_); {{/function:oneway?}} try { client->{{function:cppName}}( rpcOptions, std::move(callback){{#function:args}}, arg_{{field:py_name}}{{/function:args}} ); } catch (...) { return folly::makeFuture<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}>(folly::exception_wrapper( std::current_exception() )); } return _future; )__FBTHRIFT_TAG__", // py3/clients/cpp_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The C++ type of return_type for stream types. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}apache::thrift::ResponseAndClientBufferedStream<{{! }}{{#function:stream_first_response_type}}{{ >types/cpp_value_type}}{{/function:stream_first_response_type}},{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}apache::thrift::ClientBufferedStream<{{/function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >types/cpp_value_type}}{{/function:stream_elem_type}}>{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{ >types/cpp_value_type}}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/clients/cython_cpp_value_to_return_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used in cython client callbacks to convert the returned cpp value type to a python type. }}{{#type:iobuf?}}{{! }}_fbthrift_iobuf.from_unique_ptr(result.value().clone()){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}_fbthrift_iobuf.from_unique_ptr(move_iobuf(result.value())){{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}(result.value().data())[:result.value().size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}result.value(){{/type:bool?}}{{! }}{{#type:byte?}}result.value(){{/type:byte?}}{{! }}{{#type:i16?}}result.value(){{/type:i16?}}{{! }}{{#type:i32?}}result.value(){{/type:i32?}}{{! }}{{#type:i64?}}result.value(){{/type:i64?}}{{! }}{{#type:double?}}result.value(){{/type:double?}}{{! }}{{#type:float?}}result.value(){{/type:float?}}{{! }}{{#type:string?}}result.value().data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}result.value(){{/type:binary?}}{{! }}{{#type:struct}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}cmove(result.value()))){{/type:struct}}{{! }}{{#type:container?}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}cmove(result.value()))){{/type:container?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{> types/cython_python_type}}( result.value()){{/type:enum}}{{! }}{{/type:hasCustomTypeBehavior?}}{{! }}{{#function:stream?}}{{! }}{{> clients/stream_response_class_name}}._fbthrift_create(result.value(), options){{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/clients/cython_python_to_cpp_arg.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included in places where a Python object exists and its underlying C++ representation is required to be passed by value as a client call argument. For most primitives, the conversion can be done automatically, but for strings and structures, some work is required. This template assumes that the Python object is in a variable named . }}{{#type:iobuf?}}deref((<_fbthrift_iobuf.IOBuf>{{field:py_name}}).c_clone()){{/type:iobuf?}}{{! }}{{#type:iobufRef?}}((<_fbthrift_iobuf.IOBuf>{{field:py_name}}).c_clone()){{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}{{> types/cython_cpp_type}}(cmove({{field:py_name}})){{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}{{field:py_name}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:py_name}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:py_name}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:py_name}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:py_name}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:py_name}}{{/type:double?}}{{! }}{{#type:float?}}{{field:py_name}}{{/type:float?}}{{! }}{{#type:string?}}{{field:py_name}}.encode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}{{field:py_name}}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}deref((<{{> types/cython_python_type}}>{{field:py_name}})._cpp_obj){{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}deref((<{{> types/cython_python_type}}>{{field:py_name}})._cpp_obj){{! }}{{/type:container?}}{{! }}{{#type:enum?}}<{{> types/cython_cpp_type}}>{{field:py_name}}{{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/clients/cython_return_type_cpp_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Cython type for return_type in services }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}cResponseAndClientBufferedStream[{{! }}{{#function:stream_first_response_type}}{{ >types/cython_cpp_type}}{{/function:stream_first_response_type}},{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}cClientBufferedStream[{{! }}{{/function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >types/cython_cpp_type}}{{/function:stream_elem_type}}]{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{> types/cython_cpp_type}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/clients/stream_response_class_name.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Stream response class name. }}{{type:modulePath}}.{{! }}{{#function:stream_has_first_response?}}{{! }}ResponseAndClientBufferedStream__{{> stream/response_class_name_suffix}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}{{! }}ClientBufferedStream__{{#function:stream_elem_type}}{{type:flat_name}}{{/function:stream_elem_type}}{{! }}{{/function:stream_has_first_response?}} )__FBTHRIFT_TAG__", // py3/clients_wrapper.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a top level C++ file that generates an implementation of the C++ clients interface. Each client method adds a callback to run in the C++ EventBase IO thread that will pass data to the cython callback. }} {{> common/auto_generated_c}} #include <{{program:includePrefix}}gen-py3/{{program:name}}/clients_wrapper.h> {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} {{#program:services}} {{#service:supportedFunctions}} folly::Future<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}> {{service:name}}ClientWrapper::{{function:cppName}}( apache::thrift::RpcOptions& rpcOptions{{#function:args}}, {{#field:type}}{{> types/cpp_value_type}}{{/field:type}} arg_{{field:py_name}}{{/function:args}}) { auto* client = static_cast<::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:cpp_name}}AsyncClient*>(async_client_.get()); {{> clients/clients_wrapper.cpp_func_body}} } {{/service:supportedFunctions}} {{#service:interactions}} folly::Future> {{service:parent_service_name}}ClientWrapper::create{{service:name}}() { return folly::via( channel_->getEventBase(), [=]() -> std::unique_ptr<::thrift::py3::ClientWrapper> { auto interaction_client = static_cast>(std::make_unique<{{service:parent_service_cpp_name}}AsyncClient::{{service:name}}>((({{service:parent_service_cpp_name}}AsyncClient*)async_client_.get())->create{{service:name}}())); return static_cast>(std::make_unique<{{service:name}}InteractionWrapper>(std::move(interaction_client), channel_)); } ); } {{/service:interactions}} {{#service:interactions}} {{#service:supportedFunctions}} folly::Future<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}> {{service:parent_service_name}}ClientWrapper::{{service:name}}InteractionWrapper::{{function:cppName}}( apache::thrift::RpcOptions& rpcOptions{{#function:args}}, {{#field:type}}{{> types/cpp_value_type}}{{/field:type}} arg_{{field:py_name}}{{/function:args}}) { auto* client = static_cast<::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:parent_service_cpp_name}}AsyncClient::{{service:name}}*>(async_client_.get()); {{> clients/clients_wrapper.cpp_func_body}} } {{/service:supportedFunctions}} {{/service:interactions}} {{/program:services}}{{! }}{{#program:cppNamespaces}}} // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/clients_wrapper.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Header file for ClientsWrapper.cpp for cython to import in CythonClients.pxd. }} {{> common/auto_generated_c}} #pragma once {{#program:services}} #if __has_include(<{{program:includePrefix}}{{program:cpp_gen_path}}/{{service:name}}.h>) #include <{{program:includePrefix}}{{program:cpp_gen_path}}/{{service:name}}.h> #else #include <{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_clients.h> #endif {{#service:extends}} {{#service:externalProgram?}} #include <{{service:includePrefix}}gen-py3/{{service:programName}}/clients_wrapper.h> {{/service:externalProgram?}} {{/service:extends}} {{/program:services}} #include #include #include #include #include #include #include #include #include #include #include {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} {{#program:services}} class {{service:name}}ClientWrapper : {{! }}{{#service:extends?}}{{#service:extends}}public ::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:name}}ClientWrapper{{/service:extends}}{{/service:extends?}}{{! }}{{^service:extends?}}public ::thrift::py3::ClientWrapper{{/service:extends?}}{{! }} { public: using {{#service:extends?}}{{#service:extends}}{{! }}::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:name}}ClientWrapper::{{service:name}}ClientWrapper{{! }}{{/service:extends}}{{/service:extends?}}{{! }}{{^service:extends?}}::thrift::py3::ClientWrapper::ClientWrapper{{/service:extends?}}; {{#service:supportedFunctions}} folly::Future<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}> {{function:cppName}}( apache::thrift::RpcOptions& rpcOptions{{#function:args}}, {{#field:type}}{{> types/cpp_value_type}}{{/field:type}} arg_{{field:py_name}}{{/function:args}}); {{/service:supportedFunctions}} {{#service:interactions}} class {{service:name}}InteractionWrapper : public {{! }}{{#service:extends}}{{service:name}}{{/service:extends}}ClientWrapper { public: {{service:name}}InteractionWrapper( std::unique_ptr async_client, std::shared_ptr channel) : ClientWrapper(std::move(async_client), channel) {} {{#service:supportedFunctions}} folly::Future<{{#function:return_type}}{{> clients/cpp_return_type}}{{/function:return_type}}> {{function:cppName}}( apache::thrift::RpcOptions& rpcOptions{{#function:args}}, {{#field:type}}{{> types/cpp_value_type}}{{/field:type}} arg_{{field:py_name}}{{/function:args}}); {{/service:supportedFunctions}} }; {{/service:interactions}} {{#service:interactions}} folly::Future> create{{service:name}}(); {{/service:interactions}} }; {{/program:services}}{{! }}{{#program:cppNamespaces}} } // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/clients_wrapper.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Pxd file to expose the interface defined in ClientsWrapper.h to CythonClients.pyx classes. }} {{> common/auto_generated_py}} from cpython.ref cimport PyObject from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, ) from libcpp cimport bool as cbool from libcpp.map cimport map as cmap, pair as cpair from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.set cimport set as cset from libcpp.string cimport string from libcpp.vector cimport vector from folly cimport cFollyFuture, cFollyTry, cFollyUnit cimport folly.iobuf as _fbthrift_iobuf from thrift.py3.common cimport cRpcOptions from thrift.py3.client cimport cClientWrapper cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:has_stream?}} from thrift.py3.stream cimport cResponseAndClientBufferedStream, cClientBufferedStream {{/program:has_stream?}} {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{#hasServices?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}clients_wrapper as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}clients_wrapper {{/hasServices?}} {{/program:includeNamespaces}} {{#program:services}} cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_clients.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": cdef cppclass c{{service:name}}AsyncClient {{! }}"::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{! }}{{service:cpp_name}}AsyncClient": pass {{#service:interactions}} cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_clients.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": cdef cppclass c{{service:parent_service_name}}AsyncClient_{{service:name}} {{! }}"::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{! }}{{service:parent_service_name}}AsyncClient::{{service:name}}": pass {{/service:interactions}} cdef extern from "" namespace "std": cdef unique_ptr[c{{service:name}}ClientWrapper] move(unique_ptr[c{{service:name}}ClientWrapper]) {{/program:services}} cdef extern from "thrift/lib/cpp/TProcessorEventHandler.h" namespace "::apache::thrift": cdef cppclass cTProcessorEventHandler "apache::thrift::TProcessorEventHandler": pass cdef extern from "{{program:includePrefix}}gen-py3/{{program:name}}/clients_wrapper.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}":{{! }}{{^program:services}} pass{{/program:services}}{{#program:services}} cdef cppclass c{{service:name}}ClientWrapper "{{! }}::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{service:name}}ClientWrapper"{{! }}{{#service:extends}}({{! }}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients_wrapper.{{! }}{{/service:externalProgram?}}c{{service:name}}ClientWrapper{{! }}){{/service:extends}}: {{^service:extends?}} void setPersistentHeader(const string& key, const string& value) void addEventHandler(const shared_ptr[cTProcessorEventHandler]& handler) {{/service:extends?}} {{#service:supportedFunctions}} cFollyFuture[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}] {{function:cppName}}(cRpcOptions, {{#function:args}} {{#field:type}}{{> types/cython_cpp_type}}{{/field:type}} arg_{{field:py_name}},{{/function:args}}) {{/service:supportedFunctions}} {{! If this is an empty service definition that extends another service with no interactions Then we need to put pass, otherwise cython will complain about the empty cppclass body }} {{^service:supportedFunctions}} {{^service:interactions}} {{#service:extends?}} pass {{/service:extends?}} {{/service:interactions}} {{/service:supportedFunctions}} {{#service:interactions}} cFollyFuture[unique_ptr[cClientWrapper]]& create{{service:name}}() {{/service:interactions}} {{#service:interactions}} cdef cppclass c{{service:parent_service_name}}ClientWrapper_{{service:name}}InteractionWrapper "{{! }}::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{service:parent_service_name}}ClientWrapper{{! }}::{{service:name}}InteractionWrapper"(cClientWrapper): void setPersistentHeader(const string& key, const string& value) void addEventHandler(const shared_ptr[cTProcessorEventHandler]& handler) {{#service:supportedFunctions}} cFollyFuture[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}] {{function:cppName}}(cRpcOptions, {{#function:args}} {{#field:type}}{{> types/cython_cpp_type}}{{/field:type}} arg_{{field:py_name}},{{/function:args}}) {{/service:supportedFunctions}} {{! If this is an empty service definition that extends another service Then we need to put pass, otherwise cython will complain about the empty cppclass body }} {{^service:supportedFunctions}} {{#service:extends?}} pass {{/service:extends?}} {{/service:supportedFunctions}} {{/service:interactions}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/common/annotation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! A single annotation, written out for python consumption in a dict. Annotations may start/end with quotes hence we take extra care }} {{annotation:py_quoted_key}}: {{! }}{{#annotation:value?}}{{annotation:py_quoted_value}}{{/annotation:value?}}{{! An annotation without an explicitly provided value is implicitly assigned the default value "1". }}{{^annotation:value?}}"1"{{/annotation:value?}}, )__FBTHRIFT_TAG__", // py3/common/auto_generated_c.mustache R"__FBTHRIFT_TAG__(/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @{{!x}}generated */ {{! terminate with newline }} )__FBTHRIFT_TAG__", // py3/common/auto_generated_py.mustache R"__FBTHRIFT_TAG__(# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @{{!x}}generated # {{! terminate with newline }} )__FBTHRIFT_TAG__", // py3/common/auto_migrate_import_prefix.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! thrift-python types module path for non-cython imports }}{{#program:auto_migrate?}}{{^program:no_auto_migrate?}}thrift_{{/program:no_auto_migrate?}}{{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // py3/common/auto_migrate_prefix.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! thrift-python types module path for cython imports }}{{#program:auto_migrate?}}py3_{{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // py3/common/python_types_module_path.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! thrift-python types module path }}{{! }}{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.thrift_types )__FBTHRIFT_TAG__", // py3/converter.pxd.mustache R"__FBTHRIFT_TAG__({{> common/auto_generated_py}} from libcpp.memory cimport shared_ptr cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _fbthrift_ctypes {{#program:filtered_structs}} cdef shared_ptr[_fbthrift_ctypes.c{{struct:name}}] {{struct:name}}_convert_to_cpp(object inst) except* cdef object {{struct:name}}_from_cpp(const shared_ptr[_fbthrift_ctypes.c{{struct:name}}]& c_struct) {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/converter.pyx.mustache R"__FBTHRIFT_TAG__( {{> common/auto_generated_py}} {{#program:auto_migrate?}} from libcpp.memory cimport make_shared from thrift.python.capi.cpp_converter cimport cpp_to_python, python_to_cpp from cython.operator cimport dereference as deref {{/program:auto_migrate?}} {{#program:auto_migrate?}}{{! include Constructor and Extractor specializations }} cdef extern from "{{program:includePrefix}}gen-python-capi/{{program:name}}/thrift_types_capi.h": pass {{/program:auto_migrate?}} {{#program:filtered_structs}} {{! direct replacement for ._cpp_obj }} cdef shared_ptr[_fbthrift_ctypes.c{{struct:name}}] {{struct:name}}_convert_to_cpp(object inst) except*: {{#program:auto_migrate?}} return make_shared[_fbthrift_ctypes.c{{struct:name}}](python_to_cpp[_fbthrift_ctypes.c{{struct:name}}](inst)) {{/program:auto_migrate?}} {{^program:auto_migrate?}} return (<_fbthrift_ctypes.{{struct:name}}?>inst)._cpp_obj {{/program:auto_migrate?}} {{! direct replacement for ._fbthrift_create }} cdef object {{struct:name}}_from_cpp(const shared_ptr[_fbthrift_ctypes.c{{struct:name}}]& c_struct): {{#program:auto_migrate?}} return cpp_to_python[_fbthrift_ctypes.c{{struct:name}}](deref(c_struct)) {{/program:auto_migrate?}} {{^program:auto_migrate?}} return _fbthrift_ctypes.{{struct:name}}._fbthrift_create(c_struct) {{/program:auto_migrate?}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/metadata.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> common/auto_generated_c}} #include "{{program:includePrefix}}gen-py3/{{program:name}}/metadata.h" {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} ::apache::thrift::metadata::ThriftMetadata {{program:name}}_getThriftModuleMetadata() { ::apache::thrift::metadata::ThriftServiceMetadataResponse response; ::apache::thrift::metadata::ThriftMetadata& metadata = *response.metadata_ref(); {{#program:enums}} ::apache::thrift::detail::md::EnumMetadata<{{enum:cpp_name}}>::gen(metadata); {{/program:enums}} {{#program:filtered_structs}} {{#struct:exception?}} ::apache::thrift::detail::md::ExceptionMetadata<{{struct:name}}>::gen(metadata); {{/struct:exception?}} {{^struct:exception?}} ::apache::thrift::detail::md::StructMetadata<{{struct:name}}>::gen(metadata); {{/struct:exception?}} {{/program:filtered_structs}} {{#program:services}} ::apache::thrift::detail::md::ServiceMetadata<::apache::thrift::ServiceHandler<{{service:qualified_name}}>>::gen(response); {{/program:services}} return metadata; } {{#program:cppNamespaces}} } // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/metadata.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> common/auto_generated_c}} #pragma once #include #include "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_metadata.h" {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} ::apache::thrift::metadata::ThriftMetadata {{program:name}}_getThriftModuleMetadata(); {{#program:cppNamespaces}} } // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/metadata.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> common/auto_generated_py}} from apache.thrift.metadata.types cimport cThriftMetadata from thrift.py3.common cimport ( cThriftMetadata as __fbthrift_cThriftMetadata, ) cdef extern from "{{program:includePrefix}}gen-py3/{{program:name}}/metadata.h"{{! }} : cdef cThriftMetadata cGetThriftModuleMetadata "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{program:name}}_getThriftModuleMetadata"() )__FBTHRIFT_TAG__", // py3/metadata.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.thrift_metadata import * )__FBTHRIFT_TAG__", // py3/metadata.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> common/auto_generated_py}} from apache.thrift.metadata.types import ThriftMetadata def getThriftModuleMetadata() -> ThriftMetadata: ... )__FBTHRIFT_TAG__", // py3/metadata.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> common/auto_generated_py}} from libcpp.memory cimport shared_ptr, make_shared from libcpp.utility cimport move as cmove from apache.thrift.metadata.types cimport ( cThriftMetadata, ThriftMetadata, ) from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.metadata cimport cGetThriftModuleMetadata def getThriftModuleMetadata(): cdef shared_ptr[cThriftMetadata] metadata metadata = make_shared[cThriftMetadata](cGetThriftModuleMetadata()) return ThriftMetadata._fbthrift_create(cmove(metadata)) )__FBTHRIFT_TAG__", // py3/py3_clients.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Cython wrappers of the C++ client classes that were generated by thrift. By convention, service classes have a c in front of them to differentiate them from the Python classes, which have no differentiation. That allows the Python calling code to call into the code without any awkward prefixes or suffixes. This is a top-level file that gets imported by the CythonClients.pyx file. That file exposes Python wrappers of the services client to the end user. }} {{> common/auto_generated_py}} cimport thrift.py3.client {{#program:includeNamespaces}} {{#hasServices?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}clients as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}clients {{/hasServices?}} {{/program:includeNamespaces}} {{#program:services}} cdef class {{service:name}}{{#service:extends}}({{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients.{{/service:externalProgram?}}{{service:name}}{{! }}){{/service:extends}}{{^service:extends?}}(thrift.py3.client.Client){{/service:extends?}}: pass {{#service:interactions}} cdef class {{service:parent_service_name}}_{{service:name}}(thrift.py3.client.Client): pass {{/service:interactions}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/py3_clients.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template should always mirror clients.pyx but for mypy typing }} {{> common/auto_generated_py}} import folly.iobuf as _fbthrift_iobuf import thrift.py3.types import thrift.py3.client import thrift.py3.common import typing as _typing from types import TracebackType import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:includeNamespaces}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{#hasServices?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}clients as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}clients {{/hasServices?}} {{/program:includeNamespaces}} {{#program:services}} _{{service:name}}T = _typing.TypeVar('_{{service:name}}T', bound='{{service:name}}') class {{service:name}}({{#service:extends}}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients.{{/service:externalProgram?}}{{service:name}}{{! }}{{/service:extends}}{{^service:extends?}}thrift.py3.client.Client{{/service:extends?}}): {{#service:supportedFunctions}} async def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}}, rpc_options: _typing.Optional[thrift.py3.common.RpcOptions]=None ) -> {{#function:return_type}}{{! }}{{#function:stream?}}{{> clients/stream_response_class_name}}{{/function:stream?}}{{! }}{{^function:stream?}}{{> types/pep484_type}}{{/function:stream?}}{{! }}{{/function:return_type}}: ... {{/service:supportedFunctions}} {{#service:interactions}} def create{{service:name}}(self) -> {{service:parent_service_name}}_{{service:name}}: ... def async_create{{service:name}}(self) -> {{service:parent_service_name}}_{{service:name}}: ... {{/service:interactions}} {{^service:interactions}} {{^service:supportedFunctions}} pass {{/service:supportedFunctions}} {{/service:interactions}} {{#service:interactions}} _{{service:parent_service_name}}_{{service:name}} = _typing.TypeVar('_{{service:parent_service_name}}_{{service:name}}', bound='{{service:parent_service_name}}_{{service:name}}') class {{service:parent_service_name}}_{{service:name}}({{#service:extends}}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients.{{/service:externalProgram?}}{{service:name}}{{! }}{{/service:extends}}{{^service:extends?}}thrift.py3.client.Client{{/service:extends?}}): {{#service:supportedFunctions}} async def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}}, rpc_options: _typing.Optional[thrift.py3.common.RpcOptions]=None ) -> {{#function:return_type}}{{! }}{{#function:stream?}}{{> clients/stream_response_class_name}}{{/function:stream?}}{{! }}{{^function:stream?}}{{> types/pep484_type}}{{/function:stream?}}{{! }}{{/function:return_type}}: ... {{/service:supportedFunctions}} {{^service:supportedFunctions}} pass {{/service:supportedFunctions}} {{/service:interactions}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/py3_clients.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates a top-level file to be imported in the user's client code. The generated file is pretty big, but the bulk of the generation is done inside the clients/callback partial. }} {{> common/auto_generated_py}} from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, ) from libcpp.memory cimport shared_ptr, make_shared, unique_ptr from libcpp.string cimport string from libcpp cimport bool as cbool from cpython cimport bool as pbool from libcpp.vector cimport vector from libcpp.set cimport set as cset from libcpp.map cimport map as cmap from libcpp.utility cimport move as cmove from cython.operator cimport dereference as deref, typeid from cpython.ref cimport PyObject from thrift.py3.client cimport cRequestChannel_ptr, makeClientWrapper, cClientWrapper from thrift.py3.exceptions cimport try_make_shared_exception, create_py_exception from folly cimport cFollyTry, cFollyUnit, c_unit from folly.cast cimport down_cast_ptr from libcpp.typeinfo cimport type_info import thrift.py3.types cimport thrift.py3.types from thrift.py3.types cimport make_unique import thrift.py3.client cimport thrift.py3.client from thrift.py3.common cimport ( RpcOptions as __RpcOptions, cThriftServiceMetadataResponse as __fbthrift_cThriftServiceMetadataResponse, ServiceMetadata, MetadataBox as __MetadataBox, ) from folly.futures cimport bridgeFutureWith from folly.executor cimport get_executor cimport folly.iobuf as _fbthrift_iobuf import folly.iobuf as _fbthrift_iobuf from folly.iobuf cimport move as move_iobuf cimport cython import sys import types as _py_types from asyncio import get_event_loop as asyncio_get_event_loop, shield as asyncio_shield, InvalidStateError as asyncio_InvalidStateError cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:has_stream?}} from thrift.py3.stream cimport cResponseAndClientBufferedStream, cClientBufferedStream {{/program:has_stream?}} {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{#hasServices?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}clients as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}clients import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}clients as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}clients {{/hasServices?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.services_reflection as _services_reflection {{#program:services}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.clients_wrapper cimport c{{service:name}}AsyncClient, c{{service:name}}ClientWrapper {{#service:interactions}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.clients_wrapper cimport c{{service:parent_service_name}}ClientWrapper_{{service:name}}InteractionWrapper {{/service:interactions}} {{#service:extends}} {{#service:externalProgram?}} from {{#service:py3Namespaces}}{{value}}.{{/service:py3Namespaces}}{{service:programName}}.clients_wrapper cimport c{{service:name}}ClientWrapper {{/service:externalProgram?}} {{/service:extends}} {{/program:services}} {{> clients/callback}} {{#program:services}} cdef object _{{service:name}}_annotations = _py_types.MappingProxyType({ {{#service:annotations}} {{> common/annotation}} {{#last?}} {{/last?}} {{/service:annotations}} }) @cython.auto_pickle(False) cdef class {{service:name}}({{#service:extends}}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients.{{/service:externalProgram?}}{{service:name}}{{! }}{{/service:extends}}{{^service:extends?}}thrift.py3.client.Client{{/service:extends?}}): annotations = _{{service:name}}_annotations cdef const type_info* _typeid({{service:name}} self): return &typeid(c{{service:name}}AsyncClient) cdef bind_client({{service:name}} self, cRequestChannel_ptr&& channel): self._client = makeClientWrapper[c{{service:name}}AsyncClient, c{{service:name}}ClientWrapper]( cmove(channel) ) {{#service:supportedFunctions}} @cython.always_allow_keywords(True) def {{function:name}}( {{service:name}} self{{#function:args}}, {{#field:type}}{{! }}{{#type:hasCythonType?}}{{^type:integer?}}{{> types/cython_python_type}} {{/type:integer?}}{{/type:hasCythonType?}}{{! }}{{field:py_name}}{{#type:integer?}} not None{{/type:integer?}}{{^type:number?}} not None{{/type:number?}}{{! }}{{/field:type}}{{/function:args}}, __RpcOptions rpc_options=None ): if rpc_options is None: rpc_options = <__RpcOptions>__RpcOptions.__new__(__RpcOptions) {{#function:args}} {{#field:type}} {{#type:container?}} if not isinstance({{field:py_name}}, {{> types/python_type}}): {{field:py_name}} = {{> types/python_type}}({{field:py_name}}) {{/type:container?}} {{#type:integer?}} if not isinstance({{field:py_name}}, int): raise TypeError(f'{{field:py_name}} is not a {int !r}.') else: {{! inject cython int Overflow checks }} {{field:py_name}} = <{{> types/cython_python_type}}> {{field:py_name}} {{/type:integer?}} {{/field:type}} {{/function:args}} self._check_connect_future() __loop = asyncio_get_event_loop() __future = __loop.create_future() __userdata = (self, __future, rpc_options) bridgeFutureWith[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}]( self._executor, down_cast_ptr[c{{service:name}}ClientWrapper, cClientWrapper](self._client.get()).{{function:cppName}}(rpc_options._cpp_obj, {{#function:args}} {{#field:type}}{{> clients/cython_python_to_cpp_arg}}{{/field:type}},{{/function:args}} ), {{service:name}}_{{function:name}}_callback, __userdata ) return asyncio_shield(__future) {{/service:supportedFunctions}} {{#service:interactions}} def create{{service:name}}( {{service:parent_service_name}} self ): interaction = {{service:parent_service_name}}_{{service:name}}() bridgeFutureWith[unique_ptr[cClientWrapper]]( interaction._executor, down_cast_ptr[c{{service:parent_service_name}}ClientWrapper, cClientWrapper](self._client.get()).create{{service:name}}(), thrift.py3.client.interactions_callback, interaction ) return interaction async def async_create{{service:name}}( {{service:parent_service_name}} self ): return self.create{{service:name}}() {{/service:interactions}} @classmethod def __get_reflection__(cls): return _services_reflection.get_reflection__{{service:name}}(for_clients=True) @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftServiceMetadataResponse response ServiceMetadata[_services_reflection.c{{service:cpp_name}}SvIf].gen(response) return __MetadataBox.box(cmove(deref(response.metadata_ref()))) @staticmethod def __get_thrift_name__(): return "{{program:name}}.{{service:name}}" {{#service:interactions}} @cython.auto_pickle(False) cdef class {{service:parent_service_name}}_{{service:name}}({{#service:extends}}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_clients.{{/service:externalProgram?}}{{service:name}}{{! }}{{/service:extends}}{{^service:extends?}}thrift.py3.client.Client{{/service:extends?}}): {{#service:supportedFunctions}} @cython.always_allow_keywords(True) def {{function:name}}( {{service:parent_service_name}}_{{service:name}} self{{#function:args}}, {{#field:type}}{{! }}{{#type:hasCythonType?}}{{^type:integer?}}{{> types/cython_python_type}} {{/type:integer?}}{{/type:hasCythonType?}}{{! }}{{field:py_name}}{{#type:integer?}} not None{{/type:integer?}}{{^type:number?}} not None{{/type:number?}}{{! }}{{/field:type}}{{/function:args}}, __RpcOptions rpc_options=None ): if rpc_options is None: rpc_options = <__RpcOptions>__RpcOptions.__new__(__RpcOptions) {{#function:args}} {{#field:type}} {{#type:container?}} if not isinstance({{field:py_name}}, {{> types/python_type}}): {{field:py_name}} = {{> types/python_type}}({{field:py_name}}) {{/type:container?}} {{#type:integer?}} if not isinstance({{field:py_name}}, int): raise TypeError(f'{{field:py_name}} is not a {int !r}.') else: {{! inject cython int Overflow checks }} {{field:py_name}} = <{{> types/cython_python_type}}> {{field:py_name}} {{/type:integer?}} {{/field:type}} {{/function:args}} self._check_connect_future() __loop = asyncio_get_event_loop() __future = __loop.create_future() __userdata = (self, __future, rpc_options) bridgeFutureWith[{{#function:return_type}}{{> clients/cython_return_type_cpp_type}}{{/function:return_type}}]( self._executor, down_cast_ptr[c{{service:parent_service_name}}ClientWrapper_{{service:name}}InteractionWrapper, {{! }}cClientWrapper](self._client.get()).{{function:cppName}}(rpc_options._cpp_obj, {{#function:args}} {{#field:type}}{{> clients/cython_python_to_cpp_arg}}{{/field:type}},{{/function:args}} ), {{service:parent_service_name}}_{{service:name}}_{{function:name}}_callback, __userdata ) return asyncio_shield(__future) {{/service:supportedFunctions}} {{^service:supportedFunctions}} pass {{/service:supportedFunctions}} {{/service:interactions}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/py3_services.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Cython wrappers of the C++ service classes that were generated by thrift. By convention, service classes have a c in front of them to differentiate them from the Python classes, which have no differentiation. That allows the Python calling code to call into the code without any awkward prefixes or suffixes. This is a top-level file that gets imported by the CythonServices.pyx file. That file exposes Python wrappers of the services to the end user. }} {{> common/auto_generated_py}} from thrift.py3.server cimport ServiceInterface {{#program:includeNamespaces}} {{#hasServices?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}services as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}services {{/hasServices?}} {{/program:includeNamespaces}} {{#program:services}} cdef class {{service:name}}Interface({{#service:extends}}{{#service:externalProgram?}}{{! }}_{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_services.{{/service:externalProgram?}}{{service:name}}Interface{{! }}{{/service:extends}}{{! }}{{^service:extends?}}ServiceInterface{{/service:extends?}}): {{#service:functions?}} # these are to avoid weird Cython multiple inheritance issue {{/service:functions?}} {{#service:supportedFunctions}} cdef bint _for_cython_{{function:name }} {{/service:supportedFunctions}} pass {{/program:services}} )__FBTHRIFT_TAG__", // py3/py3_services.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template should always mirror services.pyx but for mypy typing }} {{> common/auto_generated_py}} import folly.iobuf as _fbthrift_iobuf import typing as _typing from thrift.py3.server import RequestContext, ServiceInterface from abc import abstractmethod, ABCMeta import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:includeNamespaces}} {{#hasServices?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}services as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}services {{/hasServices?}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} {{#program:services}} _{{service:name}}InterfaceT = _typing.TypeVar('_{{service:name}}InterfaceT', bound='{{service:name}}Interface') class {{service:name}}Interface( {{#service:extends}}{{#service:externalProgram?}} _{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_services.{{/service:externalProgram?}}{{service:name}}Interface, {{/service:extends}} {{^service:extends?}} ServiceInterface, {{/service:extends?}} metaclass=ABCMeta, ): {{#service:supportedFunctions}} {{#function:return_type}} {{#function:stream?}} @staticmethod def createPublisher_{{function:name}}(callback=None) -> _typing.Tuple[ _typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None], _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types.{{#function:stream_elem_type}}ServerPublisher_{{> types/cython_cpp_type_ident}}{{/function:stream_elem_type}} ]: ... {{/function:stream?}} {{/function:return_type}} @abstractmethod {{#function:return_type}}{{^function:stream?}}async {{/function:stream?}}{{#function:stream_has_first_response?}}async {{/function:stream_has_first_response?}}{{/function:return_type}}def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}} ) -> {{#function:return_type}}{{> services/return_type_pep484_type}}{{/function:return_type}}: ... {{/service:supportedFunctions}} pass {{/program:services}} )__FBTHRIFT_TAG__", // py3/py3_services.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates a top-level file to be imported in the user's service code. It provides wrappers for each of the service handlers that the user is then able to extend. The generated file is pretty big, but the bulk of the generation is done inside the services/promise and services/callback partials. }} {{> common/auto_generated_py}} cimport cython from typing import AsyncIterator from cpython.version cimport PY_VERSION_HEX from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, ) from libcpp.memory cimport shared_ptr, make_shared, unique_ptr from libcpp.string cimport string from libcpp cimport bool as cbool from cpython cimport bool as pbool from libcpp.vector cimport vector from libcpp.set cimport set as cset from libcpp.map cimport map as cmap from libcpp.utility cimport move as cmove from libcpp.pair cimport pair from cython.operator cimport dereference as deref from cpython.ref cimport PyObject from thrift.py3.exceptions cimport ( cTApplicationException, ApplicationError as __ApplicationError, cTApplicationExceptionType__UNKNOWN) from thrift.py3.server cimport ServiceInterface, RequestContext, Cpp2RequestContext from thrift.py3.server import RequestContext from folly cimport ( cFollyPromise, cFollyUnit, c_unit, ) from thrift.py3.common cimport ( cThriftServiceMetadataResponse as __fbthrift_cThriftServiceMetadataResponse, ServiceMetadata, MetadataBox as __MetadataBox, ) from thrift.py3.server cimport THRIFT_REQUEST_CONTEXT as __THRIFT_REQUEST_CONTEXT from thrift.py3.types cimport make_unique cimport folly.futures from folly.executor cimport get_executor cimport folly.iobuf as _fbthrift_iobuf import folly.iobuf as _fbthrift_iobuf from folly.iobuf cimport move as move_iobuf from folly.memory cimport to_shared_ptr as __to_shared_ptr {{#program:has_stream?}} from libcpp.optional cimport optional from thrift.py3.stream cimport cServerStream, cServerStreamPublisher, cResponseAndServerStream, createResponseAndServerStream, createAsyncIteratorFromPyIterator, pythonFuncToCppFunc, ServerStream, ServerPublisher {{/program:has_stream?}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:includeNamespaces}} {{#hasServices?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}services as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}services import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}services as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}services {{/hasServices?}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.services_reflection as _services_reflection import asyncio import functools import sys import traceback import types as _py_types {{#program:services}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.services_wrapper cimport c{{service:name}}Interface {{/program:services}} {{#program:stream_types}} cdef class ServerPublisher_{{> types/cython_cpp_type_ident}}(ServerPublisher): cdef unique_ptr[cServerStreamPublisher[{{! }}{{> types/cython_cpp_type}}{{! }}]] cPublisher def complete(ServerPublisher self): cmove(deref(self.cPublisher)).complete() # Calling this send instead of the wrapped method name of next because next is # a python keyword and makes the linter complain def send(ServerPublisher self, {{> types/cython_python_type}} item): deref(self.cPublisher).next(<{{> types/cython_cpp_type}}?>{{> types/cython_python_to_cpp_item}}) @staticmethod cdef _fbthrift_create(cServerStreamPublisher[{{! }}{{> types/cython_cpp_type}}{{! }}] cPublisher): cdef ServerPublisher_{{> types/cython_cpp_type_ident}} inst = ServerPublisher_{{> types/cython_cpp_type_ident}}.__new__(ServerPublisher_{{> types/cython_cpp_type_ident}}) inst.cPublisher = make_unique[cServerStreamPublisher[{{! }}{{> types/cython_cpp_type}}{{! }}]](cmove(cPublisher)) return inst cdef class ServerStream_{{> types/cython_cpp_type_ident}}(ServerStream): cdef unique_ptr[cServerStream[{{! }}{{> types/cython_cpp_type}}{{! }}]] cStream @staticmethod cdef _fbthrift_create(cServerStream[{{! }}{{> types/cython_cpp_type}}{{! }}] cStream): cdef ServerStream_{{> types/cython_cpp_type_ident}} inst = ServerStream_{{> types/cython_cpp_type_ident}}.__new__(ServerStream_{{> types/cython_cpp_type_ident}}) inst.cStream = make_unique[cServerStream[{{! }}{{> types/cython_cpp_type}}{{! }}]](cmove(cStream)) return inst {{/program:stream_types}} {{#program:services}} {{#service:supportedFunctions}} {{#function:return_type}} {{#function:stream?}} {{#function:stream_elem_type}} async def runGenerator_{{service:name}}_{{function:name}}(object generator, Promise_{{> types/cython_cpp_type_ident}}_Stream promise): try: item = await generator.asend(None) except StopAsyncIteration: promise.cPromise.setValue(optional[{{> types/cython_cpp_type}}]()) {{#function:stream_exceptions}} {{#field:type}} except {{> types/cython_python_type}} as ex: promise.cPromise.setException(deref((<{{> types/cython_python_type}}> ex)._cpp_obj)) {{/field:type}} {{/function:stream_exceptions}} except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in {{service:name}}.{{function:name}}:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler {{service:name}}.{{function:name}}:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(optional[{{> types/cython_cpp_type}}](<{{> types/cython_cpp_type}}?>{{> types/cython_python_to_cpp_item}})) cdef void getNextGenerator_{{service:name}}_{{function:name}}(object generator, cFollyPromise[optional[{{> types/cython_cpp_type}}]] cPromise) noexcept: cdef Promise_{{> types/cython_cpp_type_ident}}_Stream __promise = Promise_{{> types/cython_cpp_type_ident}}_Stream._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( runGenerator_{{service:name}}_{{function:name}}( generator, __promise ) ) {{/function:stream_elem_type}} {{/function:stream?}} {{/function:return_type}} {{/service:supportedFunctions}} {{/program:services}} {{> services/promise}} {{> stream/stream_promises}} {{#program:services}} cdef object _{{service:name}}_annotations = _py_types.MappingProxyType({ {{#service:annotations}} {{> common/annotation}} {{#last?}} {{/last?}} {{/service:annotations}} }) @cython.auto_pickle(False) cdef class {{service:name}}Interface( {{#service:extends}}{{#service:externalProgram?}} _{{#service:py3Namespaces}}{{value}}_{{/service:py3Namespaces}}{{! }}{{service:programName}}_services.{{/service:externalProgram?}}{{service:name}}Interface {{/service:extends}} {{^service:extends?}} ServiceInterface {{/service:extends?}} ): annotations = _{{service:name}}_annotations def __cinit__(self): self._cpp_obj = c{{service:name}}Interface( self, get_executor() ) {{#service:supportedFunctions}} async def {{function:name}}( self{{#function:args}}, {{field:py_name}}{{/function:args}}): raise NotImplementedError("async def {{function:name}} is not implemented") {{#function:return_type}} {{#function:stream?}} @staticmethod def createPublisher_{{function:name}}(callback=None): {{#function:stream_elem_type}} cdef unique_ptr[pair[cServerStream[{{> types/cython_cpp_type}}], {{! }}cServerStreamPublisher[{{> types/cython_cpp_type}}]]] streams = {{! }}make_unique[pair[cServerStream[{{> types/cython_cpp_type}}], {{! }}cServerStreamPublisher[{{> types/cython_cpp_type}}]]]({{! }}cServerStream[{{> types/cython_cpp_type}}].createPublisher(pythonFuncToCppFunc(callback))) return (ServerStream_{{> types/cython_cpp_type_ident}}._fbthrift_create(cmove(deref(streams).first)), {{! }}ServerPublisher_{{> types/cython_cpp_type_ident}}._fbthrift_create(cmove(deref(streams).second))) {{/function:stream_elem_type}} {{/function:stream?}} {{/function:return_type}} {{/service:supportedFunctions}} @classmethod def __get_reflection__(cls): return _services_reflection.get_reflection__{{service:name}}(for_clients=False) @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftServiceMetadataResponse response ServiceMetadata[_services_reflection.c{{service:cpp_name}}SvIf].gen(response) return __MetadataBox.box(cmove(deref(response.metadata_ref()))) @staticmethod def __get_thrift_name__(): return "{{program:name}}.{{service:name}}" {{/program:services}} {{> services/callback}} )__FBTHRIFT_TAG__", // py3/py3_types.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Wraps structs and exceptions defined in the thrift interface file and implemented in the cpp2 generated code. This file just exposes the C++ classes and attributes to Cython. The Pythonic wrappers of the individual structs and fields are implemented in the Struct.pyx file. }} {{> common/auto_generated_py}} {{> types/cimport_extern }} cimport thrift.py3.exceptions cimport thrift.py3.types from thrift.py3.common cimport ( RpcOptions as __RpcOptions, MetadataBox as __MetadataBox, ) from folly.optional cimport cOptional as __cOptional {{#program:has_stream?}} from folly cimport cFollyTry from cpython.ref cimport PyObject from thrift.py3.stream cimport ( ClientBufferedStream, cClientBufferedStream, cClientBufferedStreamWrapper, ResponseAndClientBufferedStream, cResponseAndClientBufferedStream, ServerStream, cServerStream, ResponseAndServerStream ) {{/program:has_stream?}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types_fields as _fbthrift_types_fields cdef extern from "{{program:includePrefix}}gen-py3/{{program:name}}/types.h": pass {{#program:python_capi_converter?}} cdef extern from "{{program:includePrefix}}gen-python-capi/{{program:name}}/thrift_types_capi.h": pass {{/program:python_capi_converter?}} {{#program:cppIncludes}} cdef extern from "{{.}}": pass {{/program:cppIncludes}}{{! }}{{#program:customTemplates}} {{> types/custom_template}} {{/program:customTemplates}}{{! }}{{#program:customTypes}} {{> types/custom_type}} {{/program:customTypes}} {{> types/enum_extern }} {{> types/enum_defs }} {{> types/struct_extern }} {{#program:filtered_structs}} {{#struct:union?}} cdef class __{{struct:name}}Type(thrift.py3.types.CompiledEnum): pass {{/struct:union?}} cdef class {{struct:name}}({{> types/python_struct_class}}): cdef shared_ptr[c{{struct:name}}] _cpp_obj {{^struct:union?}} cdef _fbthrift_types_fields.__{{struct:name}}_FieldsSetter _fields_setter {{#struct:fields_and_mixin_fields}} cdef inline object {{field:py_name}}_impl(self) {{/struct:fields_and_mixin_fields}} {{!Memoized Python wrappers of struct fields, created lazily}} {{#struct:py3_fields}} {{#field:type}}{{#type:struct}} cdef {{> types/cython_python_type}} __fbthrift_cached_{{field:py_name}} {{/type:struct}}{{#type:container?}} cdef {{> types/cython_python_type}} __fbthrift_cached_{{field:py_name}} {{/type:container?}}{{#type:enum?}} cdef object __fbthrift_cached_{{field:py_name}} {{/type:enum?}}{{#type:iobuf?}} cdef _fbthrift_iobuf.IOBuf __fbthrift_cached_{{field:py_name}} {{/type:iobuf?}}{{#type:iobufRef?}} cdef _fbthrift_iobuf.IOBuf __fbthrift_cached_{{field:py_name}} {{/type:iobufRef?}}{{/field:type}} {{/struct:py3_fields}}{{/struct:union?}} {{#struct:union?}} cdef readonly __{{struct:name}}Type type cdef readonly object value cdef _load_cache({{struct:name}} self) {{/struct:union?}} {{#struct:union?}} @staticmethod cdef unique_ptr[c{{struct:name}}] _make_instance( c{{struct:name}}* base_instance{{^struct:union?}}, bint* __isNOTSET{{/struct:union?}}{{#struct:py3_fields}}, {{#field:type}}{{! }}{{#type:cythonTypeNoneable?}}{{! }}{{> types/cython_python_type}} {{! }}{{/type:cythonTypeNoneable?}}{{! }}{{^type:cythonTypeNoneable?}}{{! }}object {{! }}{{/type:cythonTypeNoneable?}}{{! }}{{field:py_name}}{{! }}{{/field:type}}{{/struct:py3_fields}} ) except * {{/struct:union?}} @staticmethod cdef _fbthrift_create(shared_ptr[c{{struct:name}}]) {{/program:filtered_structs}} {{#program:containerTypes}} cdef class {{> types/cython_python_type}}(thrift.py3.types.{{! }}{{#type:list?}}List{{/type:list?}}{{! }}{{#type:set?}}Set{{/type:set?}}{{! }}{{#type:map?}}Map{{/type:map?}}{{! }}): cdef shared_ptr[{{> types/cython_cpp_type}}] _cpp_obj @staticmethod cdef _fbthrift_create(shared_ptr[{{> types/cython_cpp_type}}]) @staticmethod cdef shared_ptr[{{> types/cython_cpp_type}}] _make_instance(object items) except * {{/program:containerTypes}} {{> types/constant_extern }} {{#program:has_stream?}}{{! check if it's a stream case and if not short-circuit it to save get stream_types calls }} {{#program:stream_types}} cdef class ClientBufferedStream__{{type:flat_name}}(ClientBufferedStream): cdef unique_ptr[cClientBufferedStreamWrapper[{{ > types/cython_cpp_type}}]] _gen @staticmethod cdef _fbthrift_create(cClientBufferedStream[{{ > types/cython_cpp_type}}]& c_obj, __RpcOptions rpc_options) @staticmethod cdef void callback( cFollyTry[__cOptional[{{ > types/cython_cpp_type}}]]&& res, PyObject* userdata, ) noexcept cdef class ServerStream__{{type:flat_name}}(ServerStream): pass {{/program:stream_types}} {{#program:response_and_stream_functions}}{{#function:return_type}} cdef class ResponseAndClientBufferedStream__{{> stream/response_class_name_suffix}}(ResponseAndClientBufferedStream): cdef ClientBufferedStream__{{#function:stream_elem_type}}{{type:flat_name}}{{/function:stream_elem_type}} _stream cdef {{#function:stream_first_response_type}}{{ > types/cython_python_type}}{{/function:stream_first_response_type}} _response @staticmethod cdef _fbthrift_create(cResponseAndClientBufferedStream[{{! }}{{#function:stream_first_response_type}}{{ > types/cython_cpp_type}}{{/function:stream_first_response_type}}, {{! }}{{#function:stream_elem_type}}{{ > types/cython_cpp_type}}{{/function:stream_elem_type}}]& c_obj, __RpcOptions rpc_options) cdef class ResponseAndServerStream__{{> stream/response_class_name_suffix}}(ResponseAndServerStream): pass {{/function:return_type}}{{/program:response_and_stream_functions}} {{/program:has_stream?}} )__FBTHRIFT_TAG__", // py3/py3_types.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This template should always mirror types.pyx but for mypy typing }} {{> common/auto_generated_py}} import folly.iobuf as _fbthrift_iobuf import thrift.py3.types import thrift.py3.exceptions from thrift.py3.types import __NotSet, NOTSET import typing as _typing from typing_extensions import Final import sys import itertools {{#program:has_stream?}} import thrift.py3.stream {{/program:has_stream?}} {{#program:includeNamespaces}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} {{#program:intercompatible?}} import {{> common/python_types_module_path}} {{/program:intercompatible?}} __property__ = property {{#program:enums}} class {{enum:name}}(thrift.py3.types.{{^enum:flags?}}Enum{{/enum:flags?}}{{#enum:flags?}}Flag{{/enum:flags?}}{{! }}{{#program:intercompatible?}}, {{> common/python_types_module_path}}._fbthrift_compatible_with_{{enum:name}}{{/program:intercompatible?}}): {{#enum:values}} {{enum_value:py_name}}: {{enum:name}} = ... {{/enum:values}} {{!TODO: accommodate root_module_prefix}} def _to_python(self) -> "{{> common/python_types_module_path}}.{{enum:name}}": ... # type: ignore def _to_py3(self) -> {{enum:name}}: ... def _to_py_deprecated(self) -> int: ... {{/program:enums}} {{#program:filtered_structs}} {{#struct:union?}} _{{struct:name}}ValueType = _typing.Union[None, {{#struct:py3_fields}}{{^first?}}, {{/first?}}{{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/struct:py3_fields}}] {{/struct:union?}} class {{struct:name}}({{> types/python_struct_class}}, _typing.Hashable{{! }}{{#program:intercompatible?}}, {{> common/python_types_module_path}}._fbthrift_compatible_with_{{struct:name}}{{/program:intercompatible?}}): class __fbthrift_IsSet: {{#struct:py3_fields}} {{#field:has_ref_accessor?}} {{^field:terse?}} {{field:py_name}}: bool {{/field:terse?}} {{/field:has_ref_accessor?}} {{/struct:py3_fields}} pass {{#struct:fields_and_mixin_fields}} {{field:py_name}}: Final[{{#field:PEP484Optional?}}_typing.Optional[{{/field:PEP484Optional?}}{{! }}{{#field:type}}{{> types/pep484_type}}{{/field:type}}{{! }}{{#field:PEP484Optional?}}]{{/field:PEP484Optional?}}] = ... {{/struct:fields_and_mixin_fields}} def __init__( self, {{#struct:py3_fields?}}*{{/struct:py3_fields?}}{{#struct:py3_fields}}, {{field:py_name}}: _typing.Optional[{{#field:type}}{{> types/compatible_pep484_type}}{{/field:type}}]=None{{/struct:py3_fields}} ) -> None: ... {{#struct:plain?}} def __call__( self, {{#struct:py3_fields?}}*{{/struct:py3_fields?}}{{#struct:py3_fields}}, {{field:py_name}}: _typing.Union[{{#field:type}}{{> types/compatible_pep484_type}}{{/field:type}}, '__NotSet', None]=NOTSET{{/struct:py3_fields}} ) -> {{struct:name}}: ... def __reduce__(self) -> _typing.Tuple[_typing.Callable, _typing.Tuple[_typing.Type['{{struct:name}}'], bytes]]: ... {{/struct:plain?}} def __hash__(self) -> int: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... {{#struct:is_struct_orderable?}} def __lt__(self, other: '{{struct:name}}') -> bool: ... def __gt__(self, other: '{{struct:name}}') -> bool: ... def __le__(self, other: '{{struct:name}}') -> bool: ... def __ge__(self, other: '{{struct:name}}') -> bool: ... {{/struct:is_struct_orderable?}} {{#struct:union?}} class Type(thrift.py3.types.Enum): EMPTY: {{struct:name}}.Type = ... {{#struct:py3_fields}} {{field:py_name}}: {{struct:name}}.Type = ... {{/struct:py3_fields}} @staticmethod def fromValue(value: _{{struct:name}}ValueType) -> {{struct:name}}: ... @__property__ def value(self) -> _{{struct:name}}ValueType: ... @__property__ def type(self) -> "{{struct:name}}.Type": ... {{/struct:union?}} {{#program:python_capi_converter?}} @staticmethod def from_python(obj: "{{> common/python_types_module_path}}.{{struct:name}}") -> _typing.Self: ... # type: ignore {{/program:python_capi_converter?}} {{!TODO: accommodate root_module_prefix}} def _to_python(self) -> "{{> common/python_types_module_path}}.{{struct:name}}": ... # type: ignore def _to_py3(self) -> {{struct:name}}: ... def _to_py_deprecated(self) -> "{{program:py_deprecated_module_path}}.ttypes.{{struct:name}}": ... # type: ignore {{/program:filtered_structs}} {{#program:containerTypes}} {{#type:list?}} _{{> types/cython_python_type}}T = _typing.TypeVar('_{{> types/cython_python_type}}T', bound={{> types/pep484_containers}}) {{/type:list?}} class {{> types/cython_python_type}}({{> types/pep484_containers}}, _typing.Hashable): def __init__(self, items: _typing.Optional[{{> types/pep484_containers}}]=None) -> None: ... def __len__(self) -> int: ... def __hash__(self) -> int: ... def __copy__(self) -> {{> types/pep484_containers}}: ... {{#type:list?}} @_typing.overload def __getitem__(self, i: int) -> {{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}: ... @_typing.overload def __getitem__(self, s: slice) -> {{> types/pep484_containers}}: ... def __add__(self, other: {{> types/pep484_containers}}) -> '{{> types/cython_python_type}}': ... def __radd__(self, other: _{{> types/cython_python_type}}T) -> _{{> types/cython_python_type}}T: ... def __reversed__(self) -> _typing.Iterator[{{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}]: ... def __iter__(self) -> _typing.Iterator[{{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}]: ... {{/type:list?}} {{#type:set?}} def __contains__(self, x: object) -> bool: ... def union(self, other: {{> types/pep484_containers}}) -> '{{> types/cython_python_type}}': ... def intersection(self, other: {{> types/pep484_containers}}) -> '{{> types/cython_python_type}}': ... def difference(self, other: {{> types/pep484_containers}}) -> '{{> types/cython_python_type}}': ... def symmetric_difference(self, other: {{> types/pep484_containers}}) -> '{{> types/cython_python_type}}': ... def issubset(self, other: {{> types/pep484_containers}}) -> bool: ... def issuperset(self, other: {{> types/pep484_containers}}) -> bool: ... def __iter__(self) -> _typing.Iterator[{{#type:set_elem_type}}{{> types/pep484_type}}{{/type:set_elem_type}}]: ... {{/type:set?}} {{#type:map?}} def __getitem__(self, key: {{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}) -> {{#type:value_type}}{{> types/pep484_type}}{{/type:value_type}}: ... def __iter__(self) -> _typing.Iterator[{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}]: ... {{/type:map?}} {{/program:containerTypes}} {{#program:constants}} {{#constant:type}} {{constant:name}}: {{> types/python_type}} = ... {{/constant:type}} {{/program:constants}} {{#program:filtered_typedefs}} {{typedef:name}} = {{#typedef:type}}{{> types/python_type}}{{/typedef:type}} {{/program:filtered_typedefs}} {{#program:has_stream?}} {{#program:stream_types}} class ClientBufferedStream__{{type:flat_name}}(thrift.py3.stream.ClientBufferedStream[{{ > types/pep484_type}}]): def __aiter__(self) -> _typing.AsyncIterator[{{ > types/pep484_type}}]: ... async def __anext__(self) -> {{ > types/pep484_type}}: ... class ServerStream__{{type:flat_name}}(thrift.py3.stream.ServerStream[{{ > types/pep484_type}}]): pass class ServerPublisher_{{> types/cython_cpp_return_type_ident}}(thrift.py3.stream.ServerPublisher): def complete(self) -> None: ... def send(self, item: {{> types/cython_python_type}}) -> None: ... {{/program:stream_types}} {{#program:response_and_stream_functions}}{{#function:return_type}}{{! }}class ResponseAndClientBufferedStream__{{> stream/response_class_name_suffix}}(thrift.py3.stream.ResponseAndClientBufferedStream[{{#function:stream_first_response_type}}{{> types/pep484_type}}{{/function:stream_first_response_type}}, {{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}]): def __iter__(self) -> _typing.Tuple[ {{#function:stream_first_response_type}}{{> types/pep484_type}}{{/function:stream_first_response_type}}, {{#function:stream_elem_type}}ClientBufferedStream__{{type:flat_name}}{{/function:stream_elem_type}}, ]: ... class ResponseAndServerStream__{{> stream/response_class_name_suffix}}(thrift.py3.stream.ResponseAndServerStream[{{#function:stream_first_response_type}}{{> types/pep484_type}}{{/function:stream_first_response_type}}, {{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}]): pass {{/function:return_type}}{{/program:response_and_stream_functions}} {{/program:has_stream?}} )__FBTHRIFT_TAG__", // py3/py3_types.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} cimport cython as __cython from cpython.object cimport PyTypeObject, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from libcpp.memory cimport shared_ptr, make_shared, unique_ptr from libcpp.optional cimport optional as __optional from libcpp.string cimport string from libcpp cimport bool as cbool from libcpp.iterator cimport inserter as cinserter from libcpp.utility cimport move as cmove from cpython cimport bool as pbool from cython.operator cimport dereference as deref, preincrement as inc, address as ptr_address import thrift.py3.types from thrift.py3.types import _IsSet as _fbthrift_IsSet from thrift.py3.types cimport make_unique cimport thrift.py3.types cimport thrift.py3.exceptions from thrift.py3.std_libcpp cimport sv_to_str as __sv_to_str, string_view as __cstring_view from thrift.py3.types cimport ( cSetOp as __cSetOp, richcmp as __richcmp, set_op as __set_op, setcmp as __setcmp, list_index as __list_index, list_count as __list_count, list_slice as __list_slice, list_getitem as __list_getitem, set_iter as __set_iter, map_iter as __map_iter, map_contains as __map_contains, map_getitem as __map_getitem, {{#program:python_capi_converter?}} py3_to_python as __py3_to_python, python_to_py3 as __python_to_py3, {{/program:python_capi_converter?}} reference_shared_ptr as __reference_shared_ptr, get_field_name_by_index as __get_field_name_by_index, reset_field as __reset_field, translate_cpp_enum_to_python, SetMetaClass as __SetMetaClass, const_pointer_cast, constant_shared_ptr, NOTSET as __NOTSET, EnumData as __EnumData, EnumFlagsData as __EnumFlagsData, UnionTypeEnumData as __UnionTypeEnumData, createEnumDataForUnionType as __createEnumDataForUnionType, ) {{#program:intercompatible?}} from thrift.py3.types import _is_python_enum, _is_python_struct {{/program:intercompatible?}} cimport thrift.py3.serializer as serializer from thrift.python.protocol cimport Protocol as __Protocol import folly.iobuf as _fbthrift_iobuf from folly.optional cimport cOptional from folly.memory cimport to_shared_ptr as __to_shared_ptr from folly.range cimport Range as __cRange import sys from collections.abc import Sequence, Set, Mapping, Iterable import weakref as __weakref import builtins as _builtins {{#program:has_stream?}} import asyncio from folly.coro cimport bridgeCoroTaskWith {{/program:has_stream?}} {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} {{> types/enum }} {{> types/union_type_enum }} {{#program:filtered_structs}} {{^struct:union?}} @__cython.auto_pickle(False) cdef class {{struct:name}}({{> types/python_struct_class}}): def __init__({{struct:name}} self,{{#struct:exception?}} *args,{{/struct:exception?}} **kwargs): self._cpp_obj = make_shared[c{{struct:name}}]() self._fields_setter = _fbthrift_types_fields.__{{struct:name}}_FieldsSetter._fbthrift_create(self._cpp_obj.get()) super().__init__({{#struct:exception?}} *args, {{/struct:exception?}}**kwargs) {{^struct:exception?}} {{^struct:cpp_noncopyable?}} def __call__({{struct:name}} self, **kwargs): {{^struct:py3_fields?}} return self {{/struct:py3_fields?}} {{#struct:py3_fields?}} if not kwargs: return self cdef {{struct:name}} __fbthrift_inst = {{struct:name}}.__new__({{struct:name}}) __fbthrift_inst._cpp_obj = make_shared[c{{struct:name}}](deref(self._cpp_obj)) __fbthrift_inst._fields_setter = _fbthrift_types_fields.__{{struct:name}}_FieldsSetter._fbthrift_create(__fbthrift_inst._cpp_obj.get()) for __fbthrift_name, _fbthrift_value in kwargs.items(): __fbthrift_inst._fbthrift_set_field(__fbthrift_name, _fbthrift_value) return __fbthrift_inst {{/struct:py3_fields?}} {{/struct:cpp_noncopyable?}} {{/struct:exception?}} cdef void _fbthrift_set_field(self, str name, object value) except *: self._fields_setter.set_field(name.encode("utf-8"), value) cdef object _fbthrift_isset(self): return _fbthrift_IsSet("{{struct:name}}", { {{#struct:py3_fields}} {{#field:has_ref_accessor?}} {{^field:terse?}} "{{field:py_name}}": deref(self._cpp_obj).{{field:py_name}}_ref().has_value(), {{/field:terse?}} {{/field:has_ref_accessor?}} {{/struct:py3_fields}} }) @staticmethod cdef _fbthrift_create(shared_ptr[c{{struct:name}}] cpp_obj): __fbthrift_inst = <{{struct:name}}>{{struct:name}}.__new__({{struct:name}}{{#struct:exception?}}, (deref(cpp_obj).what()).decode('utf-8'){{/struct:exception?}}) __fbthrift_inst._cpp_obj = cmove(cpp_obj) {{#struct:exception?}} _builtins.Exception.__init__(__fbthrift_inst, *(v for _, v in __fbthrift_inst)) {{/struct:exception?}} return __fbthrift_inst {{#struct:fields_and_mixin_fields}} cdef inline {{field:py_name}}_impl(self): {{#field:optional?}} {{^field:hasDefaultValue?}} {{#field:has_ref_accessor?}} {{^field:terse?}} if not deref(self._cpp_obj).{{field:py_name}}_ref().has_value(): return None {{/field:terse?}} {{/field:has_ref_accessor?}} {{/field:hasDefaultValue?}} {{/field:optional?}} {{#field:type}} {{> types/cython_struct_getter}} {{/field:type}} @property def {{field:py_name}}(self): return self.{{field:py_name}}_impl() {{/struct:fields_and_mixin_fields}} def __hash__({{struct:name}} self): return super().__hash__() def __repr__({{struct:name}} self): return super().__repr__() def __str__({{struct:name}} self): {{^struct:exception?}} return super().__str__() {{/struct:exception?}} {{#struct:exception?}} {{#struct:exception_message?}} field = self.{{struct:exception_message}} if field is None: {{! optional field, stringify }} return str(field) return field {{/struct:exception_message?}} {{^struct:exception_message?}} return super().__str__() {{/struct:exception_message?}} {{/struct:exception?}} {{/struct:union?}}{{! }}{{#struct:union?}} @__cython.auto_pickle(False) cdef class {{struct:name}}(thrift.py3.types.Union): Type = __{{struct:name}}Type def __init__( self, *{{#struct:py3_fields}}, {{^program:intercompatible?}}{{#field:type}}{{! }}{{#type:cythonTypeNoneable?}}{{! }}{{> types/cython_python_type}} {{! }}{{/type:cythonTypeNoneable?}}{{! }}{{/field:type}}{{/program:intercompatible?}}{{! }}{{field:py_name}}=None{{! }}{{/struct:py3_fields}} ): {{#struct:py3_fields}} {{#field:type}} {{#program:intercompatible?}} if {{field:py_name}} is not None: if not isinstance({{field:py_name}}, {{> types/python_is_instance_type}}): if _is_python_struct({{field:py_name}}) or _is_python_enum({{field:py_name}}): {{field:py_name}} = {{field:py_name}}._to_py3() if not isinstance({{field:py_name}}, {{> types/python_is_instance_type}}): raise TypeError(f'{{field:py_name}} is a thrift-python type that can not be converted to { {{> types/python_type}} !r}.') else: raise TypeError(f'{{field:py_name}} is not a { {{> types/python_type}} !r}.') {{#type:integer?}} {{! inject cython int overflow checks }} {{field:py_name}} = <{{> types/cython_python_type}}> {{field:py_name}} {{/type:integer?}} {{/program:intercompatible?}} {{^program:intercompatible?}} {{^type:cythonTypeNoneable?}} {{^type:container?}} if {{field:py_name}} is not None: if not isinstance({{field:py_name}}, {{> types/python_is_instance_type}}): raise TypeError(f'{{field:py_name}} is not a { {{> types/python_type}} !r}.') {{#type:integer?}} {{! inject cython int overflow checks }} {{field:py_name}} = <{{> types/cython_python_type}}> {{field:py_name}} {{/type:integer?}} {{/type:container?}} {{/type:cythonTypeNoneable?}} {{/program:intercompatible?}} {{/field:type}} {{/struct:py3_fields}} self._cpp_obj = __to_shared_ptr(cmove({{struct:name}}._make_instance( NULL,{{#struct:py3_fields}} {{field:py_name}},{{/struct:py3_fields}} ))) self._load_cache() @staticmethod def fromValue(value): if value is None: return {{struct:name}}() {{! We do this with strict types first, then we will do int to float conversion}} {{#struct:py3_fields}} {{#field:type}} if isinstance(value, {{> types/python_type}}): {{#type:number?}} if not isinstance(value, pbool): try: {{#type:integer?}} {{! Cython does OverflowError checking for us }} <{{> types/cython_python_type}}> value {{/type:integer?}} {{#type:float?}} {{! This will probably fail most of the time if it does then when we try again to use floating point below it will just accept the loss of precision, or just maybe there is a double field comming up }} if <{{> types/cython_python_type}}>value != value: raise OverflowError {{/type:float?}} return {{struct:name}}({{field:py_name}}=value) except OverflowError: pass {{/type:number?}} {{^type:number?}} return {{struct:name}}({{field:py_name}}=value) {{/type:number?}} {{/field:type}} {{/struct:py3_fields}} {{#struct:py3_fields}} {{#field:type}} {{#type:floating_point?}} if isinstance(value, {{> types/python_is_instance_type}}): try: <{{> types/cython_python_type}}> value return {{struct:name}}({{field:py_name}}=value) except OverflowError: pass {{/type:floating_point?}} {{/field:type}} {{/struct:py3_fields}} raise ValueError(f"Unable to derive correct union field for value: {value}") @staticmethod cdef unique_ptr[c{{struct:name}}] _make_instance( c{{struct:name}}* base_instance{{#struct:py3_fields}}, {{#field:type}}{{! }}{{#type:cythonTypeNoneable?}}{{! }}{{> types/cython_python_type}} {{! }}{{/type:cythonTypeNoneable?}}{{! }}{{^type:cythonTypeNoneable?}}{{! }}object {{! }}{{/type:cythonTypeNoneable?}}{{! }}{{field:py_name}}{{! }}{{/field:type}}{{/struct:py3_fields}} ) except *: cdef unique_ptr[c{{struct:name}}] c_inst = make_unique[c{{struct:name}}]() cdef bint any_set = False {{#struct:py3_fields}}{{#field:type}} if {{field:py_name}} is not None: if any_set: raise TypeError("At most one field may be set when initializing a union") {{> types/cython_union_assign_field}} any_set = True {{/field:type}}{{/struct:py3_fields}} # in C++ you don't have to call move(), but this doesn't translate # into a C++ return statement, so you do here return cmove(c_inst) @staticmethod cdef _fbthrift_create(shared_ptr[c{{struct:name}}] cpp_obj): __fbthrift_inst = <{{struct:name}}>{{struct:name}}.__new__({{struct:name}}) __fbthrift_inst._cpp_obj = cmove(cpp_obj) __fbthrift_inst._load_cache() return __fbthrift_inst {{#struct:py3_fields}} @property def {{field:py_name}}(self): if self.type.value != {{field:key}}: {{! TODO: python 3.10 adds some more fields to AttributeError, those should be added here at some point }} raise AttributeError(f'Union contains a value of type {self.type.name}, not {{field:py_name}}') return self.value {{/struct:py3_fields}} def __hash__({{struct:name}} self): return super().__hash__() cdef _load_cache({{struct:name}} self): self.type = {{struct:name}}.Type((deref(self._cpp_obj).getType())) cdef int type = self.type.value if type == 0: # Empty self.value = None {{#struct:py3_fields}} elif type == {{field:key}}: {{#field:type}} {{> types/cython_union_getter}} {{/field:type}} {{/struct:py3_fields}} {{/struct:union?}} {{! Below are some things that are common to structs and unions: }} def __copy__({{struct:name}} self): {{#struct:cpp_noncopyable?}} raise TypeError("{{struct:name}} is noncopyable") {{/struct:cpp_noncopyable?}} {{^struct:cpp_noncopyable?}} cdef shared_ptr[c{{struct:name}}] cpp_obj = make_shared[c{{struct:name}}]( deref(self._cpp_obj) ) return {{struct:name}}._fbthrift_create(cmove(cpp_obj)) {{/struct:cpp_noncopyable?}} {{#struct:cpp_noncomparable}} def __eq__({{struct:name}} self, other): return isinstance(other, {{struct:name}}) and self._fbthrift_noncomparable_eq(other) {{/struct:cpp_noncomparable}} {{^struct:is_struct_orderable?}} def __eq__({{struct:name}} self, other): if not isinstance(other, {{struct:name}}): return False return deref(self._cpp_obj.get()) == deref((<{{struct:name}}>other)._cpp_obj.get()) def __ne__({{struct:name}} self, other): if not isinstance(other, {{struct:name}}): return True return deref(self._cpp_obj) != deref((<{{struct:name}}>other)._cpp_obj) {{/struct:is_struct_orderable?}} {{^struct:cpp_noncomparable}} {{#struct:is_struct_orderable?}} def __richcmp__(self, other, int op): r = self._fbthrift_cmp_sametype(other, op) return __richcmp[c{{struct:name}}]( self._cpp_obj, (<{{struct:nam)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(e}}>other)._cpp_obj, op, ) if r is None else r {{/struct:is_struct_orderable?}} {{/struct:cpp_noncomparable}} @staticmethod def __get_reflection__(): import importlib types_reflection = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types_reflection" ) return types_reflection.get_reflection__{{struct:name}}() @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftMetadata meta {{#struct:exception?}} ExceptionMetadata[c{{struct:name}}].gen(meta) {{/struct:exception?}} {{^struct:exception?}} StructMetadata[c{{struct:name}}].gen(meta) {{/struct:exception?}} return __MetadataBox.box(cmove(meta)) @staticmethod def __get_thrift_name__(): return "{{program:name}}.{{struct:name}}" {{#struct:has_hidden_fields?}} __fbthrift_field_name_list = [ {{#struct:py3_fields}} '{{field:py_name}}', {{/struct:py3_fields}} ] @classmethod def _fbthrift_get_field_name_by_index(cls, idx): return cls.__fbthrift_field_name_list[idx] {{/struct:has_hidden_fields?}} {{^struct:has_hidden_fields?}} @classmethod def _fbthrift_get_field_name_by_index(cls, idx): return __sv_to_str(__get_field_name_by_index[c{{struct:name}}](idx)) {{/struct:has_hidden_fields?}} @classmethod def _fbthrift_get_struct_size(cls): return {{struct:size}} cdef _fbthrift_iobuf.IOBuf _fbthrift_serialize({{struct:name}} self, __Protocol proto): cdef unique_ptr[_fbthrift_iobuf.cIOBuf] data with nogil: data = cmove(serializer.cserialize[c{{struct:name}}](self._cpp_obj.get(), proto)) return _fbthrift_iobuf.from_unique_ptr(cmove(data)) cdef cuint32_t _fbthrift_deserialize({{struct:name}} self, const _fbthrift_iobuf.cIOBuf* buf, __Protocol proto) except? 0: cdef cuint32_t needed {{! This is a special case, we need to construct an empty _cpp_obj because thrift.py3.serializer.deserialize will just call __new__ to skip all of our runtime type checks. We do it like this because thrift.py3.serializer.deserialize does not have enough type information to call the staticmethod ._fbthrift_create() }} self._cpp_obj = make_shared[c{{struct:name}}]() with nogil: needed = serializer.cdeserialize[c{{struct:name}}](buf, self._cpp_obj.get(), proto) {{#struct:union?}} # force a cache reload since the underlying data's changed self._load_cache() {{/struct:union?}} return needed {{#program:python_capi_converter?}} @staticmethod def from_python(object obj): cdef shared_ptr[c{{struct:name}}] cpp_obj = __python_to_py3[c{{struct:name}}](obj) return {{struct:name}}._fbthrift_create(cmove(cpp_obj)) {{/program:python_capi_converter?}} def _to_python(self): {{#program:python_capi_converter?}} return __py3_to_python[c{{struct:name}}](self._cpp_obj) {{/program:python_capi_converter?}} {{^program:python_capi_converter?}} import importlib import thrift.python.converter {{!TODO: accommodate root_module_prefix}} python_types = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.thrift_types" ) return thrift.python.converter.to_python_struct(python_types.{{struct:name}}, self) {{/program:python_capi_converter?}} def _to_py3(self): return self def _to_py_deprecated(self): import importlib import thrift.util.converter py_deprecated_types = importlib.import_module("{{program:py_deprecated_module_path}}.ttypes") return thrift.util.converter.to_py_struct(py_deprecated_types.{{struct:name}}, self) {{/program:filtered_structs}} {{#program:containerTypes}} @__cython.auto_pickle(False) cdef class {{> types/cython_python_type}}(thrift.py3.types.{{! }}{{#type:list?}}List{{/type:list?}}{{! }}{{#type:set?}}Set{{/type:set?}}{{! }}{{#type:map?}}Map{{/type:map?}}{{! }}): def __init__(self, items=None): if isinstance(items, {{> types/cython_python_type}}): self._cpp_obj = (<{{> types/cython_python_type}}> items)._cpp_obj else: self._cpp_obj = {{> types/cython_python_type}}._make_instance(items) @staticmethod cdef _fbthrift_create(shared_ptr[{{> types/cython_cpp_type}}] c_items): __fbthrift_inst = <{{> types/cython_python_type}}>{{> types/cython_python_type}}.__new__({{> types/cython_python_type}}) __fbthrift_inst._cpp_obj = cmove(c_items) return __fbthrift_inst def __copy__({{> types/cython_python_type}} self): cdef shared_ptr[{{> types/cython_cpp_type}}] cpp_obj = make_shared[{{> types/cython_cpp_type}}]( deref(self._cpp_obj) ) return {{> types/cython_python_type}}._fbthrift_create(cmove(cpp_obj)) def __len__(self): return deref(self._cpp_obj).size() {{#type:list?}} @staticmethod cdef shared_ptr[{{> types/cython_cpp_type}}] _make_instance(object items) except *: cdef shared_ptr[{{> types/cython_cpp_type}}] c_inst = make_shared[{{> types/cython_cpp_type}}]() if items is not None: {{#type:containerOfString?}} if isinstance(items, str): raise TypeError("If you really want to pass a string into a {{> types/pep484_type}} field, explicitly convert it first.") {{/type:containerOfString?}} for item in items: {{#type:list_elem_type}} {{#type:container?}} if item is None: raise TypeError("None is not of the type {{> types/pep484_type}}") if not isinstance(item, {{> types/python_type}}): item = {{> types/python_type}}(item) {{/type:container?}} {{^type:container?}} if not isinstance(item, {{> types/python_is_instance_type}}): raise TypeError(f"{item!r} is not of type {{> types/pep484_type}}") {{#type:integer?}} {{! inject cython int overflow checks }} item = <{{> types/cython_python_type}}> item {{/type:integer?}} {{/type:container?}} deref(c_inst).push_back({{> types/cython_python_to_cpp_item}}) {{/type:list_elem_type}} return c_inst cdef _get_slice(self, slice index_obj): cdef int start, stop, step start, stop, step = index_obj.indices(deref(self._cpp_obj).size()) return {{> types/cython_python_type}}._fbthrift_create( __list_slice[{{> types/cython_cpp_type}}](self._cpp_obj, start, stop, step) ) cdef _get_single_item(self, size_t index): {{#type:list_elem_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} __list_getitem(self._cpp_obj, index, citem) return {{> types/container_cython_cpp_to_python_item}} {{/type:list_elem_type}} cdef _check_item_type(self, item): if not self or item is None: return {{#type:list_elem_type}} if isinstance(item, {{> types/python_type}}): return item {{#type:container?}} try: return {{> types/python_type}}(item) except: pass {{/type:container?}} {{/type:list_elem_type}} def index(self, item, start=0, stop=None): err = ValueError(f'{item} is not in list') item = self._check_item_type(item) if item is None: raise err cdef (int, int, int) indices = slice(start, stop).indices(deref(self._cpp_obj).size()) {{#type:list_elem_type}} cdef {{>types/cython_cpp_type}} citem = {{> types/cython_python_to_cpp_item}} {{/type:list_elem_type}} cdef __optional[size_t] found = __list_index[{{> types/cython_cpp_type}}](self._cpp_obj, indices[0], indices[1], citem) if not found.has_value(): raise err return found.value() def count(self, item): item = self._check_item_type(item) if item is None: return 0 {{#type:list_elem_type}} cdef {{>types/cython_cpp_type}} citem = {{> types/cython_python_to_cpp_item}} {{/type:list_elem_type}} return __list_count[{{>types/cython_cpp_type}}](self._cpp_obj, citem) @staticmethod def __get_reflection__(): import importlib types_reflection = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types_reflection" ) return types_reflection.get_reflection__{{> types/cython_python_type}}() Sequence.register({{> types/cython_python_type}}) {{/type:list?}} {{#type:set?}} @staticmethod cdef shared_ptr[{{> types/cython_cpp_type}}] _make_instance(object items) except *: cdef shared_ptr[{{> types/cython_cpp_type}}] c_inst = make_shared[{{> types/cython_cpp_type}}]() if items is not None: {{#type:containerOfString?}} if isinstance(items, str): raise TypeError("If you really want to pass a string into a {{> types/pep484_type}} field, explicitly convert it first.") {{/type:containerOfString?}} for item in items: {{#type:set_elem_type}} {{#type:container?}} if item is None: raise TypeError("None is not of type {{> types/pep484_type}}") if not isinstance(item, {{> types/python_type}}): item = {{> types/python_type}}(item) {{/type:container?}} {{^type:container?}} if not isinstance(item, {{> types/python_is_instance_type}}): raise TypeError(f"{item!r} is not of type {{> types/pep484_type}}") {{#type:integer?}} {{! inject cython int overflow checks }} item = <{{> types/cython_python_type}}> item {{/type:integer?}} {{/type:container?}} deref(c_inst).insert({{> types/cython_python_to_cpp_item}}) {{/type:set_elem_type}} return c_inst def __contains__(self, item): if not self or item is None: return False {{#type:set_elem_type}} {{#type:container?}} try: if not isinstance(item, {{> types/python_type}}): item = {{> types/python_type}}(item) except Exception: return False {{/type:container?}} if not isinstance(item, {{> types/python_type}}): return False return pbool(deref(self._cpp_obj).count({{> types/cython_python_to_cpp_item}})) {{/type:set_elem_type}} def __iter__(self): if not self: return cdef __set_iter[{{> types/cython_cpp_type}}] itr = __set_iter[{{> types/cython_cpp_type}}](self._cpp_obj) {{#type:set_elem_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} for i in range(deref(self._cpp_obj).size()): itr.genNext(self._cpp_obj, citem) yield {{> types/container_cython_cpp_to_python_item}} {{/type:set_elem_type}} def __hash__(self): return super().__hash__() def __richcmp__(self, other, int op): if isinstance(other, {{> types/cython_python_type}}): # C level comparisons return __setcmp( self._cpp_obj, (<{{> types/cython_python_type}}> other)._cpp_obj, op, ) return self._fbthrift_py_richcmp(other, op) cdef _fbthrift_do_set_op(self, other, __cSetOp op): if not isinstance(other, {{> types/cython_python_type}}): other = {{> types/cython_python_type}}(other) cdef shared_ptr[{{> types/cython_cpp_type}}] result return {{> types/cython_python_type}}._fbthrift_create(__set_op[{{> types/cython_cpp_type}}]( self._cpp_obj, (<{{> types/cython_python_type}}>other)._cpp_obj, op, )) @staticmethod def __get_reflection__(): import importlib types_reflection = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types_reflection" ) return types_reflection.get_reflection__{{> types/cython_python_type}}() Set.register({{> types/cython_python_type}}) {{/type:set?}} {{#type:map?}} @staticmethod cdef shared_ptr[{{> types/cython_cpp_type}}] _make_instance(object items) except *: cdef shared_ptr[{{> types/cython_cpp_type}}] c_inst = make_shared[{{> types/cython_cpp_type}}]() if items is not None: for key, item in items.items(): {{#type:key_type}} {{#type:container?}} if key is None: raise TypeError("None is not of type {{> types/pep484_type}}") if not isinstance(key, {{> types/python_type}}): key = {{> types/python_type}}(key) {{/type:container?}} {{^type:container?}} if not isinstance(key, {{> types/python_is_instance_type}}): raise TypeError(f"{key!r} is not of type {{> types/pep484_type}}") {{#type:integer?}} {{! inject cython int overflow checks }} key = <{{> types/cython_python_type}}> key {{/type:integer?}} {{/type:container?}} {{/type:key_type}} {{#type:value_type}} {{#type:container?}} if item is None: raise TypeError("None is not of type {{> types/pep484_type}}") if not isinstance(item, {{> types/python_type}}): item = {{> types/python_type}}(item) {{/type:container?}} {{^type:container?}} if not isinstance(item, {{> types/python_is_instance_type}}): raise TypeError(f"{item!r} is not of type {{> types/pep484_type}}") {{#type:integer?}} {{! inject cython int overflow checks }} item = <{{> types/cython_python_type}}> item {{/type:integer?}} {{/type:container?}} {{/type:value_type}} deref(c_inst)[{{! }}{{#type:key_type}}{{> types/cython_python_to_cpp_key}}{{/type:key_type}}{{! }}] = {{! }}{{#type:value_type}}{{> types/cython_python_to_cpp_item}}{{/type:value_type}} return c_inst cdef _check_key_type(self, key): if not self or key is None: return {{#type:key_type}} if isinstance(key, {{> types/python_type}}): return key {{#type:container?}} try: return {{> types/python_type}}(key) except: pass {{/type:container?}} {{/type:key_type}} def __getitem__(self, key): err = KeyError(f'{key}') key = self._check_key_type(key) if key is None: raise err {{#type:key_type}} cdef {{> types/cython_cpp_type}} ckey = {{> types/cython_python_to_cpp_key}} {{/type:key_type}} if not __map_contains(self._cpp_obj, ckey): raise err {{#type:value_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} __map_getitem(self._cpp_obj, ckey, citem) ret)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(urn {{> types/container_cython_cpp_to_python_item}} {{/type:value_type}} def __iter__(self): if not self: return cdef __map_iter[{{> types/cython_cpp_type}}] itr = __map_iter[{{> types/cython_cpp_type}}](self._cpp_obj) {{#type:key_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} for i in range(deref(self._cpp_obj).size()): itr.genNextKey(self._cpp_obj, citem) yield {{> types/container_cython_cpp_to_python_item}} {{/type:key_type}} def __contains__(self, key): key = self._check_key_type(key) if key is None: return False {{#type:key_type}} cdef {{> types/cython_cpp_type}} ckey = {{> types/cython_python_to_cpp_key}} {{/type:key_type}} return __map_contains(self._cpp_obj, ckey) def values(self): if not self: return cdef __map_iter[{{> types/cython_cpp_type}}] itr = __map_iter[{{> types/cython_cpp_type}}](self._cpp_obj) {{#type:value_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} for i in range(deref(self._cpp_obj).size()): itr.genNextValue(self._cpp_obj, citem) yield {{> types/container_cython_cpp_to_python_item}} {{/type:value_type}} def items(self): if not self: return cdef __map_iter[{{> types/cython_cpp_type}}] itr = __map_iter[{{> types/cython_cpp_type}}](self._cpp_obj) {{#type:key_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} ckey{{> types/type_default_value}} {{/type:key_type}} {{#type:value_type}} cdef {{^type:simple?}}shared_ptr[{{> types/cython_cpp_type}}]{{/type:simple?}}{{! }}{{#type:simple?}}{{> types/cython_cpp_type}}{{/type:simple?}} citem{{> types/type_default_value}} {{/type:value_type}} for i in range(deref(self._cpp_obj).size()): itr.genNextItem(self._cpp_obj, ckey, citem) yield ({{! }}{{#type:key_type}}{{! }}{{> types/container_cython_cpp_to_python_key}}{{! }}{{/type:key_type}}, {{! }}{{#type:value_type}}{{! }}{{> types/container_cython_cpp_to_python_item}}{{! }}{{/type:value_type}}) @staticmethod def __get_reflection__(): import importlib types_reflection = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types_reflection" ) return types_reflection.get_reflection__{{> types/cython_python_type}}() Mapping.register({{> types/cython_python_type}}) {{/type:map?}} {{/program:containerTypes}}{{! }}{{#program:constants}} {{#constant:value}}{{> types/constant_value}}{{/constant:value}}{{/program:constants}}{{! }}{{#program:filtered_typedefs}} {{typedef:name}} = {{#typedef:type}}{{> types/python_type}}{{/typedef:type}} {{/program:filtered_typedefs}} {{#program:has_stream?}} {{#program:stream_types}} cdef class ClientBufferedStream__{{type:flat_name}}(ClientBufferedStream): @staticmethod cdef _fbthrift_create(cClientBufferedStream[{{ > types/cython_cpp_type}}]& c_obj, __RpcOptions rpc_options): __fbthrift_inst = ClientBufferedStream__{{type:flat_name}}(rpc_options) __fbthrift_inst._gen = make_unique[cClientBufferedStreamWrapper[{{> types/cython_cpp_type}}]](c_obj) return __fbthrift_inst @staticmethod cdef void callback( cFollyTry[__cOptional[{{> types/cython_cpp_type}}]]&& result, PyObject* userdata, ) noexcept: cdef __cOptional[{{> types/cython_cpp_type}}] opt_val cdef {{> types/cython_cpp_type}} _value stream, pyfuture, rpc_options = userdata if {{#program:stream_exceptions}}{{! }}result.hasException[{{> types/cython_cpp_type}}](): pyfuture.set_exception({{! }}{{> types/cython_python_type}}._fbthrift_create({{! }}thrift.py3.exceptions.try_make_shared_exception[{{> types/cython_cpp_type}}](result.exception()){{! }})) elif {{/program:stream_exceptions}}{{! }}result.hasException(): pyfuture.set_exception( thrift.py3.exceptions.create_py_exception(result.exception(), <__RpcOptions>rpc_options) ) else: opt_val = result.value() if opt_val.has_value(): try: _value = opt_val.value() pyfuture.set_result({{> stream/cython_cpp_value_to_python_value}}) except Exception as ex: pyfuture.set_exception(ex.with_traceback(None)) else: pyfuture.set_exception(StopAsyncIteration()) def __anext__(self): __loop = asyncio.get_event_loop() __future = __loop.create_future() # to avoid "Future exception was never retrieved" error at SIGINT __future.add_done_callback(lambda x: x.exception()) __userdata = (self, __future, self._rpc_options) bridgeCoroTaskWith[__cOptional[{{> types/cython_cpp_type}}]]( self._executor, deref(self._gen).getNext(), ClientBufferedStream__{{type:flat_name}}.callback, __userdata, ) return asyncio.shield(__future) cdef class ServerStream__{{type:flat_name}}(ServerStream): pass {{/program:stream_types}} {{#program:response_and_stream_functions}}{{#function:return_type}} cdef class ResponseAndClientBufferedStream__{{> stream/response_class_name_suffix}}(ResponseAndClientBufferedStream): @staticmethod cdef _fbthrift_create(cResponseAndClientBufferedStream[{{! }}{{#function:stream_first_response_type}}{{ > types/cython_cpp_type}}{{/function:stream_first_response_type}}, {{! }}{{#function:stream_elem_type}}{{ > types/cython_cpp_type}}{{/function:stream_elem_type}}]& c_obj, __RpcOptions rpc_options): __fbthrift_inst = ResponseAndClientBufferedStream__{{> stream/response_class_name_suffix}}() __fbthrift_inst._stream = ClientBufferedStream__{{#function:stream_elem_type}}{{type:flat_name}}{{/function:stream_elem_type}}._fbthrift_create( c_obj.stream, rpc_options, ) {{#function:stream_first_response_type}} cdef {{> types/cython_cpp_type}} _value = c_obj.response __fbthrift_inst._response = {{> stream/cython_cpp_value_to_python_value}} {{/function:stream_first_response_type}} return __fbthrift_inst def __iter__(self): yield self._response yield self._stream cdef class ResponseAndServerStream__{{> stream/response_class_name_suffix}}(ResponseAndServerStream): pass {{/function:return_type}}{{/program:response_and_stream_functions}} {{/program:has_stream?}} )__FBTHRIFT_TAG__", // py3/services.pxd.mustache R"__FBTHRIFT_TAG__({{#program:auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_services cimport * {{/program:auto_migrate?}} {{^program:auto_migrate?}} {{> py3_services.pxd }} {{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // py3/services.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} {{^program:no_auto_migrate?}}from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{! }}thrift_services import *{{/program:no_auto_migrate?}} {{#program:no_auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_services import * {{/program:no_auto_migrate?}} )__FBTHRIFT_TAG__", // py3/services.pyi.mustache R"__FBTHRIFT_TAG__({{> py3_services.pyi }} )__FBTHRIFT_TAG__", // py3/services.pyx.mustache R"__FBTHRIFT_TAG__({{> py3_services.pyx }} )__FBTHRIFT_TAG__", // py3/services/callback.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included from CythonServices.pyx, this file defines the core adapter between the C++ service and the Python handler. The C++ classes defined in ServicesWrapper.h and ServicesWrapper.cpp call into this file using a generated header. It calls into the call_cy_.... functions, passing it a promise and the arguments. That function wraps the promise and arguments in Python types appropriately, then passes them into a coroutine defined in this same file. That coroutine then looks up the handler coroutine, which does the appropriate work and then returns a Python value. The coroutine accesses the C++ promise from the Python wrapper of that promise that was passed into the coroutine and sets the converted value on that promise. }} {{#program:services}} {{#service:supportedFunctions}} cdef api void call_cy_{{service:name}}_{{function:name}}( object self, Cpp2RequestContext* ctx, cFollyPromise[{{#function:return_type}}{{! }}{{> services/cython_return_type_cpp_type}}{{! }}{{/function:return_type}}]{{! }} cPromise{{#function:args}}, {{#field:type}}{{! }}{{^function:stack_arguments?}}{{> services/cython_field_type}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cython_cpp_type}}{{/function:stack_arguments?}}{{! }}{{/field:type}} {{field:py_name}}{{/function:args}} ) noexcept:{{! Gets called from a python Executor }} {{#function:return_type}} cdef {{> services/promise_name}} __promise = {{> services/promise_name}}._fbthrift_create(cmove(cPromise)) {{/function:return_type}} {{#function:args}} arg_{{field:py_name}} = {{#field:type}}{{! }}{{^function:stack_arguments?}}{{> services/cython_cpp_to_python}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cython_cpp_value_to_python}}{{/function:stack_arguments?}}{{! }}{{/field:type}} {{/function:args}} __context = RequestContext._fbthrift_create(ctx) __context_token = __THRIFT_REQUEST_CONTEXT.set(__context) asyncio.get_event_loop().create_task( {{service:name}}_{{function:name}}_coro( self, __promise{{#function:args}}, arg_{{field:py_name}}{{/function:args}} ) ) __THRIFT_REQUEST_CONTEXT.reset(__context_token) {{/service:supportedFunctions}} {{#service:lifecycleFunctions}} cdef api void call_cy_{{service:name}}_{{function:name}}( object self, cFollyPromise[{{#function:return_type}}{{! }}{{> services/cython_return_type_cpp_type}}{{! }}{{/function:return_type}}]{{! }} cPromise ) noexcept: {{#function:return_type}} cdef {{> services/promise_name}} __promise = {{> services/promise_name}}._fbthrift_create(cmove(cPromise)) {{/function:return_type}} asyncio.get_event_loop().create_task( {{service:name}}_{{function:name}}_coro( self, __promise ) ) {{/service:lifecycleFunctions}} {{#service:supportedFunctionsWithLifecycle}} async def {{service:name}}_{{function:name}}_coro( object self, {{#function:return_type}}{{> services/promise_name}}{{/function:return_type}}{{! }} promise{{#function:args}}, {{field:py_name}}{{/function:args}} ): try: result = {{#function:return_type}}{{^function:stream?}}await {{/function:stream?}}{{/function:return_type}}self.{{function:name}}({{#function:args}} {{field:py_name}}{{^last?}},{{/last?}}{{/function:args}}) {{#function:return_type}} {{#type:container?}} result = {{> types/cython_python_type}}(result) {{/type:container?}} {{#function:stream?}} {{#function:stream_has_first_response?}} result = await result item, result = result {{/function:stream_has_first_response?}} if not isinstance(result, (ServerStream, AsyncIterator)): result = await result if isinstance(result, AsyncIterator): {{#function:stream_elem_type}} result = ServerStream_{{> types/cython_cpp_type_ident}}._fbthrift_create(cmove(createAsyncIteratorFromPyIterator[{{ >types/cython_cpp_type}}](result, get_executor(), &getNextGenerator_{{service:name}}_{{function:name}}))) {{/function:stream_elem_type}} {{/function:stream?}} {{/function:return_type}} {{#function:exceptions}} {{#field:type}} except {{> types/cython_python_type}} as ex: promise.cPromise.setException(deref((<{{> types/cython_python_type}}> ex)._cpp_obj)) {{/field:type}} {{/function:exceptions}} except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler {{service:name}}.{{function:name}}:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler {{service:name}}.{{function:name}}:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue({{#function:return_type}}{{> services/cython_return_value}}{{/function:return_type}}) {{/service:supportedFunctionsWithLifecycle}} {{/program:services}} )__FBTHRIFT_TAG__", // py3/services/cpp_field_capture.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! defines how a variable in a field should be passed into another c++ function from the current function. ie, when calling some_func(a, b, c), the variables a, b, and c would be written using this file. Most variables can be passed as themselves by value, but the complex types are unique_ptr values and need to be moved to the called function. }}{{#type:bool?}}{{field:cppName}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:cppName}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:cppName}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:cppName}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:cppName}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:cppName}}{{/type:double?}}{{! }}{{#type:float?}}{{field:cppName}}{{/type:float?}}{{! }}{{#type:string?}}{{field:cppName}} = std::move({{field:cppName}}){{/type:string?}}{{! }}{{#type:binary?}}{{field:cppName}} = {{! }}{{^type:iobufRef?}}std::move({{field:cppName}}){{/type:iobufRef?}}{{! }}{{#type:iobufRef?}}{{! }}{{#function:stack_arguments?}}{{field:cppName}}->clone(){{/function:stack_arguments?}}{{! }}{{^function:stack_arguments?}}std::move({{field:cppName}}){{/function:stack_arguments?}}{{! }}{{/type:iobufRef?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct?}}{{field:cppName}} = std::move({{field:cppName}}){{/type:struct?}}{{! }}{{#type:list?}}{{field:cppName}} = std::move({{field:cppName}}){{/type:list?}}{{! }}{{#type:set?}}{{field:cppName}} = std::move({{field:cppName}}){{/type:set?}}{{! }}{{#type:map?}}{{field:cppName}} = std::move({{field:cppName}}){{/type:map?}}{{! }}{{#type:enum?}}{{field:cppName}}{{/type:enum?}} )__FBTHRIFT_TAG__", // py3/services/cpp_handler_callback_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used for overriding methods with (thread="eb") annotation }}{{#function:oneway?}}apache::thrift::HandlerCallbackBase::Ptr{{/function:oneway?}}{{! }}{{^function:oneway?}}apache::thrift::HandlerCallbackPtr<{{#function:return_type}}{{! }}{{#type:void?}}void{{/type:void?}}{{! }}{{^type:void?}}{{> services/cpp_return_type}}{{/type:void?}}{{! }}{{/function:return_type}}>{{/function:oneway?}} )__FBTHRIFT_TAG__", // py3/services/cpp_pass_field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! defines how a variable in a field should be passed into another c++ function from the current function. ie, when calling some_func(a, b, c), the variables a, b, and c would be written using this file. Most variables can be passed as themselves by value, but the complex types are unique_ptr values and need to be moved to the called function. }}{{#type:bool?}}{{field:cppName}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:cppName}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:cppName}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:cppName}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:cppName}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:cppName}}{{/type:double?}}{{! }}{{#type:float?}}{{field:cppName}}{{/type:float?}}{{! }}{{#type:string?}}std::move({{field:cppName}}){{/type:string?}}{{! }}{{#type:binary?}}std::move({{field:cppName}}){{/type:binary?}}{{! }}{{#type:struct?}}std::move({{field:cppName}}){{/type:struct?}}{{! }}{{#type:container?}}std::move({{field:cppName}}){{/type:container?}}{{! }}{{#type:enum?}}{{field:cppName}}{{/type:enum?}} )__FBTHRIFT_TAG__", // py3/services/cpp_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Cpp type for return_type in services }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}apache::thrift::ResponseAndServerStream<{{! }}{{#function:stream_first_response_type}}{{ >types/cpp_value_type}}{{/function:stream_first_response_type}},{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}apache::thrift::ServerStream<{{/function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >types/cpp_value_type}}{{/function:stream_elem_type}}>{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{^function:stack_arguments?}}{{> types/cpp_arg_type}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cpp_value_type}}{{/function:stack_arguments?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/services/cython_cpp_to_python.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used in cases where we have a C++ object defined in Cython code and we need to create or return a Python object. For complex objects, a Python wrapper is initialized; for simple objects it can be returned directly. Strings need to be converted from unicode to binary representation. }}{{#type:iobuf?}}_fbthrift_iobuf.from_unique_ptr(move_iobuf({{field:py_name}})){{/type:iobuf?}}{{! }}{{#type:iobufRef?}}_fbthrift_iobuf.from_unique_ptr(move_iobuf(deref({{field:py_name}}))){{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}(deref({{field:py_name}}).data())[:deref({{field:py_name}}).size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}{{field:py_name}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:py_name}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:py_name}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:py_name}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:py_name}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:py_name}}{{/type:double?}}{{! }}{{#type:float?}}{{field:py_name}}{{/type:float?}}{{! }}{{#type:string?}}(deref({{field:py_name}})).data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}(deref({{field:py_name}})){{/type:binary?}}{{! }}{{#type:struct?}}{{> types/cython_python_type}}._fbthrift_create({{! }}shared_ptr[{{> types/cython_cpp_type}}]({{field:py_name}}.release())){{/type:struct?}}{{! }}{{#type:container?}}{{> types/cython_python_type}}._fbthrift_create({{! }}__to_shared_ptr(cmove({{field:py_name}}))){{/type:container?}}{{! }}{{#type:enum?}}{{> types/cython_python_type}}( {{field:py_name}}){{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/services/cython_field_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used to define the type for a reference to a C++ object in a Cython template. It is used in pxd files to wrap the same types as types/cpp_arg_type.mustache. It is used in pyx to cast an unknown type. It is used to define argument types and return types in Cython code. }}{{#type:string?}}unique_ptr[{{/type:string?}}{{! }}{{#type:binary?}}unique_ptr[{{/type:binary?}}{{! }}{{#type:struct?}}unique_ptr[{{/type:struct?}}{{! }}{{#type:container?}}unique_ptr[{{/type:container?}}{{! }}{{> types/cython_cpp_type}}{{! }}{{#type:string?}}]{{/type:string?}}{{! }}{{#type:binary?}}]{{/type:binary?}}{{! }}{{#type:struct?}}]{{/type:struct?}}{{! }}{{#type:container?}}]{{/type:container?}}{{! }} )__FBTHRIFT_TAG__", // py3/services/cython_return_type_cpp_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Cython type for return_type in services }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}cResponseAndServerStream[{{! }}{{#function:stream_first_response_type}}{{ >types/cython_cpp_type}}{{/function:stream_first_response_type}},{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}cServerStream[{{! }}{{/function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >types/cython_cpp_type}}{{/function:stream_elem_type}}]{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{^function:stack_arguments?}}{{> services/cython_field_type}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cython_cpp_type}}{{/function:stack_arguments?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/services/cython_return_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Called specifically when setting the result on a promise. It casts the Python value returned by the coroutine into the appropriate format to be returned to the client. }}{{#type:iobuf?}}{{! }}{{#function:stack_arguments?}}deref{{/function:stack_arguments?}}{{! }}((<_fbthrift_iobuf.IOBuf>result).c_clone()){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}{{^function:stack_arguments?}}make_unique[unique_ptr[_fbthrift_iobuf.cIOBuf]]({{/function:stack_arguments?}}{{! }}((<_fbthrift_iobuf.IOBuf>result).c_clone()){{! }}{{^function:stack_arguments?}}){{/function:stack_arguments?}}{{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}{{#function:stack_arguments?}}{{> types/cython_cpp_type}}({{/function:stack_arguments?}}{{! }}{{^function:stack_arguments?}}make_unique[{{> types/cython_cpp_type}}]({{/function:stack_arguments?}}{{! }}cmove(result)){{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}} result{{/type:bool?}}{{! }}{{#type:byte?}} result{{/type:byte?}}{{! }}{{#type:i16?}} result{{/type:i16?}}{{! }}{{#type:i32?}} result{{/type:i32?}}{{! }}{{#type:i64?}} result{{/type:i64?}}{{! }}{{#type:double?}} result{{/type:double?}}{{! }}{{#type:float?}} result{{/type:float?}}{{! }}{{#type:string?}}{{! }}{{^function:stack_arguments?}}make_unique[{{> types/cython_cpp_type}}]({{/function:stack_arguments?}}{{! }} result.encode('UTF-8'){{! }}{{^function:stack_arguments?}}){{/function:stack_arguments?}}{{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{^function:stack_arguments?}}make_unique[{{> types/cython_cpp_type}}]({{/function:stack_arguments?}}{{! }} result{{! }}{{^function:stack_arguments?}}){{/function:stack_arguments?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{^function:stack_arguments?}}make_unique[{{> types/cython_cpp_type}}]({{/function:stack_arguments?}}{{! }}deref((<{{> types/cython_python_type}}?> result)._cpp_obj){{! }}{{^function:stack_arguments?}}){{/function:stack_arguments?}}{{! }}{{/type:struct}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}createResponseAndServerStream[{{! }}{{#function:stream_first_response_type}}{{ >types/cython_cpp_type}}{{/function:stream_first_response_type}},{{! }}{{#function:stream_elem_type}}{{ >types/cython_cpp_type}}{{/function:stream_elem_type}}]({{! }}{{#function:stream_first_response_type}}(<{{> types/cython_cpp_type}}?> {{> types/cython_python_to_cpp_item}}){{/function:stream_first_response_type}}, {{! }}{{/function:stream_has_first_response?}}{{! }}cmove(deref((types/cython_cpp_type_ident }}{{/function:stream_elem_type}}?>result).cStream)){{! }}{{#function:stream_has_first_response?}}){{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}{{#type:container?}}{{! }}{{^function:stack_arguments?}}make_unique[{{> types/cython_cpp_type}}]({{/function:stack_arguments?}}{{! }}deref((<{{> types/cython_python_type}}?> result)._cpp_obj){{! }}{{^function:stack_arguments?}}){{/function:stack_arguments?}}{{! }}{{/type:container?}}{{! }}{{#type:void?}}c_unit{{/type:void?}}{{! }}{{#type:enum?}}<{{> types/cython_cpp_type}}>result{{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/services/promise.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included from CythonServices.pyx, it defines a Python wrapper for each type of C++ promise that needs to be returned to C++. Cython doesn't support templating on Python classes. This file is necessary primarily because the cPromise shared_ptr needs to point to a promise that wraps a specific return type in C++. The Python wrapper then gets passed into a coroutine where the promise can have it's value set after the handler coroutine has finished executing. }} {{#program:unique_functions_by_return_type}} {{#function:return_type}} @cython.auto_pickle(False) cdef class {{> services/promise_name}}: cdef cFollyPromise[{{! }}{{> services/cython_return_type_cpp_type}}{{! }}]* cPromise def __cinit__(self): self.cPromise = new cFollyPromise[{{! }}{{> services/cython_return_type_cpp_type}}{{! }}](cFollyPromise[{{! }}{{> services/cython_return_type_cpp_type}}{{! }}].makeEmpty()) def __dealloc__(self): del self.cPromise @staticmethod cdef _fbthrift_create(cFollyPromise[{{! }}{{> services/cython_return_type_cpp_type}}{{! }}] cPromise): cdef {{> services/promise_name}} inst = {{> services/promise_name}}.__new__({{! }}{{> services/promise_name}}) inst.cPromise[0] = cmove(cPromise) return inst {{/function:return_type}} {{/program:unique_functions_by_return_type}} )__FBTHRIFT_TAG__", // py3/services/promise_name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included from Promises.mustache and Callbacks.mustache. Defines the Promise class name for a return type. }}{{! }}Promise{{#function:stack_arguments?}}__sa{{/function:stack_arguments?}}_{{> types/cython_cpp_return_type_ident}} )__FBTHRIFT_TAG__", // py3/services/return_type_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is to override types/pep484_type for stream return types. This is useful for typing call paterns since it allows python container types OR thrift-py3 specific container types. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}_typing.Tuple[{{#function:stream_first_response_type}}{{! }}{{> types/pep484_type}}, {{/function:stream_first_response_type}}{{/function:stream_has_first_response?}}{{! }}_typing.Union[_typing.Awaitable[_typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None]],{{! }}_typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None]]{{! }}{{#function:stream_has_first_response?}}]{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{> types/pep484_type}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/services/stream_response_class_name.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Stream response class name. }}{{type:modulePath}}.{{! }}{{#function:stream_has_first_response?}}{{! }}ResponseAndServerStream__{{> stream/response_class_name_suffix}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}{{! }}ServerStream__{{#function:stream_elem_type}}{{type:flat_name}}{{/function:stream_elem_type}}{{! }}{{/function:stream_has_first_response?}} )__FBTHRIFT_TAG__", // py3/services_reflection.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Reflection functions for clients and services }} {{> common/auto_generated_py}} from thrift.py3.reflection cimport ( InterfaceSpec as __InterfaceSpec, ) {{#program:services}} cdef __InterfaceSpec get_reflection__{{service:name}}(bint for_clients) cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_handlers.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": cdef cppclass c{{service:cpp_name}}SvIf {{! }}"::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{! }}{{service:cpp_name}}SvIf": pass {{/program:services}} )__FBTHRIFT_TAG__", // py3/services_reflection.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Reflection functions for clients and services }} {{> common/auto_generated_py}} from thrift.py3.reflection cimport ( MethodSpec as __MethodSpec, ArgumentSpec as __ArgumentSpec, NumberType as __NumberType, ) import folly.iobuf as _fbthrift_iobuf {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:services}} cdef __InterfaceSpec get_reflection__{{service:name}}(bint for_clients): cdef __InterfaceSpec spec = __InterfaceSpec._fbthrift_create( name="{{service:name}}", annotations={ {{#service:annotations}} {{> common/annotation }} {{/service:annotations}} }, ) {{#service:supportedFunctions}} spec.add_method( __MethodSpec._fbthrift_create( name="{{function:name}}", arguments=( {{#function:args}} __ArgumentSpec._fbthrift_create( name="{{field:name}}", type={{#field:type}}{{> types/python_type}}{{/field:type}}, kind={{#field:type}}{{> types/thrift_number_type}}{{/field:type}}, annotations={ {{#field:annotations}} {{> common/annotation }} {{/field:annotations}} }, ), {{/function:args}} ), result={{#function:return_type}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#function:stream?}}{{! }}{{> clients/stream_response_class_name}} if for_clients else {{! }}{{> services/stream_response_class_name}}{{! }}{{/function:stream?}}{{! }}{{^type:void?}}{{> types/python_type}}{{/type:void?}}{{! }}{{/function:return_type}}, result_kind={{#function:return_type}}{{> types/thrift_number_type}}{{/function:return_type}}, exceptions=( {{#function:exceptions}} {{#field:type}}{{> types/python_type}}{{/field:type}}, {{/function:exceptions}} ), annotations={ {{#function:annotations}} {{> common/annotation }} {{/function:annotations}} }, ) ) {{/service:supportedFunctions}} return spec {{/program:services}} )__FBTHRIFT_TAG__", // py3/services_wrapper.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a top level C++ file that generates an implementation of the C++ Services interface. That implementation keeps a pointer to a Pyobject, which is supposed to be the Python handler for that service, as written by the end user. The life cycle of the handler is managed by the thrift server. It has lightweight wrappers of each service method (which accept futures) that pass the python object and a promise return code into the functions defined in ServicesCallbacks, along with appropriate arguments. }} {{> common/auto_generated_c}} #include <{{program:includePrefix}}gen-py3/{{program:name}}/services_wrapper.h> #include <{{program:includePrefix}}gen-py3/{{program:name}}/{{> common/auto_migrate_prefix}}services_api.h> #include {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} {{#program:services}} {{^service:extends?}} {{service:name}}Wrapper::{{service:name}}Wrapper(PyObject *obj, folly::Executor* exc) : if_object(obj), executor(exc) { import_{{#program:py3Namespaces}}{{value}}__{{/program:py3Namespaces}}{{program:name}}__{{> common/auto_migrate_prefix}}services(); } {{/service:extends?}} {{#service:extends?}} {{service:name}}Wrapper::{{service:name}}Wrapper(PyObject *obj, folly::Executor* exc) : {{#service:extends}}::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:name}}Wrapper(obj, exc){{/service:extends}} { import_{{#program:py3Namespaces}}{{value}}__{{/program:py3Namespaces}}{{program:name}}__{{> common/auto_migrate_prefix}}services(); } {{/service:extends?}} {{#service:supportedFunctions}} void {{service:name}}Wrapper::async_{{#function:eb}}eb{{/function:eb}}{{^function:eb}}tm{{/function:eb}}_{{function:cppName}}( {{> services/cpp_handler_callback_type}} callback{{#function:args}} , {{#field:type}}{{! }}{{^function:stack_arguments?}}{{> types/cpp_arg_type}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cpp_stack_arg_type}}{{/function:stack_arguments?}}{{! }}{{/field:type}} {{field:cppName}}{{#last?}} {{/last?}}{{/function:args}}) { auto ctx = callback->getRequestContext(); folly::via( this->executor, [this, ctx, callback = std::move(callback){{#function:args}}, {{#field:type}}{{> services/cpp_field_capture}}{{/field:type}}{{/function:args}} ]() mutable { auto [promise, future] = folly::makePromiseContract<{{! }}{{#function:return_type}}{{> services/cpp_return_type}}{{/function:return_type}}>(); call_cy_{{service:name}}_{{function:name}}( this->if_object, ctx, std::move(promise){{#function:args}}{{#field:type}}, {{> services/cpp_pass_field}} {{/field:type}}{{/function:args}} ); std::move(future).via(this->executor).thenTry([callback = std::move(callback)](folly::Try<{{! }}{{#function:return_type}}{{> services/cpp_return_type}}{{/function:return_type}}>&& t) { (void)t; {{^function:oneway?}}callback->complete(std::move(t));{{/function:oneway?}} }); }); } {{/service:supportedFunctions}} {{#service:interactions}} std::unique_ptr<{{service:parent_service_cpp_name}}SvIf::{{service:name}}If> {{service:parent_service_name}}Wrapper::create{{service:name}}() { throw std::runtime_error("Py3 server doesn't support interactions."); } {{/service:interactions}} std::shared_ptr {{service:name}}Interface(PyObject *if_object, folly::Executor *exc) { return std::make_shared<{{service:name}}Wrapper>(if_object, exc); } {{#service:lifecycleFunctions}} folly::SemiFuture {{service:name}}Wrapper::semifuture_{{function:cppName}}() { auto [promise, future] = folly::makePromiseContract(); call_cy_{{service:name}}_{{function:cppName}}( this->if_object, std::move(promise) ); return std::move(future); } {{/service:lifecycleFunctions}} {{^last?}} {{/last?}} {{/program:services}}{{! }}{{#program:cppNamespaces}} } // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/services_wrapper.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Header file for ServicesWrapper.Cpp. It's a subclass of the service interface created by the thrift compiler for generated cpp2 code. }} {{> common/auto_generated_c}} #pragma once {{#program:services}} #if __has_include(<{{program:includePrefix}}{{program:cpp_gen_path}}/{{service:name}}.h>) #include <{{program:includePrefix}}{{program:cpp_gen_path}}/{{service:name}}.h> #else #include <{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_handlers.h> #endif {{#service:extends}} {{#service:externalProgram?}} #include <{{service:includePrefix}}gen-py3/{{service:programName}}/services_wrapper.h> {{/service:externalProgram?}} {{/service:extends}} {{/program:services}} #include #include #include {{#program:cppNamespaces}}namespace {{value}} { {{/program:cppNamespaces}} {{#program:services}} class {{service:name}}Wrapper : {{! }}{{#service:extends}}public ::{{#service:cppNamespaces}}{{value}}::{{/service:cppNamespaces}}{{service:name}}Wrapper, {{/service:extends}}{{! }}virtual public {{service:cpp_name}}SvIf{{! }} { {{^service:extends?}} protected: PyObject *if_object; folly::Executor *executor; {{/service:extends?}} public: explicit {{service:name}}Wrapper(PyObject *if_object, folly::Executor *exc); {{#service:supportedFunctions}} void async_{{#function:eb}}eb{{/function:eb}}{{^function:eb}}tm{{/function:eb}}_{{function:cppName}}({{> services/cpp_handler_callback_type}} callback{{#function:args}} , {{#field:type}}{{! }}{{^function:stack_arguments?}}{{> types/cpp_arg_type}}{{/function:stack_arguments?}}{{! }}{{#function:stack_arguments?}}{{> types/cpp_stack_arg_type}}{{/function:stack_arguments?}}{{! }}{{/field:type}} {{field:cppName}}{{#last?}} {{/last?}}{{/function:args}}) override; {{/service:supportedFunctions}} {{#service:interactions}} std::unique_ptr<{{service:name}}If> create{{service:name}}() override; {{/service:interactions}} {{#service:lifecycleFunctions}} folly::SemiFuture semifuture_{{function:cppName}}() override; {{/service:lifecycleFunctions}} }; std::shared_ptr {{service:name}}Interface(PyObject *if_object, folly::Executor *exc); {{^last?}} {{/last?}} {{/program:services}}{{! }}{{#program:cppNamespaces}} } // namespace {{value}} {{/program:cppNamespaces}} )__FBTHRIFT_TAG__", // py3/services_wrapper.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Pxd file to expose the interface defined in ServicesWrapper.h to the pyx files. }} {{> common/auto_generated_py}} from cpython.ref cimport PyObject from libcpp.memory cimport shared_ptr from thrift.py3.server cimport cAsyncProcessorFactory from folly cimport cFollyExecutor cdef extern from "{{program:includePrefix}}gen-py3/{{program:name}}/services_wrapper.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": {{#program:services}} shared_ptr[cAsyncProcessorFactory] c{{service:name}}Interface {{! }}"::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{! }}{{service:name}}Interface"(PyObject *if_object, cFollyExecutor* Q) except * {{/program:services}} {{^program:services}} pass {{/program:services}} )__FBTHRIFT_TAG__", // py3/stream/cython_cpp_value_to_python_value.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used in semistream object callbacks to convert the returned cpp folly::optional value type to a python type. }}{{#type:iobuf?}}{{! }}_fbthrift_iobuf.from_unique_ptr(_value){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}_fbthrift_iobuf.from_unique_ptr(move_iobuf(_value)){{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}(_value.data())[:_value.size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}_value{{/type:bool?}}{{! }}{{#type:byte?}}_value{{/type:byte?}}{{! }}{{#type:i16?}}_value{{/type:i16?}}{{! }}{{#type:i32?}}_value{{/type:i32?}}{{! }}{{#type:i64?}}_value{{/type:i64?}}{{! }}{{#type:double?}}_value{{/type:double?}}{{! }}{{#type:float?}}_value{{/type:float?}}{{! }}{{#type:string?}}_value.data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}_value{{/type:binary?}}{{! }}{{#type:struct}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}_value)){{/type:struct}}{{! }}{{#type:container?}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}_value)){{/type:container?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{> types/cython_python_type}}( _value){{/type:enum}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/stream/response_class_name_suffix.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used to construct stream response class name as a suffix as a unique identification. }}{{#function:stream_first_response_type}}{{type:flat_name}}{{/function:stream_first_response_type}}_{{! }}{{#function:stream_elem_type}}{{type:flat_name}}{{/function:stream_elem_type}} )__FBTHRIFT_TAG__", // py3/stream/stream_promises.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included from CythonServices.pyx, it defines a Python wrapper for each type of C++ promise that needs to be returned to C++. Cython doesn't support templating on Python classes. This file is necessary primarily because the cPromise shared_ptr needs to point to a promise that wraps a specific return type in C++. The Python wrapper then gets passed into a coroutine where the promise can have it's value set after the handler coroutine has finished executing. }} {{#program:stream_types}} @cython.auto_pickle(False) cdef class Promise_{{> types/cython_cpp_return_type_ident}}_Stream: cdef cFollyPromise[optional[{{! }}{{> types/cython_cpp_type}}{{! }}]] cPromise @staticmethod cdef _fbthrift_create(cFollyPromise[optional[{{! }}{{> types/cython_cpp_type}}{{! }}]] cPromise): cdef Promise_{{> types/cython_cpp_return_type_ident}}_Stream inst = Promise_{{> types/cython_cpp_return_type_ident}}_Stream.__new__({{! }}Promise_{{> types/cython_cpp_return_type_ident}}_Stream) inst.cPromise = cmove(cPromise) return inst {{/program:stream_types}} )__FBTHRIFT_TAG__", // py3/types.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! C++ header to store py3 specific Enum and Union type enum data }} {{> common/auto_generated_c}} #pragma once #include #include #include #include "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_data.h" #include "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_types.h" #include "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_metadata.h" namespace thrift { namespace py3 { {{#program:enums}} template<> inline const std::vector>& PyEnumTraits< {{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{enum:cpp_name}}>::namesmap() { static const folly::Indestructible pairs { { {{#enum:values}}{{#enum_value:hasPyName?}} {"{{enum_value:py_name}}", "{{enum_value:name}}"}, {{/enum_value:hasPyName?}}{{/enum:values}} } }; return *pairs; } {{/program:enums}} {{#program:filtered_structs}} {{#struct:union?}} template<> inline const std::vector>& PyEnumTraits< {{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{struct:name}}::Type>::namesmap() { static const folly::Indestructible pairs { { {{#struct:py3_fields}}{{#field:hasPyName?}} {"{{field:py_name}}", "{{field:name}}"}, {{/field:hasPyName?}}{{/struct:py3_fields}} } }; return *pairs; } {{/struct:union?}} {{/program:filtered_structs}} {{#program:filtered_structs}} {{^struct:union?}} template<> inline void reset_field<{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{struct:name}}>( {{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{struct:name}}& obj, uint16_t index) { switch (index) { {{#struct:py3_fields}} case {{field:index}}: {{^field:reference?}} obj.{{> types/field_cppname}}().copy_from(default_inst<{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{struct:name}}>().{{> types/field_cppname}}()); {{/field:reference?}} {{#field:reference?}} obj.{{> types/field_cppname}}(){{^field:iobuf_ref?}}.{{/field:iobuf_ref?}}{{#field:iobuf_ref?}}->{{/field:iobuf_ref?}}reset(); {{/field:reference?}} return; {{/struct:py3_fields}} } } {{/struct:union?}} {{/program:filtered_structs}} {{#program:filtered_structs}} template<> inline const std::unordered_map& PyStructTraits< {{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}::{{struct:name}}>::namesmap() { static const folly::Indestructible map { { {{#struct:py3_fields}}{{#field:hasPyName?}} {"{{field:name}}", "{{field:py_name}}"}, {{/field:hasPyName?}}{{/struct:py3_fields}} } }; return *map; } {{/program:filtered_structs}} } // namespace py3 } // namespace thrift )__FBTHRIFT_TAG__", // py3/types.pxd.mustache R"__FBTHRIFT_TAG__({{#program:auto_migrate?}} {{> common/auto_generated_py}} {{#program:no_auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_types cimport * {{/program:no_auto_migrate?}} {{^program:no_auto_migrate?}} {{> types/cimport_extern }} {{#program:cppIncludes}} cdef extern from "{{.}}": pass {{/program:cppIncludes}}{{! }}{{#program:customTemplates}} {{> types/custom_template}} {{/program:customTemplates}}{{! }}{{#program:customTypes}} {{> types/custom_type}} {{/program:customTypes}} {{> types/enum_extern }} {{> types/struct_extern }} {{> types/constant_extern }} {{/program:no_auto_migrate?}} {{/program:auto_migrate?}} {{^program:auto_migrate?}} {{> py3_types.pxd }} {{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // py3/types.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} {{^program:no_auto_migrate?}}from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{! }}thrift_types import *{{/program:no_auto_migrate?}} {{#program:no_auto_migrate?}} from {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.py3_types import * {{/program:no_auto_migrate?}} )__FBTHRIFT_TAG__", // py3/types.pyi.mustache R"__FBTHRIFT_TAG__({{> py3_types.pyi }} )__FBTHRIFT_TAG__", // py3/types.pyx.mustache R"__FBTHRIFT_TAG__({{ > py3_types.pyx }} )__FBTHRIFT_TAG__", // py3/types/cimport_extern.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for exposing cimports needed for binding cpp extern in .pxd }} from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, uint32_t as cuint32_t, ) from libcpp.string cimport string from libcpp cimport bool as cbool, nullptr, nullptr_t from cpython cimport bool as pbool from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.vector cimport vector from libcpp.set cimport set as cset from libcpp.map cimport map as cmap, pair as cpair from thrift.py3.exceptions cimport cTException cimport folly.iobuf as _fbthrift_iobuf from thrift.py3.types cimport ( bstring, field_ref as __field_ref, optional_field_ref as __optional_field_ref, required_field_ref as __required_field_ref, terse_field_ref as __terse_field_ref, union_field_ref as __union_field_ref, get_union_field_value as __get_union_field_value, ) from thrift.py3.common cimport cThriftMetadata as __fbthrift_cThriftMetadata {{#program:includeNamespaces}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/program:includeNamespaces}} )__FBTHRIFT_TAG__", // py3/types/compatible_pep484_containers.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Produce the pep484 container type for a given thrift-py3 container }}{{#type:list?}}_typing.Sequence[{{! }}{{#type:list_elem_type}}{{> types/compatible_pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}_typing.AbstractSet[{{! }}{{#type:set_elem_type}}{{> types/compatible_pep484_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}_typing.Mapping[{{! }}{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> types/compatible_pep484_type}}{{/type:value_type}}{{! }}]{{/type:map?}} )__FBTHRIFT_TAG__", // py3/types/compatible_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-py3 specific container types. }}{{#program:intercompatible?}}{{! }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobufWrapper?}}_fbthrift_iobuf.IOBuf{{/type:iobufWrapper?}}{{! }}{{^type:iobufWrapper?}}bytes{{/type:iobufWrapper?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{> common/python_types_module_path}}._fbthrift_compatible_with_{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}{{> types/compatible_pep484_containers}}{{! }}{{/type:container?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{> common/python_types_module_path}}._fbthrift_compatible_with_{{enum:name}}{{! }}{{/type:enum}}{{! }}{{/program:intercompatible?}}{{! }}{{^program:intercompatible?}}{{! }}{{> types/pep484_type}}{{! }}{{/program:intercompatible?}} )__FBTHRIFT_TAG__", // py3/types/constant_extern.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for exposing cpp constants in .pxd }} {{#program:constants}} {{#first?}} cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_constants.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": {{/first?}} {{#constant:type}} cdef {{^type:string?}}{{> types/cython_cpp_type}}{{/type:string?}}{{#type:string?}}const char*{{/type:string?}} {{! }}c{{constant:name}} "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{program:name}}_constants::{{constant:name}}"{{! }}{{#type:struct?}}(){{/type:struct?}}{{#type:string?}}(){{/type:string?}}{{#type:binary?}}(){{/type:binary?}}{{#type:container?}}(){{/type:container?}}{{#type:enum?}}(){{/type:enum?}} {{/constant:type}}{{/program:constants}} )__FBTHRIFT_TAG__", // py3/types/constant_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Definitions for constant values. These are included from the struct.pyx file and define Python objects that can be imported from the end-user's Python file. }} {{#constant:type}}{{! }} {{#type:bool?}} {{constant:name}} = {{#constant:value}}{{! }}{{#value:nonzero?}}True{{/value:nonzero?}}{{! }}{{^value:nonzero?}}False{{/value:nonzero?}}{{/constant:value}} {{/type:bool?}} {{#type:byte?}} {{constant:name}} = {{#constant:value}}{{value:integer_value}}{{/constant:value}} {{/type:byte?}} {{#type:i16?}} {{constant:name}} = {{#constant:value}}{{value:integer_value}}{{/constant:value}} {{/type:i16?}} {{#type:i32?}} {{constant:name}} = {{#constant:value}}{{value:integer_value}}{{/constant:value}} {{/type:i32?}} {{#type:i64?}} {{constant:name}} = {{#constant:value}}{{value:integer_value}}{{/constant:value}} {{/type:i64?}} {{#type:double?}} {{constant:name}} = {{#constant:value}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{/constant:value}} {{/type:double?}} {{#type:float?}} {{constant:name}} = {{#constant:value}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{/constant:value}} {{/type:float?}} {{#type:string?}} {{constant:name}} = c{{constant:name}}().decode('UTF-8') {{/type:string?}} {{#type:binary?}} {{constant:name}} = c{{constant:name}}() {{/type:binary?}} {{! We take the constant structs/containers and build a non-const shared_ptr as required by the thrift-py3 wrapper api, generally this is a terrible idea as constant() is an r-value, and removing the const qualifier is dangerous but we *promise* in the thrift-py3 api to never change objects. }} {{#type:struct?}} {{constant:name}} = {{> types/cython_python_type}}._fbthrift_create(constant_shared_ptr({{! }}c{{constant:name}}())) {{/type:struct?}} {{#type:container?}} {{constant:name}} = {{> types/cython_python_type}}._fbthrift_create(constant_shared_ptr({{! }}c{{constant:name}}())) {{/type:container?}} {{#type:enum}} {{constant:name}} = {{#type:need_module_path?}}{{type:modulePath}}.{{! }}{{/type:need_module_path?}}{{enum:name}}( (c{{constant:name}}())) {{/type:enum}} {{/constant:type}} )__FBTHRIFT_TAG__", // py3/types/container_cython_cpp_to_python_item.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Usually included in places where a container item is being processed. You have access to a C object and need to return or convert it to a Python object. The type in this case is probably a type:list_elem_type, type:set_elem_type, type:key_type, or type:value_type. By convention, it assumes the c++ structure that is being manipulated is named citem. }}{{#type:iobuf?}}{{! }}_fbthrift_iobuf.IOBuf.create(citem.get(), self){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}_fbthrift_iobuf.IOBuf.create(citem.get().get(), self){{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}(citem.data())[:citem.size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}citem{{/type:bool?}}{{! }}{{#type:byte?}}citem{{/type:byte?}}{{! }}{{#type:i16?}}citem{{/type:i16?}}{{! }}{{#type:i32?}}citem{{/type:i32?}}{{! }}{{#type:i64?}}citem{{/type:i64?}}{{! }}{{#type:double?}}citem{{/type:double?}}{{! }}{{#type:float?}}citem{{/type:float?}}{{! }}{{#type:string?}}bytes(citem).decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}bytes(citem){{/type:binary?}}{{! }}{{^type:base?}}{{^type:enum?}}{{! }}{{> types/cython_python_type}}._fbthrift_create(citem){{! }}{{/type:enum?}}{{/type:base?}}{{! }}{{#type:enum}}translate_cpp_enum_to_python({{! }}{{> types/cython_python_type}}, citem){{/type:enum}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/types/container_cython_cpp_to_python_key.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Usually included in places where a container item is being processed. You have access to a C object and need to return or convert it to a Python object. The type in this case is probably a type:list_elem_type, type:set_elem_type, type:key_type, or type:value_type. By convention, it assumes the c++ structure that is being manipulated is named ckey. }}{{#type:bool?}}ckey{{/type:bool?}}{{! }}{{#type:byte?}}ckey{{/type:byte?}}{{! }}{{#type:i16?}}ckey{{/type:i16?}}{{! }}{{#type:i32?}}ckey{{/type:i32?}}{{! }}{{#type:i64?}}ckey{{/type:i64?}}{{! }}{{#type:double?}}ckey{{/type:double?}}{{! }}{{#type:float?}}ckey{{/type:float?}}{{! }}{{#type:string?}}ckey.data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}ckey{{/type:binary?}}{{! }}{{^type:base?}}{{^type:enum?}}{{! }}{{> types/cython_python_type}}._fbthrift_create(ckey){{! }}{{/type:enum?}}{{/type:base?}}{{! }}{{#type:enum}}translate_cpp_enum_to_python({{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{enum:name}}, {{! }} ckey){{/type:enum}} )__FBTHRIFT_TAG__", // py3/types/cpp_arg_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used when a cpp type is passed as an argument - basic types are passed by value, and complex types are boxed in `std::unique_ptr`s. }}{{#type:string?}}std::unique_ptr<{{/type:string?}}{{! }}{{#type:binary?}}std::unique_ptr<{{/type:binary?}}{{! }}{{#type:struct}}std::unique_ptr<{{/type:struct}}{{! }}{{#type:container?}}std::unique_ptr<{{/type:container?}}{{! }}{{> types/cpp_value_type}}{{! }}{{#type:string?}}>{{/type:string?}}{{! }}{{#type:binary?}}>{{/type:binary?}}{{! }}{{#type:struct}}>{{/type:struct}}{{! }}{{#type:container?}}>{{/type:container?}} )__FBTHRIFT_TAG__", // py3/types/cpp_stack_arg_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used when a cpp type is passed as an argument with stack_arguments on complex types are passed in as const refs. }}{{#type:string?}}const {{/type:string?}}{{! }}{{#type:binary?}}const {{/type:binary?}}{{! }}{{#type:struct}}const {{/type:struct}}{{! }}{{#type:container?}}const {{/type:container?}}{{! }}{{> types/cpp_value_type}}{{! }}{{#type:string?}}&{{/type:string?}}{{! }}{{#type:binary?}}&{{/type:binary?}}{{! }}{{#type:struct}}&{{/type:struct}}{{! }}{{#type:container?}}&{{/type:container?}} )__FBTHRIFT_TAG__", // py3/types/cpp_value_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included in cpp files to define the type of a simple or contained struct, or anywhere else the type is used as a value directly. }}{{#type:hasCustomType?}}{{type:cppCustomType}}{{/type:hasCustomType?}}{{! }}{{^type:hasCustomType?}}{{! }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int8_t{{/type:byte?}}{{! }}{{#type:i16?}}int16_t{{/type:i16?}}{{! }}{{#type:i32?}}int32_t{{/type:i32?}}{{! }}{{#type:i64?}}int64_t{{/type:i64?}}{{! }}{{#type:double?}}double{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}std::string{{/type:string?}}{{! }}{{#type:binary?}}std::string{{/type:binary?}}{{! }}{{#type:enum}}{{! }}::{{#type:cppNamespaces}}{{value}}::{{/type:cppNamespaces}}{{enum:cpp_name}}{{! }}{{/type:enum}}{{! }}{{#type:struct}}{{! }}::{{#type:cppNamespaces}}{{value}}::{{/type:cppNamespaces}}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:list?}}{{! }}{{type:cppTemplate}}<{{! }}{{#type:list_elem_type}}{{> types/cpp_value_type}}{{/type:list_elem_type}}{{! }}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}{{type:cppTemplate}}<{{! }}{{#type:set_elem_type}}{{> types/cpp_value_type}}{{/type:set_elem_type}}{{! }}>{{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}{{type:cppTemplate}}<{{! }}{{#type:key_type}}{{> types/cpp_value_type}}{{/type:key_type}},{{! }}{{#type:value_type}}{{> types/cpp_value_type}}{{/type:value_type}}{{! }}>{{! }}{{/type:map?}}{{! }}{{#type:void?}}folly::Unit{{/type:void?}}{{! }}{{/type:hasCustomType?}} )__FBTHRIFT_TAG__", // py3/types/current_module_types.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types )__FBTHRIFT_TAG__", // py3/types/custom_template.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Appropriate extern defs for cpp.template alternate implementations of the various container types, used in the appropriate .pxd file. }} {{#type:list?}} cdef extern from * nogil: cdef cppclass {{type:cythonTemplate}} "{{type:cppTemplate}}"[T]: ctypedef T value_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: T& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: T& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonTemplate}}() except + {{type:cythonTemplate}}({{type:cythonTemplate}}&) except + T& operator[](size_type) void push_back(T&) except + size_type size() iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:list?}} {{#type:set?}} cdef extern from * nogil: cdef cppclass {{type:cythonTemplate}} "{{type:cppTemplate}}"[T]: ctypedef T value_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: T& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: T& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonTemplate}}() except + {{type:cythonTemplate}}({{type:cythonTemplate}}&) except + cpair[iterator, bint] insert(const T&) except + size_type size() size_type count(const T&) iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:set?}} {{#type:map?}} cdef extern from * nogil: cdef cppclass {{type:cythonTemplate}} "{{type:cppTemplate}}"[T, U]: ctypedef T key_type ctypedef U mapped_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: cpair[T, U]& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: cpair[T, U]& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonTemplate}}() except + {{type:cythonTemplate}}({{type:cythonTemplate}}&) except + U& operator[](T&) iterator find(const T&) const_iterator const_find "find"(const T&) size_type count(const T&) size_type size() iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:map?}} )__FBTHRIFT_TAG__", // py3/types/custom_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Appropriate extern defs for cpp.type alternate implementations of the various container types, used in the appropriate .pxd file. Note that this file may get used when the type is not a container, in which case it just provides a typedef instead of a full class definition. }} {{#type:list?}} cdef extern from * nogil: cdef cppclass {{type:cythonCustomType}} "{{type:cppCustomType}}": ctypedef {{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}} value_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: {{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}}& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: {{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}}& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonCustomType}}() except + {{type:cythonCustomType}}({{type:cythonCustomType}}&) except + {{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}}& operator[](size_type) void push_back({{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}}&) except + size_type size() iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:list?}} {{#type:set?}} cdef extern from * nogil: cdef cppclass {{type:cythonCustomType}} "{{type:cppCustomType}}": ctypedef {{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}} value_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: {{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}}& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: {{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}}& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonCustomType}}() except + {{type:cythonCustomType}}({{type:cythonCustomType}}&) except + cpair[iterator, bint] insert(const {{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}}&) except + size_type size() size_type count(const {{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}}&) iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:set?}} {{#type:map?}} cdef extern from * nogil: cdef cppclass {{type:cythonCustomType}} "{{type:cppCustomType}}": ctypedef {{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}} key_type ctypedef {{#type:value_type}}{{> types/cython_cpp_type}}{{/type:value_type}} mapped_type {{! see comment in https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd for context on why this is size_t }} ctypedef size_t size_type cppclass iterator: cpair[{{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}, {{#type:value_type}}{{> types/cython_cpp_type}}{{/type:value_type}}]& operator*() iterator operator++() bint operator==(iterator) bint operator!=(iterator) cppclass reverse_iterator: cpair[{{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}, {{#type:value_type}}{{> types/cython_cpp_type}}{{/type:value_type}}]& operator*() iterator operator++() bint operator==(reverse_iterator) bint operator!=(reverse_iterator) cppclass const_iterator(iterator): pass cppclass const_reverse_iterator(reverse_iterator): pass {{type:cythonCustomType}}() except + {{type:cythonCustomType}}({{type:cythonCustomType}}&) except + {{#type:value_type}}{{> types/cython_cpp_type}}{{/type:value_type}}& operator[]({{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}&) iterator find(const {{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}&) const_iterator const_find "find"(const {{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}&) size_type count(const {{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}}&) size_type size() iterator begin() const_iterator const_begin "begin"() iterator end() const_iterator const_end "end"() reverse_iterator rbegin() const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() const_reverse_iterator const_rend "rend"() void clear() bint empty() {{/type:map?}} {{^type:container?}}{{^type:iobufWrapper?}} cdef extern from *: ctypedef {{! }}{{#type:flexibleBinary?}}bstring{{/type:flexibleBinary?}}{{! }}{{^type:flexibleBinary?}}{{> types/cython_cpp_basic_type}}{{/type:flexibleBinary?}}{{! }} {{type:cythonCustomType}} "{{type:cppCustomType}}" {{/type:iobufWrapper?}}{{/type:container?}} )__FBTHRIFT_TAG__", // py3/types/cython_cast_or_create_python_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! cast a field to its Cython Python Type if not a container, otherwise create a container type with constructor }}{{^type:container?}}{{! }}(<{{> types/cython_python_type}}?>_fbthrift_value){{! }}{{/type:container?}}{{#type:container?}}{{! }}{{> types/cython_python_type }}(_fbthrift_value){{! }}{{/type:container?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_basic_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is used to declare a cython type that is referring to or wrapping a c++ object. Most of the values are direct references to variables imported from libcpp and friends. Structs are the special case, as they refer to the struct by name as defined in the pxd file, with a 'c' prefix. Structs and enums will be namespaced appropriately if they are either defined in a different thrift file, or defined in the same thrift file but this is in the client or server source rather than the type definition source. Note that you almost never want to include this file directly - use CythonCppType instead to use a custom type override when appropriate (from the cpp.type annotation). }}{{#type:bool?}}cbool{{/type:bool?}}{{! }}{{#type:byte?}}cint8_t{{/type:byte?}}{{! }}{{#type:i16?}}cint16_t{{/type:i16?}}{{! }}{{#type:i32?}}cint32_t{{/type:i32?}}{{! }}{{#type:i64?}}cint64_t{{/type:i64?}}{{! }}{{#type:double?}}double{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}string{{/type:string?}}{{! }}{{#type:binary?}}string{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}c{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{^type:defaultTemplate?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{/type:defaultTemplate?}}{{/type:container?}}{{! }}{{#type:list?}}{{type:cythonTemplate}}[{{! }}{{#type:list_elem_type}}{{> types/cython_cpp_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}{{type:cythonTemplate}}[{{! }}{{#type:set_elem_type}}{{> types/cython_cpp_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}{{type:cythonTemplate}}[{{! }}{{#type:key_type}}{{> types/cython_cpp_type}}{{/type:key_type}},{{! }}{{#type:value_type}}{{> types/cython_cpp_type}}{{/type:value_type}}{{! }}]{{/type:map?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}c{{enum:name}}{{! }}{{/type:enum}}{{! }}{{#type:void?}}cFollyUnit{{/type:void?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_return_type_ident.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> types/cython_cpp_type_ident}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}cResponseAndServerStream__{{! }}{{#function:stream_first_response_type}}{{ >types/cython_cpp_type_ident}}{{/function:stream_first_response_type}}_{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}cServerStream__{{! }}{{/function:stream_has_first_response?}}{{! }}{{#function:stream_elem_type}}{{ >types/cython_cpp_type_ident}}{{/function:stream_elem_type}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_struct_field_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is used to declare a cython type that is referring to or wrapping a c++ object specifically in the context of a field on a struct, which means it has to cope with the fields being annotated as cpp.ref or similar. Most of this is done in CythonCppType; this file just handles references and other wrappers. }}{{#field:unique_ref?}}unique_ptr[{{/field:unique_ref?}}{{! }}{{#field:shared_ref?}}shared_ptr[{{/field:shared_ref?}}{{! }}{{#field:shared_const_ref?}}shared_ptr[const {{/field:shared_const_ref?}}{{! }}{{> types/cython_cpp_type}}{{! }}{{#field:unique_ref?}}]{{/field:unique_ref?}}{{! }}{{#field:shared_ref?}}]{{/field:shared_ref?}}{{! }}{{#field:shared_const_ref?}}]{{/field:shared_const_ref?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is used to declare a cython type that is referring to or wrapping a c++ object. The work is mostly done in CythonCppBasicType, but this file handles custom type overrides from the cpp.type annotation. }}{{#type:hasCustomType?}}{{! }}{{#type:iobuf?}}_fbthrift_iobuf.cIOBuf{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}unique_ptr[_fbthrift_iobuf.cIOBuf]{{/type:iobufRef?}}{{! }}{{^type:iobuf?}}{{^type:iobufRef?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{type:cythonCustomType}}{{! }}{{/type:iobufRef?}}{{/type:iobuf?}}{{! }}{{/type:hasCustomType?}}{{! }}{{^type:hasCustomType?}}{{> types/cython_cpp_basic_type}}{{/type:hasCustomType?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_type_ident.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is the equivalent of CythonCpp[Basic]Type, for use as part of an identifier (like in the name of a Promise class), not as a standalone type }}{{#type:hasCustomType?}}{{! }}{{#type:iobuf?}}__iobuf_cIOBuf{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}unique_ptr__iobuf_cIOBuf{{/type:iobufRef?}}{{! }}{{^type:iobuf?}}{{^type:iobufRef?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}_{{/type:need_module_path?}}{{! }}{{type:cythonCustomType}}{{! }}{{/type:iobufRef?}}{{/type:iobuf?}}{{! }}{{/type:hasCustomType?}}{{! }}{{^type:hasCustomType?}}{{! }}{{#type:bool?}}cbool{{/type:bool?}}{{! }}{{#type:byte?}}cint8_t{{/type:byte?}}{{! }}{{#type:i16?}}cint16_t{{/type:i16?}}{{! }}{{#type:i32?}}cint32_t{{/type:i32?}}{{! }}{{#type:i64?}}cint64_t{{/type:i64?}}{{! }}{{#type:double?}}double{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}string{{/type:string?}}{{! }}{{#type:binary?}}binary{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}_{{/type:need_module_path?}}{{! }}c{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{^type:defaultTemplate?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}_{{/type:need_module_path?}}{{! }}{{/type:defaultTemplate?}}{{/type:container?}}{{! }}{{#type:list?}}{{type:cythonTemplate}}__{{! }}{{#type:list_elem_type}}{{> types/cython_cpp_type_ident}}{{/type:list_elem_type}}{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{type:cythonTemplate}}__{{! }}{{#type:set_elem_type}}{{> types/cython_cpp_type_ident}}{{/type:set_elem_type}}{{! }}{{/type:set?}}{{! }}{{#type:map?}}{{type:cythonTemplate}}__{{! }}{{#type:key_type}}{{> types/cython_cpp_type_ident}}{{/type:key_type}}_{{! }}{{#type:value_type}}{{> types/cython_cpp_type_ident}}{{/type:value_type}}{{! }}{{/type:map?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}_{{/type:need_module_path?}}{{! }}c{{enum:name}}{{! }}{{/type:enum}}{{! }}{{#type:void?}}cFollyUnit{{/type:void?}}{{! }}{{/type:hasCustomType?}} )__FBTHRIFT_TAG__", // py3/types/cython_cpp_value_to_python.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used in cases where we have a C++ object defined in Cython code and we need to create or return a Python object. For complex objects, a Python wrapper is initialized; for simple objects it can be returned directly. Strings need to be converted from unicode to binary representation. }}{{#type:iobuf?}}_fbthrift_iobuf.from_unique_ptr({{field:py_name}}.clone()){{/type:iobuf?}}{{! }}{{#type:iobufRef?}}_fbthrift_iobuf.from_unique_ptr(move_iobuf({{field:py_name}})){{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}({{field:py_name}}.data())[:{{field:py_name}}.size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}{{field:py_name}}{{/type:bool?}}{{! }}{{#type:byte?}}{{field:py_name}}{{/type:byte?}}{{! }}{{#type:i16?}}{{field:py_name}}{{/type:i16?}}{{! }}{{#type:i32?}}{{field:py_name}}{{/type:i32?}}{{! }}{{#type:i64?}}{{field:py_name}}{{/type:i64?}}{{! }}{{#type:double?}}{{field:py_name}}{{/type:double?}}{{! }}{{#type:float?}}{{field:py_name}}{{/type:float?}}{{! }}{{#type:string?}}{{field:py_name}}.data().decode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}{{field:py_name}}{{/type:binary?}}{{! }}{{#type:struct?}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{field:py_name}})){{/type:struct?}}{{! }}{{#type:container?}}{{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{field:py_name}})){{/type:container?}}{{! }}{{#type:enum?}}{{> types/cython_python_type}}( {{field:py_name}}){{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/types/cython_field_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! For the Thrift field foo, this generates the field name: foo if it's non-optional or foo_ref().ref_unchecked() if it's optional. Cython doesn't handle references very well, so we have two variants of optional_field_ref::value_unchecked() in the Cython wrapper, value_unchecked() that returns a copy and ref_unchecked() that returns a reference. The latter is only used when we need to take an address. }}{{#field:has_ref_accessor?}}{{! }}{{#field:optional?}}{{! }}{{#field:boxed_ref?}}{{field:py_name}}_ref().ref(){{/field:boxed_ref?}}{{! }}{{^field:boxed_ref?}}{{field:py_name}}_ref().ref_unchecked(){{/field:boxed_ref?}}{{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{field:py_name}}_ref().ref(){{/field:optional?}}{{! }}{{/field:has_ref_accessor?}}{{! }}{{^field:has_ref_accessor?}}{{field:py_name}}{{/field:has_ref_accessor?}} )__FBTHRIFT_TAG__", // py3/types/cython_field_value_for_assignment.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Called specifically from types.pyx when initializing the individual attributes on a struct. }}{{#type:iobuf?}}{{! }}deref((<_fbthrift_iobuf.IOBuf?>_fbthrift_value).c_clone()){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}(<_fbthrift_iobuf.IOBuf?>_fbthrift_value).c_clone(){{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}{{> types/cython_cpp_type}}(cmove(_fbthrift_value)){{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#field:reference?}}{{! }}{{#field:unique_ref?}}{{! For unique references, we just make a copy of the target object - it's not especially efficient but there isn't much else we can do from a shared ptr }}make_unique[{{> types/cython_cpp_type}}](deref({{> types/cython_cast_or_create_python_type}}._cpp_obj)){{! }}{{/field:unique_ref?}}{{! }}{{#field:shared_ref?}}{{! }}{{> types/cython_cast_or_create_python_type}}._cpp_obj{{! }}{{/field:shared_ref?}}{{! }}{{#field:shared_const_ref?}}{{! }}const_pointer_cast({{> types/cython_cast_or_create_python_type}}._cpp_obj){{! }}{{/field:shared_const_ref?}}{{! }}{{/field:reference?}}{{^field:reference?}}{{! }}{{#type:base?}}{{! }}{{#type:string?}}cmove(bytes_to_string({{/type:string?}}{{! }}{{#type:binary?}}cmove(bytes_to_string({{/type:binary?}}{{! }}_fbthrift_value{{! }}{{#type:string?}}.encode('utf-8'))){{/type:string?}}{{! }}{{#type:binary?}})){{/type:binary?}}{{! }}{{/type:base?}}{{! }}{{#type:enum?}}<{{> types/cython_cpp_type}}>_fbthrift_value{{/type:enum?}}{{! }}{{#type:struct?}}{{! }}deref((<{{> types/cython_python_type }}?> _fbthrift_value)._cpp_obj){{! }}{{/type:struct?}}{{! }}{{#type:container?}}{{! }}deref({{> types/cython_python_type }}(_fbthrift_value)._cpp_obj){{! }}{{/type:container?}}{{/field:reference?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/types/cython_field_value_ref.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! For the Thrift field foo, this generates the field name: foo if it's non-optional or foo_ref().value_unchecked() if it's optional. }}{{#field:has_ref_accessor?}}{{! }}{{#field:optional?}}{{! }}{{#field:boxed_ref?}}{{field:py_name}}_ref().value(){{/field:boxed_ref?}}{{! }}{{^field:boxed_ref?}}{{field:py_name}}_ref().value_unchecked(){{/field:boxed_ref?}}{{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{field:py_name}}_ref().value(){{/field:optional?}}{{! }}{{/field:has_ref_accessor?}}{{! }}{{^field:has_ref_accessor?}}{{field:py_name}}{{/field:has_ref_accessor?}} )__FBTHRIFT_TAG__", // py3/types/cython_python_to_cpp_item.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included in places where a Python object exists and it's underlying C++ representation is required. For most primitives, the conversion can be done automatically, but for strings, structures, and containers, more work is required. By convention, the template assumes that the Python object is in a variable named item, for use in sets, lists, and map values. If you need to use a map key, include the parallel CythonPythonToCppKey file instead. }}{{#type:iobuf?}}{{! }}deref((<_fbthrift_iobuf.IOBuf?>item).c_clone()){{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}(<_fbthrift_iobuf.IOBuf?>item).c_clone(){{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}{{> types/cython_cpp_type}}(cmove(item)){{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#type:bool?}}item{{/type:bool?}}{{! }}{{#type:byte?}}item{{/type:byte?}}{{! }}{{#type:i16?}}item{{/type:i16?}}{{! }}{{#type:i32?}}item{{/type:i32?}}{{! }}{{#type:i64?}}item{{/type:i64?}}{{! }}{{#type:double?}}item{{/type:double?}}{{! }}{{#type:float?}}item{{/type:float?}}{{! }}{{#type:string?}}item.encode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}item{{/type:binary?}}{{! }}{{#type:struct}}{{! }}deref((<{{> types/cython_python_type}}>item)._cpp_obj){{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}deref((<{{> types/cython_python_type}}>item)._cpp_obj){{! }}{{/type:container?}}{{! }}{{#type:enum?}}<{{> types/cython_cpp_type}}>item{{/type:enum?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/types/cython_python_to_cpp_key.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included in places where a Python object exists and it's underlying C++ representation is required. For most primitives, the conversion can be done automatically, but for strings, structures, and containers, more work is required. This template assumes that the Python object is in a variable named key, and is most often used with maps. Use the CythonPythonToCppItem template for general keys (conventionally used for sets, lists, and map values). }}{{#type:bool?}}key{{/type:bool?}}{{! }}{{#type:byte?}}key{{/type:byte?}}{{! }}{{#type:i16?}}key{{/type:i16?}}{{! }}{{#type:i32?}}key{{/type:i32?}}{{! }}{{#type:i64?}}key{{/type:i64?}}{{! }}{{#type:double?}}key{{/type:double?}}{{! }}{{#type:float?}}key{{/type:float?}}{{! }}{{#type:string?}}key.encode('UTF-8'){{/type:string?}}{{! }}{{#type:binary?}}key{{/type:binary?}}{{! }}{{#type:struct}}{{! }}deref((<{{> types/cython_python_type}}>key)._cpp_obj){{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}deref((<{{> types/cython_python_type}}>key)._cpp_obj){{! }}{{/type:container?}}{{! }}{{#type:enum?}}<{{> types/cython_cpp_type}}>key{{/type:enum?}} )__FBTHRIFT_TAG__", // py3/types/cython_python_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is used to declare a cython type that is referring to a Python value (ie, something that will be returned to external Python code or just used in Cython). Structs and enums will be namespaced appropriately if they are either defined in a different thrift file, or defined in the same thrift file but this is in the client or server source rather than the type definition source. }}{{#type:iobufWrapper?}}_fbthrift_iobuf.IOBuf{{/type:iobufWrapper?}}{{! }}{{^type:iobufWrapper?}}{{! }}{{#type:bool?}}pbool{{/type:bool?}}{{! }}{{#type:byte?}}cint8_t{{/type:byte?}}{{! }}{{#type:i16?}}cint16_t{{/type:i16?}}{{! }}{{#type:i32?}}cint32_t{{/type:i32?}}{{! }}{{#type:i64?}}cint64_t{{/type:i64?}}{{! }}{{#type:double?}}double{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}bytes{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{type:flat_name}}{{! }}{{/type:container?}}{{! }}{{#type:void?}}object{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{enum:name}}{{! }}{{/type:enum}}{{! }}{{/type:iobufWrapper?}} )__FBTHRIFT_TAG__", // py3/types/cython_struct_getter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included on Cython structs in properties for retrieving child values from that struct. Most types can be returned directly and converted to python objects by Cython. Complex objects need to be wrapped or decoded appropriately. Structs are special because we try to memoize their wrappers on the parent handler if they have been previously retrieved. }}{{#type:iobuf?}}{{! }}if self.__fbthrift_cached_{{field:py_name}} is None: self.__fbthrift_cached_{{field:py_name}} = _fbthrift_iobuf.IOBuf.create(ptr_address(deref(self._cpp_obj).{{> types/cython_field_ref}}), self) return self.__fbthrift_cached_{{field:py_name}}{{! }}{{/type:iobuf?}}{{! }}{{#type:iobufRef?}}{{! }}if self.__fbthrift_cached_{{field:py_name}} is None: if not deref(self._cpp_obj).{{> types/cython_field_value_ref}}: return None self.__fbthrift_cached_{{field:py_name}} = _fbthrift_iobuf.IOBuf.create(deref(self._cpp_obj).{{> types/cython_field_value_ref}}.get(), self) return self.__fbthrift_cached_{{field:py_name}}{{! }}{{/type:iobufRef?}}{{! }}{{#type:flexibleBinary?}}{{! }}return (deref(self._cpp_obj).{{> types/cython_field_value_ref}}{{! }}.data())[:deref(self._cpp_obj).{{> types/cython_field_value_ref}}{{! }}.size()]{{! }}{{/type:flexibleBinary?}}{{! }}{{^type:hasCustomTypeBehavior?}}{{! }}{{#field:reference?}}{{! }}if self.__fbthrift_cached_{{field:py_name}} is None: if not deref(self._cpp_obj).{{> types/cython_field_value_ref}}_ref(): return None {{! Use an aliasing constructor since the object we're returning is still managed by the top-level object, possible via a unique_ptr }} self.__fbthrift_cached_{{field:py_name}} = {{> types/cython_python_type}}._fbthrift_create(__reference_shared_ptr({{! }}deref(deref(self._cpp_obj).{{> types/cython_field_value_ref}}_ref()), self._cpp_obj)) return self.__fbthrift_cached_{{field:py_name}}{{! }}{{/field:reference?}}{{! }}{{^field:reference?}}{{! }}{{#type:base?}}{{! }}return {{! }}{{#type:bool?}} {{/type:bool?}}{{! }}{{#type:string?}}({{/type:string?}}{{! }}deref(self._cpp_obj).{{> types/cython_field_value_ref}}{{! }}{{#type:string?}}).decode('UTF-8'){{/type:string?}}{{! }}{{/type:base?}}{{! }}{{^type:base?}}{{! }}if self.__fbthrift_cached_{{field:py_name}} is None: self.__fbthrift_cached_{{field:py_name}} = {{! }}{{#type:enum?}}translate_cpp_enum_to_python({{! }}{{> types/cython_python_type}}, {{! }}({{! }}deref(self._cpp_obj).{{> types/cython_field_value_ref}}{{! }})){{/type:enum?}}{{! }}{{^type:enum?}}{{> types/cython_python_type}}._fbthrift_create(__reference_shared_ptr({{! }}deref(self._cpp_obj).{{> types/cython_field_ref}}, {{! }}self._cpp_obj{{! }})){{/type:enum?}} return self.__fbthrift_cached_{{field:py_name}}{{! }}{{/type:base?}}{{! }}{{/field:reference?}}{{! }}{{/type:hasCustomTypeBehavior?}} )__FBTHRIFT_TAG__", // py3/types/cython_union_assign_field.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Called specifically from types.pyx when initializing the individual attributes on a union. }}{{^field:has_ref_api?}}{{! }}{{#field:reference?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign_ptr({{! }}cmove(deref((<{{> types/cython_python_type }}?> {{field:py_name}})._cpp_obj))){{! }}{{/field:reference?}}{{! }}{{^field:reference?}}{{! }}{{#type:bool?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:i64?}}{{! }}{{#type:double?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:double?}}{{! }}{{#type:float?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:float?}}{{! }}{{#type:string?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}.encode('UTF-8')){{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobuf?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign(deref((<_fbthrift_iobuf.IOBuf?>{{field:py_name}})._this)) {{! }}{{/type:iobuf?}}{{! }}{{^type:iobuf?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{field:py_name}}){{! }}{{/type:iobuf?}}{{! }}{{/type:binary?}}{{! }}{{#type:enum?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{! }}<{{> types/cython_cpp_type}}>{{field:py_name}}){{! }}{{/type:enum?}}{{! }}{{#type:struct?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{! }}deref((<{{> types/cython_python_type }}?> {{field:py_name}})._cpp_obj)){{! }}{{/type:struct?}}{{! }}{{#type:container?}}{{! }}deref(c_inst).{{field:py_name}}_ref().assign({{! }}<{{> types/cython_cpp_type}}>{{! }}deref({{> types/cython_python_type }}({{field:py_name}})._cpp_obj)){{! }}{{/type:container?}}{{! }}{{/field:reference?}}{{! }}{{/field:has_ref_api?}}{{! }}{{#field:has_ref_api?}}{{! }}{{#field:reference?}}{{! }}deref(c_inst).set_{{field:py_name}}({{! }}{{#field:unique_ref?}}{{! For unique references, we just make a copy of the target object - it's not especially efficient but there isn't much else we can do from a shared ptr }}{{> types/cython_cpp_type}}(deref((<{{> types/cython_python_type}}?>{{field:py_name}})._cpp_obj)){{! }}{{/field:unique_ref?}}{{! }}{{#field:shared_ref?}}{{! }}deref((<{{> types/cython_python_type}}?>{{field:py_name}})._cpp_obj){{! }}{{/field:shared_ref?}}{{! }}{{#field:shared_const_ref?}}{{! }}deref((<{{> types/cython_python_type}}?>{{field:py_name}})._cpp_obj){{! }}{{/field:shared_const_ref?}}{{! }}){{! }}{{/field:reference?}}{{^field:reference?}}{{! }}{{#type:bool?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:i64?}}{{! }}{{#type:double?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:double?}}{{! }}{{#type:float?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:float?}}{{! }}{{#type:string?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}.encode('UTF-8')){{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobuf?}}{{! }}deref(c_inst).set_{{field:py_name}}(deref((<_fbthrift_iobuf.IOBuf?>{{field:py_name}})._this)) {{! }}{{/type:iobuf?}}{{! }}{{^type:iobuf?}}{{! }}deref(c_inst).set_{{field:py_name}}({{field:py_name}}){{! }}{{/type:iobuf?}}{{! }}{{/type:binary?}}{{! }}{{#type:enum?}}{{! }}deref(c_inst).set_{{field:py_name}}({{! }}<{{> types/cython_cpp_type}}>{{field:py_name}}){{! }}{{/type:enum?}}{{! }}{{#type:struct?}}{{! }}deref(c_inst).set_{{field:py_name}}({{! }}deref((<{{> types/cython_python_type }}?> {{field:py_name}})._cpp_obj)){{! }}{{/type:struct?}}{{! }}{{#type:container?}}{{! }}deref(c_inst).set_{{field:py_name}}({{! }}<{{> types/cython_cpp_type}}>{{! }}deref({{> types/cython_python_type }}({{field:py_name}})._cpp_obj)){{! }}{{/type:container?}}{{! }}{{/field:reference?}}{{! }}{{/field:has_ref_api?}} )__FBTHRIFT_TAG__", // py3/types/cython_union_getter.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included on Cython unions to retrieve the current value of the union and stick it in the self.value variable. }}{{^field:has_ref_api?}}{{! }}{{#field:reference?}}{{! }}if not deref(self._cpp_obj).{{field:py_name}}_ref().has_value(): self.value = None else: {{! Use an aliasing constructor since the object we're returning is still managed by the top-level object, possible via a unique_ptr }} self.value = {{> types/cython_python_type}}._fbthrift_create(__reference_shared_ptr({{! }}deref(__get_union_field_value[{{> types/cython_cpp_type}}](deref(self._cpp_obj).{{field:py_name}}_ref())), self._cpp_obj)){{! }}{{/field:reference?}}{{! }}{{^field:reference?}}{{! }}{{#type:bool?}}{{! }}self.value = (deref(self._cpp_obj).{{field:py_name}}_ref().value()){{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:i64?}}{{! }}{{#type:double?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:double?}}{{! }}{{#type:float?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:float?}}{{! }}{{#type:string?}}{{! }}self.value = bytes(deref(self._cpp_obj).{{field:py_name}}_ref().value()).decode('UTF-8'){{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobuf?}}{{! }}self.value = _fbthrift_iobuf.from_unique_ptr({{! }}deref(self._cpp_obj).{{field:py_name}}_ref().value().clone()){{! }}{{/type:iobuf?}}{{! }}{{^type:iobuf?}}{{! }}self.value = deref(self._cpp_obj).{{field:py_name}}_ref().value(){{! }}{{/type:iobuf?}}{{! }}{{/type:binary?}}{{! }}{{#type:enum}}{{! }}self.value = translate_cpp_enum_to_python({{! }}{{> types/cython_python_type}}, {{! }}deref(self._cpp_obj).{{field:py_name}}_ref().value()){{! }}{{/type:enum}}{{! }}{{#type:struct?}}{{! }}self.value = {{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}deref(self._cpp_obj).{{field:py_name}}_ref().value())){{! }}{{/type:struct?}}{{! }}{{#type:container?}}{{! }}self.value = {{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}deref(self._cpp_obj).{{field:py_name}}_ref().value())){{! }}{{/type:container?}}{{! }}{{/field:reference?}}{{! }}{{/field:has_ref_api?}}{{! }}{{#field:has_ref_api?}}{{! }}{{#field:reference?}}{{! }}if not deref(self._cpp_obj).get_{{field:py_name}}(): self.value = None else: {{! Use an aliasing constructor since the object we're returning is still managed by the top-level object, possible via a unique_ptr }} self.value = {{> types/cython_python_type}}._fbthrift_create(__reference_shared_ptr({{! }}deref(deref(self._cpp_obj).get_{{field:py_name}}()), self._cpp_obj)){{! }}{{/field:reference?}}{{! }}{{^field:reference?}}{{! }}{{#type:bool?}}{{! }}self.value = (deref(self._cpp_obj).get_{{field:py_name}}()){{! }}{{/type:bool?}}{{! }}{{#type:byte?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:byte?}}{{! }}{{#type:i16?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:i16?}}{{! }}{{#type:i32?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:i32?}}{{! }}{{#type:i64?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:i64?}}{{! }}{{#type:double?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:double?}}{{! }}{{#type:float?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:float?}}{{! }}{{#type:string?}}{{! }}self.value = bytes(deref(self._cpp_obj).get_{{field:py_name}}()).decode('UTF-8'){{! }}{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobuf?}}{{! }}self.value = _fbthrift_iobuf.from_unique_ptr({{! }}deref(self._cpp_obj).get_{{field:py_name}}().clone()){{! }}{{/type:iobuf?}}{{! }}{{^type:iobuf?}}{{! }}self.value = deref(self._cpp_obj).get_{{field:py_name}}(){{! }}{{/type:iobuf?}}{{! }}{{/type:binary?}}{{! }}{{#type:enum}}{{! }}self.value = translate_cpp_enum_to_python({{! }}{{> types/cython_python_type}}, {{! }}deref(self._cpp_obj).get_{{field:py_name}}()){{! }}{{/type:enum}}{{! }}{{#type:struct?}}{{! }}self.value = {{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}deref(self._cpp_obj).get_{{field:py_name}}())){{! }}{{/type:struct?}}{{! }}{{#type:container?}}{{! }}self.value = {{> types/cython_python_type}}._fbthrift_create({{! }}make_shared[{{> types/cython_cpp_type}}]({{! }}deref(self._cpp_obj).get_{{field:py_name}}())){{! }}{{/type:container?}}{{! }}{{/field:reference?}}{{! }}{{/field:has_ref_api?}} )__FBTHRIFT_TAG__", // py3/types/enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for creating compiled Enum and Flag pyx information }} {{#program:enums}} {{#enum:flags?}} cdef __EnumFlagsData __{{enum:name}}_enum_data = __EnumFlagsData._fbthrift_create(thrift.py3.types.createEnumFlagsData[c{{enum:name}}](), {{enum:name}}) {{/enum:flags?}}{{^enum:flags?}} cdef __EnumData __{{enum:name}}_enum_data = __EnumData._fbthrift_create(thrift.py3.types.createEnumData[c{{enum:name}}](), {{enum:name}}) {{/enum:flags?}} @__cython.internal @__cython.auto_pickle(False) cdef class __{{enum:name}}Meta(thrift.py3.types.EnumMeta): def _fbthrift_get_by_value(cls, int value): return __{{enum:name}}_enum_data.get_by_value(value) def _fbthrift_get_all_names(cls): return __{{enum:name}}_enum_data.get_all_names() def __len__(cls): return __{{enum:name}}_enum_data.size() def __getattribute__(cls, str name not None): if name.startswith("__") or name.startswith("_fbthrift_") or name == "mro": return super().__getattribute__(name) return __{{enum:name}}_enum_data.get_by_name(name) @__cython.final @__cython.auto_pickle(False) cdef class {{enum:name}}(thrift.py3.types.{{^enum:flags?}}CompiledEnum{{/enum:flags?}}{{#enum:flags?}}Flag{{/enum:flags?}}): cdef get_by_name(self, str name): return __{{enum:name}}_enum_data.get_by_name(name) {{#enum:flags?}} def __invert__(self): return __{{enum:name}}_enum_data.get_invert(self.value) {{/enum:flags?}} @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftMetadata meta EnumMetadata[c{{enum:name}}].gen(meta) return __MetadataBox.box(cmove(meta)) @staticmethod def __get_thrift_name__(): return "{{program:name}}.{{enum:name}}" def _to_python(self): import importlib {{!TODO: accommodate root_module_prefix}} python_types = importlib.import_module( "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.thrift_types" ) return python_types.{{enum:name}}(self.value) def _to_py3(self): return self def _to_py_deprecated(self): return self.value __SetMetaClass( {{enum:name}}, __{{enum:name}}Meta) {{/program:enums}} )__FBTHRIFT_TAG__", // py3/types/enum_defs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for creating compiled Enum and Flag pxd information }} {{#program:enums}} cdef class {{enum:name}}(thrift.py3.types.{{^enum:flags?}}CompiledEnum{{/enum:flags?}}{{#enum:flags?}}Flag{{/enum:flags?}}): pass {{/program:enums}} )__FBTHRIFT_TAG__", // py3/types/enum_extern.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for exposing cpp enums in .pxd }} {{#program:enums}} {{#first?}} cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_metadata.h" namespace "apache::thrift::detail::md": cdef cppclass EnumMetadata[T]: @staticmethod void gen(__fbthrift_cThriftMetadata &metadata) cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_types.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": {{/first?}} cdef cppclass c{{enum:name}} "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{enum:cpp_name}}": pass {{/program:enums}} )__FBTHRIFT_TAG__", // py3/types/field_cppname.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! fields accessors have different names depending on the @thrift.NoLegacy annotation }}{{#field:has_ref_api?}}{{field:cppName}}_ref{{/field:has_ref_api?}}{{! }}{{^field:has_ref_api?}}{{field:cppName}}{{/field:has_ref_api?}} )__FBTHRIFT_TAG__", // py3/types/pep484_containers.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Produce the pep484 container type for a given thrift-py3 container }}{{#type:list?}}_typing.Sequence[{{! }}{{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}_typing.AbstractSet[{{! }}{{#type:set_elem_type}}{{> types/pep484_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}_typing.Mapping[{{! }}{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> types/pep484_type}}{{/type:value_type}}{{! }}]{{/type:map?}} )__FBTHRIFT_TAG__", // py3/types/pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-py3 specific container types. }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobufWrapper?}}_fbthrift_iobuf.IOBuf{{/type:iobufWrapper?}}{{! }}{{^type:iobufWrapper?}}bytes{{/type:iobufWrapper?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}{{> types/pep484_containers}}{{! }}{{/type:container?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{enum:name}}{{! }}{{/type:enum}} )__FBTHRIFT_TAG__", // py3/types/python_is_instance_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for python types, suitable for isinstance check_types }}{{#type:bool?}}bool{{/type:bool?}}{{! we will not implicity convert float to int because information is lost }}{{#type:integer?}}int{{/type:integer?}}{{! We will implicity convert int to float because no information is lost }}{{#type:floating_point?}}(float, int){{/type:floating_point?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobufWrapper?}}_fbthrift_iobuf.IOBuf{{/type:iobufWrapper?}}{{! }}{{^type:iobufWrapper?}}bytes{{/type:iobufWrapper?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{> types/cython_python_type}}{{! }}{{/type:container?}}{{! }}{{#type:void?}}object{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:modulePath}}.{{/type:need_module_path?}}{{! }}{{enum:name}}{{! }}{{/type:enum}} )__FBTHRIFT_TAG__", // py3/types/python_struct_class.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This results in the proper baseclass for python structs }}{{#struct:exception?}}thrift.py3.exceptions.GeneratedError{{/struct:exception?}}{{! }}{{#struct:union?}}thrift.py3.types.Union{{/struct:union?}}{{! }}{{#struct:plain?}}thrift.py3.types.Struct{{/struct:plain?}} )__FBTHRIFT_TAG__", // py3/types/python_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for python types, used for typedefs aliases for use in python. Structs and enums will be namespaced appropriately if they are either defined in a different thrift file, or defined in the same thrift file but this is in the client or server source rather than the type definition source. }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:iobufWrapper?}}_fbthrift_iobuf.IOBuf{{/type:iobufWrapper?}}{{! }}{{^type:iobufWrapper?}}bytes{{/type:iobufWrapper?}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{> types/cython_python_type}}{{! }}{{/type:struct}}{{! }}{{#type:container?}}{{! }}{{> types/cython_python_type}}{{! }}{{/type:container?}}{{! }}{{#type:enum}}{{! }}{{> types/cython_python_type}}{{! }}{{/type:enum}}{{! }}{{#type:void?}}object{{/type:void?}} )__FBTHRIFT_TAG__", // py3/types/struct_extern.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for exposing cpp structs and unions in .pxd }} {{#program:filtered_structs}} {{#first?}} cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_metadata.h" namespace "apache::thrift::detail::md": cdef cppclass ExceptionMetadata[T]: @staticmethod void gen(__fbthrift_cThriftMetadata &metadata) cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_metadata.h" namespace "apache::thrift::detail::md": cdef cppclass StructMetadata[T]: @staticmethod void gen(__fbthrift_cThriftMetadata &metadata) cdef extern from "{{program:includePrefix}}{{program:cpp_gen_path}}/{{program:name}}_types_custom_protocol.h"{{! }} namespace "{{#program:cppNamespaces}}::{{value}}{{/program:cppNamespaces}}": {{/first?}} {{#struct:union?}} cdef enum c{{struct:name}}__type "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{struct:name}}::Type": c{{struct:name}}__type___EMPTY__ "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{struct:name}}::Type::__EMPTY__", {{#struct:py3_fields}} c{{struct:name}}__type_{{field:py_name}} "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{struct:name}}::Type::{{field:cppName}}", {{/struct:py3_fields}} {{/struct:union?}} cdef cppclass c{{struct:name}} "::{{#program:cppNamespaces}}{{value}}::{{/program:cppNamespaces}}{{struct:name}}"{{#struct:exception?}}(cTException){{/struct:exception?}}: c{{struct:name}}() except + {{^struct:cpp_noncopyable?}} c{{struct:name}}(const c{{struct:name}}&) except + {{/struct:cpp_noncopyable?}} {{^struct:cpp_noncomparable}} bint operator==(c{{struct:name}}&) bint operator!=(c{{struct:name}}&) {{#struct:is_struct_orderable?}} bint operator<(c{{struct:name}}&) bint operator>(c{{struct:name}}&) bint operator<=(c{{struct:name}}&) bint operator>=(c{{struct:name}}&) {{/struct:is_struct_orderable?}} {{/struct:cpp_noncomparable}} {{^struct:union?}} {{#struct:fields_and_mixin_fields}} {{#field:has_ref_accessor?}} {{#field:optional?}} __optional_field_ref[{{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}}] {{! }}{{field:py_name}}_ref "{{> types/field_cppname}}" () {{/field:optional?}} {{#field:required?}} __required_field_ref[{{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}}] {{! }}{{field:py_name}}_ref "{{> types/field_cppname}}" () {{/field:required?}} {{#field:opt_in_req_out?}} __field_ref[{{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}}] {{! }}{{field:py_name}}_ref "{{> types/field_cppname}}" () {{/field:opt_in_req_out?}} {{#field:terse?}} __terse_field_ref[{{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}}] {{! }}{{field:py_name}}_ref "{{> types/field_cppname}}" () {{/field:terse?}} {{/field:has_ref_accessor?}} {{^field:has_ref_accessor?}} {{#field:reference?}} {{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}} {{field:py_name}}_ref "{{> types/field_cppname}}" () {{/field:reference?}} {{/field:has_ref_accessor?}} {{/struct:fields_and_mixin_fields}} {{/struct:union?}} {{#struct:union?}} c{{struct:name}}__type getType() const {{#struct:py3_fields}} {{^field:has_ref_api?}} __union_field_ref[{{#field:type}}{{> types/cython_cpp_struct_field_type}}{{/field:type}}] {{! }}{{field:py_name}}_ref"{{> types/field_cppname}}_ref" () {{/field:has_ref_api?}}{{! }}{{#field:has_ref_api?}} {{#field:type}}const {{> types/cython_cpp_struct_field_type}}& get_{{field:py_name}} "get_{{field:cppName}}" () const{{/field:type}} {{! Note that the set methods don't take in a shared/unique_ptr, they just take in an object ref, but they return the appropriate ptr }} {{#field:type}}{{> types/cython_cpp_struct_field_type}}& set_{{field:py_name}} "set_{{field:cppName}}" (const {{> types/cython_cpp_type}}&){{/field:type}} {{/field:has_ref_api?}} {{/struct:py3_fields}}{{/struct:union?}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/types/thrift_number_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This gives additional information for number types. }}{{#type:byte?}}__NumberType.BYTE{{/type:byte?}}{{! }}{{#type:i16?}}__NumberType.I16{{/type:i16?}}{{! }}{{#type:i32?}}__NumberType.I32{{/type:i32?}}{{! }}{{#type:i64?}}__NumberType.I64{{/type:i64?}}{{! }}{{#type:double?}}__NumberType.DOUBLE{{/type:double?}}{{! }}{{#type:float?}}__NumberType.FLOAT{{/type:float?}}{{! }}{{^type:number?}}__NumberType.NOT_A_NUMBER{{/type:number?}} )__FBTHRIFT_TAG__", // py3/types/type_default_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:number?}} = 0{{/type:number?}}{{! }}{{#type:bool?}} = False{{/type:bool?}} )__FBTHRIFT_TAG__", // py3/types/union_type_enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is a template for creating compiled Enum and Flag pyx information }} {{#program:filtered_structs}} {{#struct:union?}} cdef __UnionTypeEnumData __{{struct:name}}_union_type_enum_data = __UnionTypeEnumData._fbthrift_create( __createEnumDataForUnionType[c{{struct:name}}](), __{{struct:name}}Type, ) @__cython.internal @__cython.auto_pickle(False) cdef class __{{struct:name}}_Union_TypeMeta(thrift.py3.types.EnumMeta): def _fbthrift_get_by_value(cls, int value): return __{{struct:name}}_union_type_enum_data.get_by_value(value) def _fbthrift_get_all_names(cls): return __{{struct:name}}_union_type_enum_data.get_all_names() def __len__(cls): return __{{struct:name}}_union_type_enum_data.size() def __getattribute__(cls, str name not None): if name.startswith("__") or name.startswith("_fbthrift_") or name == "mro": return super().__getattribute__(name) return __{{struct:name}}_union_type_enum_data.get_by_name(name) @__cython.final @__cython.auto_pickle(False) cdef class __{{struct:name}}Type(thrift.py3.types.CompiledEnum): cdef get_by_name(self, str name): return __{{struct:name}}_union_type_enum_data.get_by_name(name) __SetMetaClass( __{{struct:name}}Type, __{{struct:name}}_Union_TypeMeta) {{/struct:union?}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/types_fields.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> common/auto_generated_py}} from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, uint16_t as cuint16_t, uint32_t as cuint32_t, ) from libcpp.string cimport string from libcpp cimport bool as cbool, nullptr, nullptr_t from cpython cimport bool as pbool from libcpp.memory cimport shared_ptr, unique_ptr from libcpp.utility cimport move as cmove from libcpp.vector cimport vector from libcpp.set cimport set as cset from libcpp.map cimport map as cmap from libcpp.unordered_map cimport unordered_map as cumap from thrift.py3.exceptions cimport cTException cimport folly.iobuf as _fbthrift_iobuf cimport thrift.py3.exceptions cimport thrift.py3.types from thrift.py3.std_libcpp cimport string_view as __cstring_view from thrift.py3.types cimport ( bstring, bytes_to_string, field_ref as __field_ref, optional_field_ref as __optional_field_ref, required_field_ref as __required_field_ref, terse_field_ref as __terse_field_ref, StructFieldsSetter as __StructFieldsSetter ) from thrift.python.protocol cimport Protocol as __Protocol from folly.optional cimport cOptional as __cOptional {{#program:includeNamespaces}} {{#hasTypes?}} cimport {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} cimport {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_prefix}}types as {{> types/current_module_types}} {{#program:filtered_structs}} {{^struct:union?}} ctypedef void (*__{{struct:name}}_FieldsSetterFunc)(__{{struct:name}}_FieldsSetter, object) except * cdef class __{{struct:name}}_FieldsSetter(__StructFieldsSetter): cdef {{> types/current_module_types}}.c{{struct:name}}* _struct_cpp_obj cdef cumap[__cstring_view, __{{struct:name}}_FieldsSetterFunc] _setters @staticmethod cdef __{{struct:name}}_FieldsSetter _fbthrift_create({{> types/current_module_types}}.c{{struct:name}}* struct_cpp_obj) {{#struct:py3_fields}} {{#field:type}} cdef void _set_field_{{field:index}}(self, _fbthrift_value) except * {{/field:type}} {{/struct:py3_fields}} {{/struct:union?}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/types_fields.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> common/auto_generated_py}} cimport cython as __cython from cython.operator cimport dereference as deref from libcpp.memory cimport unique_ptr, shared_ptr from thrift.py3.types cimport ( assign_unique_ptr, assign_shared_ptr, assign_shared_const_ptr, bytes_to_string, make_unique, ) cimport thrift.py3.types from thrift.py3.types cimport ( reset_field as __reset_field, StructFieldsSetter as __StructFieldsSetter ) {{#program:structs?}} from thrift.py3.types cimport const_pointer_cast, BadEnum as _fbthrift_BadEnum {{/program:structs?}} {{#program:intercompatible?}} from thrift.py3.types import _is_python_enum, _is_python_struct {{/program:intercompatible?}} {{#program:filtered_structs}} {{^struct:union?}} @__cython.auto_pickle(False) cdef class __{{struct:name}}_FieldsSetter(__StructFieldsSetter): @staticmethod cdef __{{struct:name}}_FieldsSetter _fbthrift_create({{> types/current_module_types}}.c{{struct:name}}* struct_cpp_obj): cdef __{{struct:name}}_FieldsSetter __fbthrift_inst = __{{struct:name}}_FieldsSetter.__new__(__{{struct:name}}_FieldsSetter) __fbthrift_inst._struct_cpp_obj = struct_cpp_obj {{#struct:py3_fields}} __fbthrift_inst._setters[__cstring_view("{{field:py_name}}")] = __{{struct:name}}_FieldsSetter._set_field_{{field:index}} {{/struct:py3_fields}} return __fbthrift_inst cdef void set_field(__{{struct:name}}_FieldsSetter self, const char* name, object value) except *: cdef __cstring_view cname = __cstring_view(name) cdef cumap[__cstring_view, __{{struct:name}}_FieldsSetterFunc].iterator found = self._setters.find(cname) if found == self._setters.end(): raise TypeError(f"invalid field name {name.decode('utf-8')}") deref(found).second(self, value) {{#struct:py3_fields}} {{#field:type}} cdef void _set_field_{{field:index}}(self, _fbthrift_value) except *: # for field {{field:py_name}} if _fbthrift_value is None: __reset_field[{{> types/current_module_types}}.c{{struct:name}}](deref(self._struct_cpp_obj), {{field:index}}) return {{^type:container?}} {{#type:enum?}} if not isinstance(_fbthrift_value, _fbthrift_BadEnum) and not isinstance(_fbthrift_value, {{> types/python_type}}): {{#program:intercompatible?}} if _is_python_enum(_fbthrift_value): _fbthrift_value = _fbthrift_value._to_py3() if not isinstance(_fbthrift_value, {{> types/python_type}}): raise TypeError(f'field {{field:py_name}} value: {repr(_fbthrift_value)} is a thrift-python enum that can not be converted to enum type { {{> types/python_type}} }.') else: raise TypeError(f'field {{field:py_name}} value: {repr(_fbthrift_value)} is not of the enum type { {{> types/python_type}} }.') {{/program:intercompatible?}} {{^program:intercompatible?}} raise TypeError(f'field {{field:py_name}} value: {repr(_fbthrift_value)} is not of the enum type { {{> types/python_type}} }.') {{/program:intercompatible?}} {{/type:enum?}} {{^type:enum?}} if not isinstance(_fbthrift_value, {{> types/python_is_instance_type}}): {{#program:intercompatible?}} {{#type:struct?}} if _is_python_struct(_fbthrift_value): _fbthrift_value = _fbthrift_value._to_py3() if not isinstance(_fbthrift_value, {{> types/python_is_instance_type}}): raise TypeError(f'{{field:py_name}} is a thrift-python struct of type {type(_fbthrift_value) !r} that can not be converted to { {{> types/python_type}} !r}.') else: raise TypeError(f'{{field:py_name}} is not a { {{> types/python_type}} !r}.') {{/type:struct?}} {{^type:struct?}} raise TypeError(f'{{field:py_name}} is not a { {{> types/python_type}} !r}.') {{/type:struct?}} {{/program:intercompatible?}} {{^program:intercompatible?}} raise TypeError(f'{{field:py_name}} is not a { {{> types/python_type}} !r}.') {{/program:intercompatible?}} {{#type:integer?}} {{! inject cython int overflow checks }} _fbthrift_value = <{{> types/cython_python_type}}> _fbthrift_value {{/type:integer?}} {{/type:enum?}} {{/type:container?}} {{#field:has_ref_accessor?}} deref(self._struct_cpp_obj).{{field:py_name}}_ref().assign({{> types/cython_field_value_for_assignment}}) {{/field:has_ref_accessor?}} {{^field:has_ref_accessor?}} assign_{{#field:unique_ref?}}unique{{/field:unique_ref?}}{{! }}{{#field:shared_ref?}}shared{{/field:shared_ref?}}{{! }}{{#field:shared_const_ref?}}shared_const{{/field:shared_const_ref?}}{{! }}_ptr[{{> types/cython_cpp_type}}](deref(self._struct_cpp_obj).{{field:py_name}}_ref(), {{> types/cython_field_value_for_assignment}}) {{/field:has_ref_accessor?}} {{/field:type}} {{/struct:py3_fields}} {{/struct:union?}} {{/program:filtered_structs}} )__FBTHRIFT_TAG__", // py3/types_reflection.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Python wrappers of the structs defined in the services files. This file is compiled into it's own module to be included by clients and services and end-user code. It's one of the more complicated files, as it has to map Pythonic APIs to C++ objects and back. One of the nastier things in this file is the definition of containers. A separate container wrapper has to be defined for each type of contained attribute because Cython can't template C++ classes. So, for example, we need a List__int16 or a List__string or a Map__string_mystruct instance for each container/type combination. Consider that containers can contain other containers or structs that contain containers and you realize how messy this can get. Further, we'd prefer to have the end user freed from having to know about these container types, so we'll need to define factories for them based on what they want to include. }} {{> common/auto_generated_py}} import folly.iobuf as _fbthrift_iobuf from thrift.py3.reflection import ( NumberType as __NumberType, StructType as __StructType, Qualifier as __Qualifier, StructSpec as __StructSpec, ListSpec as __ListSpec, SetSpec as __SetSpec, MapSpec as __MapSpec, FieldSpec as __FieldSpec, ) {{#program:includeNamespaces}} {{#hasTypes?}} import {{#includeNamespace}}{{value}}.{{/includeNamespace}}{{> common/auto_migrate_prefix }}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types {{/hasTypes?}} {{/program:includeNamespaces}} import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.{{> common/auto_migrate_import_prefix }}types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types {{#program:filtered_structs}} def get_reflection__{{struct:name}}() -> __StructSpec: spec: __StructSpec = __StructSpec._fbthrift_create( name="{{struct:name}}", kind=__StructType.{{! }}{{#struct:exception?}}EXCEPTION{{/struct:exception?}}{{! }}{{#struct:union?}}UNION{{/struct:union?}}{{! }}{{#struct:plain?}}STRUCT{{/struct:plain?}}, annotations={ {{#struct:annotations}} {{> common/annotation }} {{/struct:annotations}} }, ) {{#struct:py3_fields}} {{#struct:has_defaulted_field?}} {{#first?}} defaults = _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types.{{struct:name}}() {{/first?}} {{/struct:has_defaulted_field?}} spec.add_field( __FieldSpec._fbthrift_create( id={{field:key}}, name="{{field:name}}", py_name="{{field:py_name}}", type={{#field:type}}{{> types/python_type}}{{/field:type}}, kind={{#field:type}}{{> types/thrift_number_type}}{{/field:type}}, qualifier=__Qualifier.{{! }}{{#field:required?}}REQUIRED{{/field:required?}}{{! }}{{^field:required?}}{{! }}{{#field:optional?}}OPTIONAL{{/field:optional?}}{{! }}{{^field:optional?}}UNQUALIFIED{{/field:optional?}}{{! }}{{/field:required?}}, default={{! }}{{^struct:union?}}{{! }}{{#field:value}}defaults.{{field:name}}{{/field:value}}{{! }}{{^field:value}}None{{/field:value}}{{! }}{{/struct:union?}}{{! }}{{#struct:union?}}None{{/struct:union?}}, annotations={ {{#field:annotations}} {{> common/annotation }} {{/field:annotations}} }, ), ) {{/struct:py3_fields}} return spec {{/program:filtered_structs}} {{^program:auto_migrate?}} {{#program:containerTypes}} {{#type:list?}} def get_reflection__{{type:flat_name}}() -> __ListSpec : {{#type:list_elem_type}} return __ListSpec._fbthrift_create( value={{> types/python_type}}, kind={{> types/thrift_number_type}}, ) {{/type:list_elem_type}} {{/type:list?}} {{#type:set?}} def get_reflection__{{type:flat_name}}() -> __SetSpec: {{#type:set_elem_type}} return __SetSpec._fbthrift_create( value={{> types/python_type}}, kind={{> types/thrift_number_type}}, ) {{/type:set_elem_type}} {{/type:set?}} {{#type:map?}} def get_reflection__{{type:flat_name}}() -> __MapSpec: return __MapSpec._fbthrift_create( key={{#type:key_type}}{{> types/python_type}}{{/type:key_type}}, key_kind={{#type:key_type}}{{> types/thrift_number_type}}{{/type:key_type}}, value={{#type:value_type}}{{> types/python_type}}{{/type:value_type}}, value_kind={{#type:value_type}}{{> types/thrift_number_type}}{{/type:value_type}}, ) {{/type:map?}} {{/program:containerTypes}} {{/program:auto_migrate?}} )__FBTHRIFT_TAG__", // pyi/common/AutoGeneratedPy.mustache R"__FBTHRIFT_TAG__(# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @{{!x}}generated # {{! terminate with newline }} )__FBTHRIFT_TAG__", // pyi/common/Constant.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#constant:type}}{{constant:name}}: {{> common/FieldType}} {{/constant:type}} )__FBTHRIFT_TAG__", // pyi/common/FieldType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Trivial mapping to type annotation field types. Depends on an import in the form: import typing as __T Recursive. }}{{#type:has_adapter?}}{{#type:adapter}}{{.}}.Type{{/type:adapter}}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}bytes{{/type:binary?}}{{! }}{{#type:struct}}{{#type:externalProgram?}}{{> common/ModulePath}}.{{/type:externalProgram?}}{{struct:name}}{{/type:struct}}{{! }}{{#type:list?}}__T.List[{{#type:list_elem_type}}{{> common/FieldType}}{{/type:list_elem_type}}]{{/type:list?}}{{! }}{{#type:set?}}__T.Set[{{#type:set_elem_type}}{{> common/FieldType}}{{/type:set_elem_type}}]{{/type:set?}}{{! }}{{#type:map?}}__T.Dict[{{#type:key_type}}{{> common/FieldType}}{{/type:key_type}},{{! }} {{#type:value_type}}{{> common/FieldType}}{{/type:value_type}}]{{/type:map?}}{{! }}{{#type:enum}}{{#type:externalProgram?}}{{> common/ModulePath}}.{{/type:externalProgram?}}{{enum:name}}{{/type:enum}}{{! }}{{#type:typedef?}}{{#type:typedef_type}}{{#type:struct?}}{{> common/FieldType}}{{/type:struct?}}{{/type:typedef_type}}{{/type:typedef?}}{{! }}{{/type:has_adapter?}} )__FBTHRIFT_TAG__", // pyi/common/ModulePath.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Included in several places within most of the cython files to specialize the the path to the module of the given type. }} {{#type:modulePath}}{{value}}{{^last?}}.{{/last?}}{{/type:modulePath}} )__FBTHRIFT_TAG__", // pyi/common/OptionalFieldType.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Wraps FieldType with an optional type when there's no default value. }}{{^field:value}}{{^field:optional?}}__T.Optional[{{/field:optional?}}{{/field:value}}{{! }}{{#field:optional?}}__T.Optional[{{/field:optional?}}{{! }}{{> common/FieldType}}{{! }}{{^field:value}}{{^field:optional?}}]{{/field:optional?}}{{/field:value}}{{! }}{{#field:optional?}}]{{/field:optional?}} )__FBTHRIFT_TAG__", // pyi/constants.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates external type annotations for legacy Thrift files. }} {{> common/AutoGeneratedPy}} import typing as __T {{#program:importModules}} import {{.}} {{/program:importModules}} from {{#program:pyNamespaces}}{{value}}.{{/program:pyNamespaces}}ttypes import * {{#program:constants}} {{#constant:value}}{{> common/Constant}}{{/constant:value}}{{! }}{{/program:constants}} )__FBTHRIFT_TAG__", // pyi/service.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates external type annotations for legacy Thrift files. }} {{> common/AutoGeneratedPy}} import typing as __T {{#program:asyncio?}} import asyncio {{/program:asyncio?}} from thrift import Thrift from thrift.protocol.TProtocol import TProtocolBase {{#program:importModules}} import {{.}} {{/program:importModules}} from {{#program:pyNamespaces}}{{value}}.{{/program:pyNamespaces}}ttypes import * {{#service:extends}} import {{#service:pyNamespaces}}{{value}}.{{/service:pyNamespaces}}{{service:name}} {{/service:extends}} class Iface{{! }}{{#service:extends}}({{! }}{{#service:pyNamespaces}}{{value}}.{{/service:pyNamespaces}}{{! }}{{service:name}}.Iface{{! }}){{/service:extends}}:{{^service:functions}} ...{{/service:functions}} # {{service:name}} {{#program:asyncio?}} # These have to be Awaitable because handler methods don't return Futures # Clients do return Futures but lsp requires us to say they are both Awaitable # You can cast the result of a Client if you need Future {{/program:asyncio?}} {{#service:functions}} {{#function:isSupported?}} def {{function:name}}(self{{#function:args}}, {{! }}{{field:py_name}}: {{#field:type}}{{> common/FieldType}}{{/field:type}}{{! }}{{/function:args}}) -> {{! }}{{#program:asyncio?}}__T.Awaitable[{{/program:asyncio?}}{{! }}{{#function:return_type}}{{> common/FieldType}}{{/function:return_type}}{{! }}{{#program:asyncio?}}]{{/program:asyncio?}}{{! }}: ... {{/function:isSupported?}} {{/service:functions}} class Client(Iface, __T.ContextManager[Client]): # {{service:name}} {{#program:asyncio?}}{{! }}def __init__(self, oprot: __T.Optional[TProtocolBase], loop: __T.Optional[asyncio.AbstractEventLoop] = None, cpp_transport: __T.Optional[__T.TypeVar("SyncClient")] = None) -> None: ...{{! }}{{/program:asyncio?}}{{! }}{{^program:asyncio?}}{{! }}def __init__(self, iprot: __T.Optional[TProtocolBase], oprot: __T.Optional[TProtocolBase] = None, cpp_transport: __T.Optional[__T.TypeVar("SyncClient")] = None) -> None: ...{{! }}{{/program:asyncio?}} def set_persistent_header(self, key: str, value: str) -> None: ... def get_persistent_headers(self) -> __T.Mapping[str, str]: ... def clear_persistent_headers(self) -> None: ... def set_onetime_header(self, key: str, value: str) -> None: ... def get_last_response_headers(self) -> __T.Mapping[str, str]: ... def set_max_frame_size(self, size: int) -> None: ... {{#service:functions}} {{#function:isSupported?}} def send_{{function:name}}(self{{#function:args}}, {{! }}{{field:py_name}}: {{#field:type}}{{> common/OptionalFieldType}}{{/field:type}} = ...{{! }}{{/function:args}}) -> None: ... def recv_{{function:name}}(self{{#program:asyncio?}}, iprot: TProtocolBase, mtype: int, rseqid: int{{/program:asyncio?}}) -> {{! }}{{#program:asyncio?}}None{{/program:asyncio?}}{{! }}{{^program:asyncio?}}{{! }}{{#function:return_type}}{{> common/FieldType}}{{/function:return_type}}{{! }}{{/program:asyncio?}}{{! }}: ... {{/function:isSupported?}} {{/service:functions}} class Processor(Iface, Thrift.TProcessor): # {{service:name}} def __init__(self, handler: Iface) -> None: self._handler: Iface self._onewayMethods: __T.Sequence[__T.Callable] self._processMap: __T.Dict[str, __T.Callable] {{#service:functions}} {{#function:isSupported?}} def process_{{function:name}}(self, {{! }}seqid: int, {{! }}iprot: TProtocolBase, {{! }}oprot: TProtocolBase, {{! }}server_ctx: __T.Any = ...{{! }}) -> {{^program:asyncio?}}None{{/program:asyncio?}}{{#program:asyncio?}}asyncio.Future{{/program:asyncio?}}: ... {{/function:isSupported?}} {{/service:functions}} def process_main(self, {{! }}iprot: TProtocolBase, {{! }}oprot: TProtocolBase, {{! }}server_ctx: __T.Any = ...{{! }}) -> {{^program:asyncio?}}__T.Optional[bool]{{/program:asyncio?}}{{#program:asyncio?}}asyncio.Future{{/program:asyncio?}}: ... def onewayMethods(self) -> __T.Tuple[__T.Callable]: ... {{#service:functions}} {{#function:isSupported?}} class {{function:name}}_args: thrift_spec: __T.Tuple[__T.Optional[__T.Tuple[int, int, str, __T.Any, __T.Optional[int], int]]] thrift_field_annotations: __T.Dict[int, __T.Dict[str, str]] thrift_struct_annotations: __T.Dict[str, str] def __init__( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> common/OptionalFieldType}}{{/field:type}} = ...{{/function:args}} ) -> None: {{#function:args}} {{#field:type}} self.{{field:py_name}}: {{> common/OptionalFieldType}} {{/field:type}} {{/function:args}} {{^function:args}} ... {{/function:args}} def isUnion(self) -> bool: ... def checkRequired(self) -> None: ... def read(self, iprot: TProtocolBase) -> None: ... def write(self, oprot: TProtocolBase) -> None: ... def __eq__(self, other: __T.Any) -> bool: ... def __ne__(self, other: __T.Any) -> bool: ... class {{function:name}}_result: thrift_spec: __T.Tuple[__T.Optional[__T.Tuple[int, int, str, __T.Any, __T.Optional[int], int]]] thrift_field_annotations: __T.Dict[int, __T.Dict[str, str]] thrift_struct_annotations: __T.Dict[str, str] def __init__(self, {{! }}success: {{#function:return_type}}{{> common/FieldType}}{{! }}{{/function:return_type}} = ...) -> None: self.success: {{#function:return_type}}{{> common/FieldType}}{{! }}{{/function:return_type}} def isUnion(self) -> bool: ... def checkRequired(self) -> None: ... def read(self, iprot: TProtocolBase) -> None: ... def write(self, oprot: TProtocolBase) -> None: ... def __eq__(self, other: __T.Any) -> bool: ... def __ne__(self, other: __T.Any) -> bool: ... {{/function:isSupported?}} {{/service:functions}} )__FBTHRIFT_TAG__", // pyi/ttypes.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates external type annotations for legacy Thrift files. }} {{> common/AutoGeneratedPy}} # pyre-unsafe import typing as __T # sometimes `t` is used as a field name from thrift import Thrift from thrift.protocol.TProtocol import TProtocolBase __property__ = property # sometimes `property` is used as a field name {{#program:importModules}} import {{.}} {{/program:importModules}} UTF8STRINGS: bool {{#program:enums}} class {{enum:name}}(int): {{#enum:values}} {{enum_value:name}}: __T.ClassVar[{{enum:name}}] {{/enum:values}} _VALUES_TO_NAMES: __T.ClassVar[__T.Dict[{{enum:name}}, str]] _NAMES_TO_VALUES: __T.ClassVar[__T.Dict[str, {{enum:name}}]] {{/program:enums}} {{#program:structs}} class {{struct:name}}{{#struct:exception?}}(Thrift.TException){{/struct:exception?}}: thrift_spec: __T.Tuple[__T.Optional[__T.Tuple[int, int, str, __T.Any, __T.Optional[int], int]]] thrift_field_annotations: __T.Dict[int, __T.Dict[str, str]] thrift_struct_annotations: __T.Dict[str, str] def __init__( self{{#struct:fields}}, {{field:py_name}}: {{#field:type}}{{> common/OptionalFieldType}}{{/field:type}} = ...{{/struct:fields}} ) -> None: ... {{^struct:union?}} {{#struct:fields}} {{#field:type}} @__property__ def {{field:py_name}}(self) -> {{#field:PEP484Optional?}}__T.Optional[{{/field:PEP484Optional?}}{{! }}{{> common/FieldType}}{{#field:PEP484Optional?}}]{{/field:PEP484Optional?}}: ... @{{field:py_name}}.setter def {{field:py_name}}(self, value: {{> common/OptionalFieldType}}) -> None: ... {{/field:type}} {{/struct:fields}} {{/struct:union?}} {{#struct:union?}} def getType(self) -> int: ... {{#struct:fields}} {{#field:type}} def get_{{field:py_name}}(self) -> {{> common/FieldType}}: ... def set_{{field:py_name}}(self, value: {{> common/FieldType}}) -> None: ... {{/field:type}} {{/struct:fields}} __EMPTY__: int = ... {{#struct:fields}} {{#field:type}} {{field:capitalizedName}}: int = ... {{/field:type}} {{/struct:fields}} {{/struct:union?}} def isUnion(self) -> bool: ... def checkRequired(self) -> None: ... def read(self, iprot: TProtocolBase) -> None: ... {{#program:json?}} @__T.overload def readFromJson(self, json: __T.Dict[str, __T.Any], is_text: bool = ..., **kwargs: __T.Any) -> None: ... @__T.overload def readFromJson(self, json: str, is_text: bool = ..., **kwargs: __T.Any) -> None: ... {{/program:json?}} def write(self, oprot: TProtocolBase) -> None: ... def __eq__(self, other: __T.Any) -> bool: ... def __ne__(self, other: __T.Any) -> bool: ... def __dir__(self) -> __T.Sequence[str]: ... {{!TODO: accommodate root_module_prefix}} def _to_python(self) -> "{{#program:pythonNamespaces}}{{value}}.{{/program:pythonNamespaces}}{{program:name}}.thrift_types.{{struct:name}}": ... # type: ignore def _to_py3(self) -> "{{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types.{{struct:name}}": ... # type: ignore def _to_py_deprecated(self) -> {{struct:name}}: ... {{/program:structs}} {{#program:typedefs}} {{typedef:name}} = {{#typedef:type}}{{> common/FieldType}}{{/typedef:type}} {{/program:typedefs}} )__FBTHRIFT_TAG__", // python/clients/client_body.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Thrift python client body definition, which is shared between normal clients and interaction clients }}@staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{service:name}}" @staticmethod def __get_thrift_uri__() -> _typing.Optional[str]: return {{#service:thrift_uri}}"{{service:thrift_uri}}"{{/service:thrift_uri}}{{! }}{{^service:thrift_uri}}None{{/service:thrift_uri}} @staticmethod def __get_thrift_unstructured_annotations_DEPRECATED__() -> _typing.Mapping[str, str]: return { {{#service:annotations}}{{> common/annotation}}{{/service:annotations}} } {{^service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:name}}() {{/service:interaction?}} {{#service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:parent_service_name}}_{{service:name}}() {{/service:interaction?}} class Async({{#service:extends}}{{! }}{{> services/client_module_path}}.Async{{! }}{{/service:extends}}{{^service:extends?}}{{! }}_fbthrift_python_AsyncClient{{! }}{{/service:extends?}}): @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{service:name}}" @staticmethod def __get_thrift_uri__() -> _typing.Optional[str]: return {{#service:thrift_uri}}"{{service:thrift_uri}}"{{/service:thrift_uri}}{{! }}{{^service:thrift_uri}}None{{/service:thrift_uri}} {{^service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:name}}() {{/service:interaction?}} {{#service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:parent_service_name}}_{{service:name}}() {{/service:interaction?}} {{#service:supported_functions}} async def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}}, *, rpc_options: _typing.Optional[RpcOptions] = None, ) -> {{#function:return_type}}{{! }}{{#function:returns_tuple?}}_typing.Tuple[{{/function:returns_tuple?}}{{! }}{{#function:creates_interaction?}}{{service:name}}_{{function:created_interaction}}.Async{{^type:void?}}, {{> types/pep484_return_type}}{{/type:void?}}{{/function:creates_interaction?}}{{! }}{{^function:creates_interaction?}}{{> types/pep484_return_type}}{{/function:creates_interaction?}}{{! }}{{#function:returns_tuple?}}]{{/function:returns_tuple?}}{{! }}{{/function:return_type}}: {{#function:creates_interaction?}} _fbthrift_interaction = self.create{{function:created_interaction}}() {{/function:creates_interaction?}} _fbthrift_resp = await self._send_request( {{^service:interaction?}}"{{service:name}}"{{/service:interaction?}}{{#service:interaction?}}"{{service:parent_service_name}}"{{/service:interaction?}}, {{#service:interaction?}}"{{service:name}}.{{function:name}}",{{/service:interaction?}}{{^service:interaction?}}"{{function:name}}",{{/service:interaction?}} {{> types/function_args_type}}({{#function:args}} {{field:py_name}}={{field:py_name}},{{/function:args}}), {{> clients/client_return_type}}, qualifier = _fbthrift_FunctionQualifier.{{function:qualifier}}, {{#function:creates_interaction?}} interaction_position=_fbthrift_InteractionMethodPosition.Factory, interaction_name="{{function:created_interaction}}", created_interaction = _fbthrift_interaction, {{/function:creates_interaction?}} {{#service:interaction?}} interaction_position=_fbthrift_InteractionMethodPosition.Member, interaction_name="{{service:name}}", {{/service:interaction?}} uri_or_name={{#service:thrift_uri}}"{{service:thrift_uri}}"{{/service:thrift_uri}}{{! }}{{^service:thrift_uri}}"{{service:name}}"{{/service:thrift_uri}}, rpc_options=rpc_options, ) {{#function:stream?}} _fbthrift_resp, _fbthrift_stream = _fbthrift_resp {{/function:stream?}} {{#function:return_type}} {{#function:early_client_return?}} # shortcut to success path for non-void returns if _fbthrift_resp.success is not None: return {{#function:creates_interaction?}}_fbthrift_interaction, {{/function:creates_interaction?}}{{! }}_fbthrift_resp.success{{#function:stream?}}, _fbthrift_stream{{/function:stream?}} {{/function:early_client_return?}} {{#function:exceptions}} if _fbthrift_resp.{{field:py_name}} is not None: raise _fbthrift_resp.{{field:py_name}} {{/function:exceptions}} {{^function:early_client_return?}} {{^function:void?}} return {{#function:creates_interaction?}}_fbthrift_interaction{{/function:creates_interaction?}}{{! }}{{#function:returns_tuple?}}, {{/function:returns_tuple?}}{{! }}{{#function:stream?}}_fbthrift_stream{{/function:stream?}} {{/function:void?}} {{/function:early_client_return?}} {{#function:with_regular_response?}} raise _fbthrift_python_exceptions.ApplicationError( _fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT, "Empty Response", ) {{/function:with_regular_response?}} {{/function:return_type}} {{/service:supported_functions}} {{#service:interactions}} def create{{service:name}}( self #{{service:parent_service_name}} ) -> {{service:parent_service_name}}_{{service:name}}.Async: return self._create_interaction("{{service:name}}", {{service:parent_service_name}}_{{service:name}}.Async) async def async_create{{service:name}}( self #{{service:parent_service_name}} ) -> {{service:parent_service_name}}_{{service:name}}.Async: return self.create{{service:name}}() {{/service:interactions}} class Sync({{#service:extends}}{{! }}{{> services/client_module_path}}.Sync{{! }}{{/service:extends}}{{^service:extends?}}{{! }}_fbthrift_python_SyncClient{{! }}{{/service:extends?}}): @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{service:name}}" @staticmethod def __get_thrift_uri__() -> _typing.Optional[str]: return {{#service:thrift_uri}}"{{service:thrift_uri}}"{{/service:thrift_uri}}{{! }}{{^service:thrift_uri}}None{{/service:thrift_uri}} {{^service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:name}}() {{/service:interaction?}} {{#service:interaction?}} @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:parent_service_name}}_{{service:name}}() {{/service:interaction?}} {{#service:supported_functions}} {{^function:async_only?}} def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}}, *, rpc_options: _typing.Optional[RpcOptions] = None, ) -> {{#function:return_type}}{{> types/pep484_return_type}}{{/function:return_type}}: _fbthrift_resp = self._send_request( "{{service:name}}", "{{function:name}}", {{> types/function_args_type}}({{#function:args}} {{field:py_name}}={{field:py_name}},{{/function:args}}), {{> clients/client_return_type}}, uri_or_name={{#service:thrift_uri}}"{{service:thrift_uri}}"{{/service:thrift_uri}}{{! }}{{^service:thrift_uri}}"{{service:name}}"{{/service:thrift_uri}}, rpc_options=rpc_options, ) {{#function:return_type}}{{^type:void?}} # shortcut to success path for non-void returns if _fbthrift_resp.success is not None: return _fbthrift_resp.success {{/type:void?}}{{/function:return_type}} {{#function:exceptions}} if _fbthrift_resp.{{field:py_name}} is not None: raise _fbthrift_resp.{{field:py_name}} {{/function:exceptions}} {{#function:return_type}}{{^type:void?}} raise _fbthrift_python_exceptions.ApplicationError( _fbthrift_python_exceptions.ApplicationErrorType.MISSING_RESULT, "Empty Response", ) {{/type:void?}}{{/function:return_type}} {{/function:async_only?}} {{/service:supported_functions}} )__FBTHRIFT_TAG__", // python/clients/client_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The client return type tuple }}{{#function:stream?}}({{/function:stream?}}{{> types/function_return_type }}{{! }}{{#function:stream?}}, {{> types/function_second_return_type }}){{/function:stream?}} )__FBTHRIFT_TAG__", // python/clients/stream_response_class_name.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Stream response class name. }}{{#function:stream_has_first_response?}}_typing.Tuple[{{! }}{{#function:stream_first_response_type}}{{> types/pep484_type}}{{/function:stream_first_response_type}}{{! }}, {{/function:stream_has_first_response?}}{{! }}_typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None]{{! }}{{#function:stream_has_first_response?}}]{{/function:stream_has_first_response?}} )__FBTHRIFT_TAG__", // python/common/annotation.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! A single annotation, written out for python consumption in a dict. Annotations may start/end with quotes hence we take extra care }} {{annotation:py_quoted_key}}: {{! }}{{#annotation:value?}}{{annotation:py_quoted_value}}{{/annotation:value?}}{{! An annotation without an explicitly provided value is implicitly assigned the default value "1". }}{{^annotation:value?}}"1"{{/annotation:value?}}, )__FBTHRIFT_TAG__", // python/common/auto_generated_py.mustache R"__FBTHRIFT_TAG__(# # Autogenerated by Thrift # # DO NOT EDIT # @{{!x}}generated # from __future__ import annotations {{#program:import_static?}} import __static__ {{/program:import_static?}} {{! terminate with newline }} )__FBTHRIFT_TAG__", // python/fields/adapted_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Adapted type if field has adapter, otherwise the original type }}{{#field:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#field:type}}{{> types/python_type}}{{/field:type}}]{{/adapter:is_generic?}}{{! }}{{/field:has_adapter?}}{{! }}{{^field:has_adapter?}}{{! }}{{#field:type}}{{> types/pep484_type}}{{/field:type}}{{! }}{{/field:has_adapter?}} )__FBTHRIFT_TAG__", // python/fields/adapter_info.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! A tuple of: 1. adapter class, 2. a lambda that returns transitive annotation (if the adapter is applied via transitive annotation, else None.) if the field has an adapter, else None. }}{{#field:has_adapter?}}({{! }}{{adapter:name}}, lambda: {{! }}{{#adapter:is_transitive?}}{{! }}{{#adapter:transitive_annotation}}{{> types/constant_value }}{{/adapter:transitive_annotation}}{{! }}{{/adapter:is_transitive?}}{{! }}{{^adapter:is_transitive?}}{{! }}None{{! }}{{/adapter:is_transitive?}}{{! }}){{/field:has_adapter?}}{{! }}{{^field:has_adapter?}}{{! }}None{{! }}{{/field:has_adapter?}} )__FBTHRIFT_TAG__", // python/fields/compatible_adapted_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Adapted type if field has adapter, otherwise the original type }}{{#field:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#field:type}}{{> types/python_type}}{{/field:type}}]{{/adapter:is_generic?}}{{! }}{{/field:has_adapter?}}{{! }}{{^field:has_adapter?}}{{! }}{{#field:type}}{{> types/compatible_pep484_type}}{{/field:type}}{{! }}{{/field:has_adapter?}} )__FBTHRIFT_TAG__", // python/fields/is_primitive.mustache R"__FBTHRIFT_TAG__({{#field:type}}{{! }}{{#type:numeric_or_void?}}True{{/type:numeric_or_void?}}{{! }}{{#type:enum?}}False{{/type:enum?}}{{! }}{{#type:binary?}}True{{/type:binary?}}{{! }}{{#type:iobuf?}}{{^type:binary?}}True{{/type:binary?}}{{/type:iobuf?}}{{! }}{{#type:string?}}False{{/type:string?}}{{! }}{{#type:struct?}}False{{/type:struct?}}{{! }}{{#type:list?}}False{{/type:list?}}{{! }}{{#type:set?}}False{{/type:set?}}{{! }}{{#type:map?}}False{{/type:map?}}{{! }}{{#type:void?}}False{{/type:void?}}{{! }}{{/field:type}}{{^field:type}}False{{/field:type}} )__FBTHRIFT_TAG__", // python/metadata/const_struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}_fbthrift_metadata.ThriftConstStruct({{#value:const_struct_type}}type={{#type:struct}}{{! }}_fbthrift_metadata.ThriftStructType(name="{{type:program_name}}.{{> structs/unadapted_name}}"){{/type:struct}}, {{/value:const_struct_type}}{{! }}fields= { {{#value:const_struct}}"{{constant:name}}": {{#constant:value}}{{ > metadata/const_value }}{{/constant:value}}, {{/value:const_struct}} }) )__FBTHRIFT_TAG__", // python/metadata/const_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}_fbthrift_metadata.ThriftConstValue({{! }}{{^value:const_struct?}}{{#value:bool?}}cv_bool={{#value:nonzero?}}True{{/value:nonzero?}}{{! }}{{^value:nonzero?}}False{{/value:nonzero?}}{{/value:bool?}}{{! }}{{#value:integer?}}cv_integer={{value:integer_value}}{{/value:integer?}}{{! }}{{#value:enum?}}cv_integer={{value:integer_value}}{{/value:enum?}}{{! }}{{#value:double?}}cv_double={{value:double_value}}{{/value:double?}}{{! }}{{#value:string?}}cv_string="{{value:string_value}}"{{/value:string?}}{{! }}{{#value:map?}}cv_map=[{{#value:map_elements}}_fbthrift_metadata.ThriftConstValuePair(key={{#element:key}}{{ > metadata/const_value }}{{/element:key}}, value={{#element:value}}{{ > metadata/const_value }}{{/element:value}}), {{/value:map_elements}}]{{/value:map?}}{{! }}{{#value:list?}}cv_list=[{{#value:list_elements}}{{ > metadata/const_value }}, {{/value:list_elements}}]{{/value:list?}}{{/value:const_struct?}}{{! }}{{#value:const_struct?}}cv_struct={{> metadata/const_struct }}{{/value:const_struct?}}) )__FBTHRIFT_TAG__", // python/metadata/recursive_call.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used to turn a thrift type into a gen_metadata call }}{{! }}{{#type:list?}}{{#type:list_elem_type}}{{> metadata/recursive_call }}{{/type:list_elem_type}}{{/type:list?}}{{! }}{{#type:set?}}{{#type:set_elem_type}}{{> metadata/recursive_call }}{{/type:set_elem_type}}{{/type:set?}}{{! }}{{#type:map?}}{{#type:key_type}}{{> metadata/recursive_call }}{{/type:key_type}} # key {{#type:value_type}}{{> metadata/recursive_call }}{{/type:value_type}} # val {{/type:map?}}{{! }}{{#type:struct?}}{{#type:struct}}new_struct = {{#type:external_program?}}{{type:metadata_path}}.{{/type:external_program?}}{{! }}_fbthrift_gen_metadata_{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}(new_struct){{/type:struct}}{{/type:struct?}}{{! }}{{#type:enum?}}{{#type:enum}}new_struct = {{#type:external_program?}}{{type:metadata_path}}.{{/type:external_program?}}{{! }}_fbthrift_gen_metadata_enum_{{enum:name}}(new_struct){{/type:enum}}{{/type:enum?}}{{! }} )__FBTHRIFT_TAG__", // python/metadata/return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#function:return_type}} {{^function:sink?}}{{ > metadata/thrift_type }}{{/function:sink?}}{{! }}{{#function:sink?}}{{! }}_fbthrift_metadata.ThriftType(t_sink=_fbthrift_metadata.ThriftSinkType({{! }}elemType={{#function:sink_elem_type}}{{> metadata/thrift_type }}{{/function:sink_elem_type}},{{! }}finalResponseType={{#function:sink_final_response_type}}{{> metadata/thrift_type }}{{/function:sink_final_response_type}}{{! }}{{#function:sink_has_first_response?}},initialResponseType={{#function:sink_first_response_type}}{{> metadata/thrift_type }}{{/function:sink_first_response_type}}{{/function:sink_has_first_response?}})){{! }}{{/function:sink?}}{{! }}{{#function:stream?}}{{! }}_fbthrift_metadata.ThriftType(t_stream=_fbthrift_metadata.ThriftStreamType({{! }}elemType={{#function:stream_elem_type}}{{> metadata/thrift_type }}{{/function:stream_elem_type}}{{! }}{{#function:stream_has_first_response?}},initialResponseType={{#function:stream_first_response_type}}{{> metadata/thrift_type }}{{/function:stream_first_response_type}}{{/function:stream_has_first_response?}})){{! }}{{/function:stream?}}{{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // python/metadata/service_metadata.mustache R"__FBTHRIFT_TAG__(qualified_name = "{{program:name}}.{{service:name}}" if qualified_name in metadata_struct.services: return metadata_struct functions = [ {{#service:functions}}{{^function:starts_interaction?}} _fbthrift_metadata.ThriftFunction(name="{{function:name}}", return_type={{> metadata/return_type }}, arguments=[ {{#function:args}} _fbthrift_metadata.ThriftField(id={{field:key}}, type={{#field:type}}{{> metadata/thrift_type }}{{/field:type}}, name="{{field:name}}", is_optional=False, structured_annotations=[ {{#field:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/field:structured_annotations}} ]), {{/function:args}} ], exceptions = [ {{#function:exceptions}} _fbthrift_metadata.ThriftField(id={{field:key}}, type={{#field:type}}{{> metadata/thrift_type }}{{/field:type}}, name="{{field:name}}", is_optional=False, structured_annotations=[ {{#field:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/field:structured_annotations}} ]), {{/function:exceptions}} ], is_oneway={{#function:oneway?}}True{{/function:oneway?}}{{^function:oneway?}}False{{/function:oneway?}}, structured_annotations=[ {{#function:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/function:structured_annotations}} ]), {{/function:starts_interaction?}}{{/service:functions}} ] service_dict = dict(metadata_struct.services) service_dict[qualified_name] = _fbthrift_metadata.ThriftService(name=qualified_name, functions=functions, {{#service:extends?}}{{#service:extends}}parent="{{service:program_name}}.{{service:name}}",{{/service:extends}}{{/service:extends?}} structured_annotations=[ {{#service:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/service:structured_annotations}} ]) new_struct = metadata_struct(services=service_dict) {{#service:extends?}}{{#service:extends}} new_struct = {{#service:external_program?}}{{service:module_path}}.thrift_metadata.{{/service:external_program?}}_fbthrift_gen_metadata_service_{{service:name}}(new_struct) {{/service:extends}}{{/service:extends?}} {{#service:functions}}{{^function:starts_interaction?}} {{#function:args}} {{#field:type}}{{> metadata/recursive_call }} # {{field:name}}{{/field:type}} {{/function:args}} {{#function:exceptions}} {{#field:type}}{{> metadata/recursive_call }} # {{field:name}}{{/field:type}} {{/function:exceptions}} {{#function:return_type}} {{> metadata/recursive_call }}{{! }}{{#function:stream?}}{{#function:stream_elem_type}}{{> metadata/recursive_call }}{{/function:stream_elem_type}} # elem {{#function:stream_first_response_type}}{{> metadata/recursive_call }}{{/function:stream_first_response_type}} # response {{/function:stream?}}{{! }}{{#function:sink?}}{{#function:sink_elem_type}}{{> metadata/recursive_call }}{{/function:sink_elem_type}} # elem {{#function:sink_final_response_type}}{{> metadata/recursive_call }}{{/function:sink_final_response_type}} # final response {{#function:sink_first_response_type}}{{> metadata/recursive_call }}{{/function:sink_first_response_type}} # first response {{/function:sink?}}{{! }} # return value {{/function:return_type}} {{/function:starts_interaction?}}{{/service:functions}} return new_struct )__FBTHRIFT_TAG__", // python/metadata/thrift_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Used to turn a type into a thrift metadata ThriftType struct }}{{#type:typedef?}}_fbthrift_metadata.ThriftType(t_typedef={{! TODO this branch never gets hit }}_fbthrift_metadata.ThriftTypedefType(name="{{type:program_name}}.{{type:name}}", {{! }}underlyingType={{#type:typedef_type}}{{> metadata/thrift_type }}{{/type:typedef_type}}, {{! }}structured_annotations=[]){{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{#type:bool?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_BOOL_TYPE){{/type:bool?}}{{! }}{{#type:byte?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_BYTE_TYPE){{/type:byte?}}{{! }}{{#type:i16?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I16_TYPE){{/type:i16?}}{{! }}{{#type:i32?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I32_TYPE){{/type:i32?}}{{! }}{{#type:i64?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_I64_TYPE){{/type:i64?}}{{! }}{{#type:float?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_FLOAT_TYPE){{/type:float?}}{{! }}{{#type:double?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_DOUBLE_TYPE){{/type:double?}}{{! }}{{#type:string?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_STRING_TYPE){{/type:string?}}{{! }}{{#type:binary?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_BINARY_TYPE){{/type:binary?}}{{! }}{{#type:void?}}_fbthrift_metadata.ThriftType(t_primitive=_fbthrift_metadata.ThriftPrimitiveType.THRIFT_VOID_TYPE){{/type:void?}}{{! }}{{#type:struct}}{{! }}{{#struct:union?}}{{! }}_fbthrift_metadata.ThriftType(t_union=_fbthrift_metadata.ThriftUnionType({{! }}name="{{type:program_name}}.{{> structs/unadapted_name}}")){{! }}{{/struct:union?}}{{! }}{{^struct:union?}}{{! }}_fbthrift_metadata.ThriftType(t_struct=_fbthrift_metadata.ThriftStructType({{! }}name="{{type:program_name}}.{{> structs/unadapted_name}}")){{! }}{{/struct:union?}}{{! }}{{/type:struct}}{{! }}{{#type:list?}}{{! }}_fbthrift_metadata.ThriftType(t_list=_fbthrift_metadata.ThriftListType({{! }}valueType={{#type:list_elem_type}}{{> metadata/thrift_type }}{{/type:list_elem_type}})){{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}_fbthrift_metadata.ThriftType(t_set=_fbthrift_metadata.ThriftSetType({{! }}valueType={{#type:set_elem_type}}{{> metadata/thrift_type }}{{/type:set_elem_type}})){{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}_fbthrift_metadata.ThriftType(t_map=_fbthrift_metadata.ThriftMapType({{! }}keyType={{#type:key_type}}{{> metadata/thrift_type }}{{/type:key_type}},{{! }}valueType={{#type:value_type}}{{> metadata/thrift_type }}{{/type:value_type}})){{! }}{{/type:map?}}{{! }}{{#type:enum}}{{! }}_fbthrift_metadata.ThriftType(t_enum=_fbthrift_metadata.ThriftEnumType({{! }}name="{{type:program_name}}.{{enum:name}}")){{! }}{{/type:enum}}{{/type:typedef?}} )__FBTHRIFT_TAG__", // python/services/client_module_path.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This generates module path to the client given a service }}{{#service:external_program?}}{{service:module_path}}.thrift_clients.{{/service:external_program?}}{{service:name}} )__FBTHRIFT_TAG__", // python/services/function_kind.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^function:oneway?}}{{! }}{{^function:stream?}}{{! }}{{^function:sink?}}{{! }}RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE{{! }}{{/function:sink?}}{{! }}{{#function:sink?}}{{! }}RpcKind.SINK{{! }}{{/function:sink?}}{{! }}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}RpcKind.SINGLE_REQUEST_STREAMING_RESPONSE{{! }}{{/function:stream?}}{{! }}{{/function:oneway?}}{{! }}{{#function:oneway?}}{{! }}RpcKind.SINGLE_REQUEST_NO_RESPONSE{{! }}{{/function:oneway?}} )__FBTHRIFT_TAG__", // python/services/get_handler_result.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}value = {{^function:stream?}}await {{/function:stream?}}self.{{function:name}}({{#function:args}}args_struct.{{field:py_name}},{{/function:args}}) {{#function:stream?}} {{#function:stream_has_first_response?}} value, stream = await value {{/function:stream_has_first_response?}} {{^function:stream_has_first_response?}} stream = value {{/function:stream_has_first_response?}} if not isinstance(stream, _typing.AsyncIterator): stream = await stream {{/function:stream?}} {{^function:oneway?}} return_struct = {{> types/function_return_type}}({{! }}{{#function:with_regular_response?}}success=value{{/function:with_regular_response?}}) {{/function:oneway?}} {{#function:stream?}} return_stream = self._fbthrift__stream_wrapper_{{function:name}}(stream, protocol) {{/function:stream?}} )__FBTHRIFT_TAG__", // python/services/service_func_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is to override types/pep484_type for stream return types. This is useful for typing call paterns since it allows python container types OR thrift-py3 specific container types. }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}_typing.Tuple[{{#function:stream_first_response_type}}{{! }}{{> types/pep484_type}}, {{/function:stream_first_response_type}}{{/function:stream_has_first_response?}}{{! }}_typing.Awaitable[_typing.AsyncIterator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}]] | {{! }}_typing.AsyncIterator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}]{{! }}{{#function:stream_has_first_response?}}]{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}{{^function:stream?}}{{! }}{{> types/pep484_type}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // python/services/service_handler_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The internal return type of a service handler }}{{#function:oneway?}}None{{/function:oneway?}}{{! }}{{^function:oneway?}}{{! }}{{#function:stream?}}_typing.Tuple[_fbthrift_iobuf.IOBuf, _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]]{{/function:stream?}}{{! }}{{^function:stream?}}_fbthrift_iobuf.IOBuf{{/function:stream?}}{{! }}{{/function:oneway?}} )__FBTHRIFT_TAG__", // python/structs/unadapted_name.mustache R"__FBTHRIFT_TAG__({{! Copyright 2016 Meta Platforms, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Raw struct name, with special preffix if directly adapted }}{{#struct:has_adapter?}}_fbthrift_unadapted_{{/struct:has_adapter?}}{{struct:name}} )__FBTHRIFT_TAG__", // python/thrift_clients.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Python classes for Thrift clients }} {{> common/auto_generated_py}} import typing as _typing import apache.thrift.metadata.thrift_types as _fbthrift_metadata import folly.iobuf as _fbthrift_iobuf from {{program:base_library_package}}.client import ( AsyncClient as _fbthrift_python_AsyncClient, SyncClient as _fbthrift_python_SyncClient, Client as _fbthrift_python_Client, ) from {{program:base_library_package}}.client.omni_client import InteractionMethodPosition as _fbthrift_InteractionMethodPosition, FunctionQualifier as _fbthrift_FunctionQualifier from {{program:base_library_package}}.common import RpcOptions import {{program:base_library_package}}.exceptions as _fbthrift_python_exceptions import {{program:base_library_package}}.types as _fbthrift_python_types import {{program:module_path}}.thrift_types import {{program:module_path}}.thrift_metadata {{#program:include_namespaces}} {{#has_types?}} import {{included_module_path}}.thrift_types {{/has_types?}} {{#has_services?}} import {{included_module_path}}.thrift_clients {{/has_services?}} {{/program:include_namespaces}} {{#program:adapter_modules}} import {{module_path}} {{/program:adapter_modules}} {{#program:adapter_type_hint_modules}} import {{module_path}} {{/program:adapter_type_hint_modules}} {{#program:services?}} {{#program:services}} class {{service:name}}(_fbthrift_python_Client["{{service:name}}.Async", "{{service:name}}.Sync"]): {{> clients/client_body }} {{#service:interactions}} class {{service:parent_service_name}}_{{service:name}}(_fbthrift_python_Client["{{service:parent_service_name}}_{{service:name}}.Async", "{{service:parent_service_name}}_{{service:name}}.Sync"]): {{> clients/client_body }} {{/service:interactions}} {{/program:services}} {{/program:services?}} )__FBTHRIFT_TAG__", // python/thrift_metadata.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Metadata for Thrift types }} {{> common/auto_generated_py}} import apache.thrift.metadata.thrift_types as _fbthrift_metadata {{#program:include_namespaces}} {{#has_types?}} import {{included_module_path}}.thrift_metadata {{/has_types?}} {{/program:include_namespaces}} {{#program:structs}} # TODO (ffrancet): This general pattern can be optimized by using tuples and dicts # instead of re-generating thrift structs def _fbthrift_gen_metadata_{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}({{! }}metadata_struct: _fbthrift_metadata.ThriftMetadata) -> _fbthrift_metadata.ThriftMetadata: qualified_name = "{{program:name}}.{{> structs/unadapted_name}}" if qualified_name in metadata_struct.{{#struct:exception?}}exceptions{{/struct:exception?}}{{^struct:exception?}}structs{{/struct:exception?}}: return metadata_struct fields = [ {{#struct:fields_ordered_by_id}} _fbthrift_metadata.ThriftField(id={{field:key}}, type={{#field:type}}{{> metadata/thrift_type }}{{/field:type}}, name="{{field:name}}", is_optional={{#field:optional?}}True{{/field:optional?}}{{^field:optional?}}False{{/field:optional?}}, structured_annotations=[ {{#field:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/field:structured_annotations}} ]), {{/struct:fields_ordered_by_id}} ] struct_dict = dict(metadata_struct.{{#struct:exception?}}exceptions{{/struct:exception?}}{{^struct:exception?}}structs{{/struct:exception?}}) struct_dict[qualified_name] = _fbthrift_metadata.{{! }}{{#struct:exception?}}ThriftException{{/struct:exception?}}{{^struct:exception?}}ThriftStruct{{/struct:exception?}}(name=qualified_name, fields=fields, {{^struct:exception?}} is_union={{#struct:union?}}True{{/struct:union?}}{{^struct:union?}}False{{/struct:union?}}, {{/struct:exception?}} structured_annotations=[ {{#struct:structured_annotations}} {{#structured_annotation:const_struct?}}{{#structured_annotation:const}}{{#constant:value}} {{> metadata/const_struct }}, {{/constant:value}}{{/structured_annotation:const}}{{/structured_annotation:const_struct?}} {{/struct:structured_annotations}} ]) new_struct = metadata_struct({{#struct:exception?}}exceptions{{/struct:exception?}}{{^struct:exception?}}structs{{/struct:exception?}}=struct_dict) {{#struct:fields}} {{#field:type}}{{> metadata/recursive_call }}{{/field:type}} # {{field:name}} {{/struct:fields}} return new_struct def gen_metadata_{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}() -> _fbthrift_metadata.ThriftMetadata: return _fbthrift_gen_metadata_{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}({{! }}_fbthrift_metadata.ThriftMetadata(structs={}, enums={}, exceptions={}, services={})) {{/program:structs}} {{#program:services}} def gen_metadata_service_{{service:name}}() -> _fbthrift_metadata.ThriftMetadata: return _fbthrift_gen_metadata_service_{{service:name}}(_fbthrift_metadata.ThriftMetadata(structs={}, enums={}, exceptions={}, services={})) def _fbthrift_gen_metadata_service_{{service:name}}({{! }}metadata_struct: _fbthrift_metadata.ThriftMetadata) -> _fbthrift_metadata.ThriftMetadata: {{> metadata/service_metadata }} {{#service:interactions}} def gen_metadata_service_{{service:parent_service_name}}_{{service:name}}() -> _fbthrift_metadata.ThriftMetadata: return _fbthrift_gen_metadata_service_{{service:parent_service_name}}_{{service:name}}(_fbthrift_metadata.ThriftMetadata(structs={}, enums={}, exceptions={}, services={})) def _fbthrift_gen_metadata_service_{{service:parent_service_name}}_{{service:name}}({{! }}metadata_struct: _fbthrift_metadata.ThriftMetadata) -> _fbthrift_metadata.ThriftMetadata: {{> metadata/service_metadata }} {{/service:interactions}} def _fbthrift_metadata_service_response_{{service:name}}() -> _fbthrift_metadata.ThriftServiceMetadataResponse: metadata = gen_metadata_service_{{service:name}}() context = _fbthrift_metadata.ThriftServiceContext(service_info=metadata.services["{{program:name}}.{{service:name}}"], module=_fbthrift_metadata.ThriftModuleContext(name="{{program:name}}")) services = [_fbthrift_metadata.ThriftServiceContextRef(module=_fbthrift_metadata.ThriftModuleContext(name=name.split('.')[0]), service_name=name) for name in metadata.services] return _fbthrift_metadata.ThriftServiceMetadataResponse(metadata=metadata,context=context,services=services) {{/program:services}} {{#program:enums}} def _fbthrift_gen_metadata_enum_{{enum:name}}({{! }}metadata_struct: _fbthrift_metadata.ThriftMetadata) -> _fbthrift_metadata.ThriftMetadata: qualified_name = "{{program:name}}.{{enum:name}}" if qualified_name in metadata_struct.enums: return metadata_struct elements = { {{#enum:values}} {{enum_value:value}}: "{{enum_value:name}}", {{/enum:values}} } enum_dict = dict(metadata_struct.enums) enum_dict[qualified_name] = _fbthrift_metadata.ThriftEnum(name=qualified_name, elements=elements, structured_annotations=[]) new_struct = metadata_struct(enums=enum_dict) return new_struct def gen_metadata_enum_{{enum:name}}() -> _fbthrift_metadata.ThriftMetadata: return _fbthrift_gen_metadata_enum_{{enum:name}}(_fbthrift_metadata.ThriftMetadata(structs={}, enums={}, exceptions={}, services={})) {{/program:enums}} def getThriftModuleMetadata() -> _fbthrift_metadata.ThriftMetadata: meta = _fbthrift_metadata.ThriftMetadata(structs={}, enums={}, exceptions={}, services={}) {{#program:enums}} meta = _fbthrift_gen_metadata_enum_{{enum:name}}(meta) {{/program:enums}} {{#program:structs}} {{#struct:exception?}} meta = _fbthrift_gen_metadata_exception_{{> structs/unadapted_name}}(meta) {{/struct:exception?}} {{^struct:exception?}} meta = _fbthrift_gen_metadata_struct_{{> structs/unadapted_name}}(meta) {{/struct:exception?}} {{/program:structs}} {{#program:services}} meta = _fbthrift_gen_metadata_service_{{service:name}}(meta) {{/program:services}} return meta )__FBTHRIFT_TAG__", // python/thrift_mutable_types.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Python classes for mutable thrift-python types. }}{{> common/auto_generated_py}} # EXPERIMENTAL - DO NOT USE !!! # See `experimental_generate_mutable_types` documentation in thrift compiler import dataclasses import {{program:base_library_package}}.mutable_types as _fbthrift_python_mutable_types import {{program:base_library_package}}.types as _fbthrift_python_types {{! For now, process all structs that are neither exceptions nor unions. }}{{#program:structs}}{{^struct:exception?}}{{^struct:union?}} class {{> structs/unadapted_name}}(metaclass=_fbthrift_python_mutable_types.MutableStructMeta): _fbthrift_SPEC = ( {{#struct:fields_ordered_by_id}} ( {{field:key}}, # id _fbthrift_python_types.{{field:tablebased_qualifier}}, # qualifier "{{field:py_name}}", # name {{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}{{/field:type}}, # typeinfo {{#field:user_default_value}}{{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{/field:type}}{{> types/constant_value }}{{/field:user_default_value}}{{! }}{{^field:user_default_value}}None{{/field:user_default_value}}, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/struct:fields_ordered_by_id}} ) @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{> structs/unadapted_name}}" @staticmethod def __get_thrift_uri__(): return {{#struct:thrift_uri}}"{{struct:thrift_uri}}"{{/struct:thrift_uri}}{{! }}{{^struct:thrift_uri}}None{{/struct:thrift_uri}} @staticmethod def __get_metadata__(): raise NotImplementedError(f"__get_metadata__() is not yet implemented for mutable thrift-python structs: {type(self)}") def _to_immutable(self): import importlib immutable_types = importlib.import_module("{{program:module_path}}.thrift_types") return immutable_types.{{> structs/unadapted_name}}(**dataclasses.asdict(self)) {{#struct:has_adapter?}} raise NotImplementedError("Adapted struct not yet supported in thrift-python: {{> structs/unadapted_name}}") {{/struct:has_adapter?}}{{! }}{{/struct:union?}}{{/struct:exception?}}{{/program:structs}} )__FBTHRIFT_TAG__", // python/thrift_mutable_types.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Python typestubs for mutable thrift-python types }}{{> common/auto_generated_py}} # EXPERIMENTAL - DO NOT USE !!! # See `experimental_generate_mutable_types` documentation in thrift compiler raise NotImplementedError(f"thrift-python mutable types are not implemented yet, do not import module: {__name__}") )__FBTHRIFT_TAG__", // python/thrift_services.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generates a top-level file to be imported in the user's service code. It provides wrappers for each of the service handlers that the user is then able to extend. }} {{> common/auto_generated_py}} from abc import ABCMeta import typing as _typing import folly.iobuf as _fbthrift_iobuf import apache.thrift.metadata.thrift_types as _fbthrift_metadata from {{program:base_library_package}}.serializer import serialize_iobuf, deserialize, Protocol from {{program:base_library_package}}.server import ServiceInterface, RpcKind, PythonUserException import {{program:module_path}}.thrift_types import {{program:module_path}}.thrift_metadata {{#program:include_namespaces}} {{#has_services?}} import {{included_module_path}}.thrift_services {{/has_services?}} {{#has_types?}} import {{included_module_path}}.thrift_types {{/has_types?}} {{/program:include_namespaces}} {{#program:adapter_modules}} import {{module_path}} {{/program:adapter_modules}} {{#program:adapter_type_hint_modules}} import {{module_path}} {{/program:adapter_type_hint_modules}} {{#program:services}} class {{service:name}}Interface( {{#service:extends}}{{#service:external_program?}} {{service:module_path}}.thrift_services.{{/service:external_program?}}{{service:name}}Interface, {{/service:extends}} {{^service:extends?}} ServiceInterface, {{/service:extends?}} metaclass=ABCMeta ): @staticmethod def service_name() -> bytes: return b"{{service:name}}" def getFunctionTable(self) -> _typing.Mapping[bytes, _typing.Callable[..., object]]: functionTable = { {{#service:supported_service_functions}} b"{{function:name}}": ({{> services/function_kind }}, self._fbthrift__handler_{{function:name}}), {{/service:supported_service_functions}} } return {**super().getFunctionTable(), **functionTable} @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{service:name}}" @staticmethod def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata: return {{program:module_path}}.thrift_metadata.gen_metadata_service_{{service:name}}() @staticmethod def __get_metadata_service_response__() -> _fbthrift_metadata.ThriftServiceMetadataResponse: return {{program:module_path}}.thrift_metadata._fbthrift_metadata_service_response_{{service:name}}() {{#service:supported_service_functions}} {{^function:stream?}}async {{/function:stream?}}{{#function:stream_has_first_response?}}async {{/function:stream_has_first_response?}}def {{function:name}}( self{{#function:args}}, {{field:py_name}}: {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{/function:args}} ) -> {{#function:return_type}}{{> services/service_func_return_type }}{{/function:return_type}}: raise NotImplementedError("async def {{function:name}} is not implemented") {{#function:stream?}} async def _fbthrift__stream_wrapper_{{function:name}}(self, stream_generator: _typing.AsyncIterator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}], protocol: Protocol) -> _typing.AsyncIterator[_fbthrift_iobuf.IOBuf]: {{#function:stream_exceptions?}} try: async for item in stream_generator: yield serialize_iobuf({{> types/function_second_return_type}}(success=item), protocol) {{#function:stream_exceptions}}{{#field:type}} except {{type:module_path}}.{{#type:struct}}{{> structs/unadapted_name}}{{/type:struct}} as e: return_struct = {{> types/function_second_return_type}}({{field:py_name}}=e) buf = serialize_iobuf(return_struct, protocol) exp = PythonUserException('{{type:py3_namespace}}{{#type:struct}}{{> structs/unadapted_name}}{{/type:struct}}', str(e), buf) raise exp {{/field:type}} {{/function:stream_exceptions}} {{/function:stream_exceptions?}} {{^function:stream_exceptions?}} async for item in stream_generator: yield serialize_iobuf({{> types/function_second_return_type}}(success=item), protocol) {{/function:stream_exceptions?}} {{/function:stream?}} async def _fbthrift__handler_{{function:name}}(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) {{! }}-> {{> services/service_handler_return_type }}: args_struct = deserialize({{> types/function_args_type}}, args, protocol) {{! TODO: call the postWrite hook here }} {{#function:exceptions?}} try: {{> services/get_handler_result }} {{#function:exceptions}}{{#field:type}} except {{type:module_path}}.{{#type:struct}}{{> structs/unadapted_name}}{{/type:struct}} as e: return_struct = {{> types/function_return_type}}({{field:py_name}}=e) buf = serialize_iobuf(return_struct, protocol) exp = PythonUserException('{{type:py3_namespace}}{{#type:struct}}{{> structs/unadapted_name}}{{/type:struct}}', str(e), buf) raise exp {{/field:type}} {{/function:exceptions}} {{/function:exceptions?}} {{^function:exceptions?}} {{> services/get_handler_result }} {{/function:exceptions?}} {{^function:oneway?}} {{^function:stream?}} return serialize_iobuf(return_struct, protocol) {{/function:stream?}} {{#function:stream?}} return (serialize_iobuf(return_struct, protocol), return_stream) {{/function:stream?}} {{/function:oneway?}} {{/service:supported_service_functions}} {{/program:services}} )__FBTHRIFT_TAG__", // python/thrift_types.py.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Python classes for Thrift types }} {{> common/auto_generated_py}} import folly.iobuf as _fbthrift_iobuf import {{program:base_library_package}}.types as _fbthrift_python_types import {{program:base_library_package}}.exceptions as _fbthrift_python_exceptions {{#program:include_namespaces}} {{#has_types?}} import {{included_module_path}}.thrift_types {{/has_types?}} {{/program:include_namespaces}} {{#program:adapter_modules}} import {{module_path}} {{/program:adapter_modules}} {{#program:structs}} class {{> structs/unadapted_name}}(metaclass={{! }}{{#struct:union?}}_fbthrift_python_types.UnionMeta{{/struct:union?}}{{! }}{{^struct:union?}}{{! }}{{#struct:exception?}}_fbthrift_python_exceptions.GeneratedErrorMeta{{/struct:exception?}}{{! }}{{^struct:exception?}}_fbthrift_python_types.StructMeta{{/struct:exception?}}{{! }}{{/struct:union?}}{{! }}): _fbthrift_SPEC = ( {{#struct:fields_ordered_by_id}} ( {{field:key}}, # id _fbthrift_python_types.{{field:tablebased_qualifier}}, # qualifier "{{field:py_name}}", # name {{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}{{/field:type}}, # typeinfo {{#field:user_default_value}}{{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{/field:type}}{{> types/constant_value }}{{/field:user_default_value}}{{! }}{{^field:user_default_value}}None{{/field:user_default_value}}, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/struct:fields_ordered_by_id}} ) @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{> structs/unadapted_name}}" @staticmethod def __get_thrift_uri__(): return {{#struct:thrift_uri}}"{{struct:thrift_uri}}"{{/struct:thrift_uri}}{{! }}{{^struct:thrift_uri}}None{{/struct:thrift_uri}} @staticmethod def __get_metadata__(): return _fbthrift_metadata__{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}() {{! makes reflection work in auto-migrated thrift-py3 }}{{#program:py3_auto_migrate?}} @staticmethod def __get_reflection__(): import importlib types_reflection = importlib.import_module("{{program:module_path}}.types_reflection") return types_reflection.get_reflection__{{struct:name}}() {{/program:py3_auto_migrate?}} {{#struct:exception?}} {{#struct:exception_message?}} def __str__(self): field = self.{{struct:exception_message}} if field is None: {{! optional field, stringify }} return str(field) return field {{/struct:exception_message?}} {{/struct:exception?}} {{#struct:legacy_api?}} def _to_python(self): return self def _to_py3(self): import importlib py3_types = importlib.import_module("{{program:module_path}}.types") import thrift.py3.converter return thrift.py3.converter.to_py3_struct(py3_types.{{> structs/unadapted_name}}, self) def _to_py_deprecated(self): import importlib import thrift.util.converter try: py_deprecated_types = importlib.import_module("{{program:py_deprecated_module_path}}.ttypes") return thrift.util.converter.to_py_struct(py_deprecated_types.{{> structs/unadapted_name}}, self) except ModuleNotFoundError: py_asyncio_types = importlib.import_module("{{program:py_asyncio_module_path}}.ttypes") return thrift.util.converter.to_py_struct(py_asyncio_types.{{> structs/unadapted_name}}, self) {{/struct:legacy_api?}} {{#struct:has_adapter?}} {{struct:name}} = {{adapter:type_hint}}{{#adapter:is_generic?}}[{{> structs/unadapted_name}}]{{/adapter:is_generic?}} {{/struct:has_adapter?}}{{! }}{{/program:structs}} # This unfortunately has to be down here to prevent circular imports import {{program:module_path}}.thrift_metadata {{#program:enums}} class {{enum:name}}(_fbthrift_python_types.{{! }}{{#enum:flags?}}Flag{{/enum:flags?}}{{! }}{{^enum:flags?}}Enum, int{{/enum:flags?}}): {{#enum:values}} {{enum_value:py_name}} = {{enum_value:value}} {{/enum:values}} @staticmethod def __get_thrift_name__() -> str: return "{{program:name}}.{{enum:name}}" @staticmethod def __get_thrift_uri__(): return {{#enum:thrift_uri}}"{{enum:thrift_uri}}"{{/enum:thrift_uri}}{{! }}{{^enum:thrift_uri}}None{{/enum:thrift_uri}} @staticmethod def __get_metadata__(): return {{program:module_path}}.thrift_metadata.gen_metadata_enum_{{enum:name}}() {{#enum:legacy_api?}} def _to_python(self): return self def _to_py3(self): import importlib py3_types = importlib.import_module("{{program:module_path}}.types") return py3_types.{{enum:name}}(self.value) def _to_py_deprecated(self): return self.value {{/enum:legacy_api?}} {{/program:enums}} _fbthrift_all_enums = [ {{#program:enums}} {{enum:name}}, {{/program:enums}} ] {{#program:structs}} def _fbthrift_metadata__{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}(): return {{program:module_path}}.thrift_metadata.gen_metadata_{{#struct:exception?}}exception{{/struct:exception?}}{{^struct:exception?}}struct{{/struct:exception?}}_{{> structs/unadapted_name}}() {{/program:structs}} _fbthrift_all_structs = [ {{#program:structs}} {{> structs/unadapted_name}}, {{/program:structs}} ] {{#program:structs?}} _fbthrift_python_types.fill_specs(*_fbthrift_all_structs) {{/program:structs?}} {{#program:constants?}} {{#program:constants}} {{#constant:has_adapter?}}_fbthrift_unadapted_{{/constant:has_adapter?}}{{constant:name}} = {{#constant:value}}{{> types/constant_value}}{{/constant:value}} {{#constant:has_adapter?}} {{constant:name}} = {{constant:adapter_name}}.from_thrift( _fbthrift_unadapted_{{constant:name}}, transitive_annotation={{#constant:is_adapter_transitive?}}{{! }}{{#constant:transitive_adapter_annotation}}{{> types/constant_value }}{{/constant:transitive_adapter_annotation}}{{! }}{{/constant:is_adapter_transitive?}}{{! }}{{^constant:is_adapter_transitive?}}{{! }}None }}{{/constant:is_adapter_transitive?}}, constant_uri={{#constant:uri}}"{{constant:uri}}"{{/constant:uri}}{{! }}{{^constant:uri}}None{{/constant:uri}}, ) {{/constant:has_adapter?}} {{/program:constants}} {{/program:constants?}} {{#program:typedefs?}} {{#program:typedefs}} {{typedef:name}} = {{#typedef:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#typedef:type}}{{> types/python_type}}{{/typedef:type}}]{{/adapter:is_generic?}}{{! }}{{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}{{#typedef:type}}{{> types/python_type}}{{/typedef:type}}{{! }}{{/typedef:has_adapter?}} {{/program:typedefs}} {{/program:typedefs?}} {{#program:services?}} {{#program:services}} {{> types/service_arg_types }} {{#service:interactions}} {{> types/service_arg_types }} {{/service:interactions}} {{/program:services}} _fbthrift_python_types.fill_specs( {{#program:services}} {{> types/service_arg_type_list}} {{#service:interactions}} {{> types/service_arg_type_list}} {{/service:interactions}} {{/program:services}} ) {{/program:services?}} )__FBTHRIFT_TAG__", // python/thrift_types.pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Python typestubs for Thrift types }} {{> common/auto_generated_py}} import typing as _typing {{#program:unions?}} import enum {{/program:unions?}} import folly.iobuf as _fbthrift_iobuf import {{program:base_library_package}}.types as _fbthrift_python_types import {{program:base_library_package}}.exceptions as _fbthrift_python_exceptions {{#program:include_namespaces}} {{#has_types?}} import {{included_module_path}}.thrift_types {{/has_types?}} {{/program:include_namespaces}} {{#program:adapter_type_hint_modules}} import {{module_path}} {{/program:adapter_type_hint_modules}} {{#program:enums}} class _fbthrift_compatible_with_{{enum:name}}: pass class {{enum:name}}(_fbthrift_python_types.{{! }}{{#enum:flags?}}Flag{{/enum:flags?}}{{! }}{{^enum:flags?}}Enum, int{{/enum:flags?}}{{! }}, _fbthrift_compatible_with_{{enum:name}}): {{#enum:values}} {{enum_value:py_name}}: {{enum:name}} = ... {{/enum:values}} {{#enum:legacy_api?}} def _to_python(self) -> {{enum:name}}: ... def _to_py3(self) -> "{{program:module_path}}.types.{{enum:name}}": ... # type: ignore def _to_py_deprecated(self) -> int: ... {{/enum:legacy_api?}} {{/program:enums}} {{#program:structs}} class _fbthrift_compatible_with_{{> structs/unadapted_name}}: pass class {{> structs/unadapted_name}}({{! }}{{#struct:union?}}_fbthrift_python_types.Union{{/struct:union?}}{{! }}{{^struct:union?}}{{! }}{{#struct:exception?}}_fbthrift_python_exceptions.GeneratedError{{/struct:exception?}}{{! }}{{^struct:exception?}}_fbthrift_python_types.Struct{{/struct:exception?}}{{! }}{{/struct:union?}}{{! }}, _fbthrift_compatible_with_{{> structs/unadapted_name}}{{! }}): {{#struct:fields_ordered_by_id}} {{field:py_name}}: _typing.Final[{{#field:optional?}}_typing.Optional[{{/field:optional?}}{{! }}{{> fields/adapted_type}}{{! }}{{#field:optional?}}]{{/field:optional?}}] = ... {{/struct:fields_ordered_by_id}} def __init__( self,{{#struct:fields?}} *{{/struct:fields?}}{{#struct:fields_ordered_by_id}}, {{field:py_name}}: _typing.Optional[{{> fields/compatible_adapted_type}}]=...{{/struct:fields_ordered_by_id}} ) -> None: ... {{#struct:plain?}} def __call__( self,{{#struct:fields?}} *{{/struct:fields?}}{{#struct:fields_ordered_by_id}}, {{field:py_name}}: _typing.Optional[{{> fields/compatible_adapted_type}}]=...{{/struct:fields_ordered_by_id}} ) -> _typing.Self: ... {{/struct:plain?}} {{#struct:union?}} class Type(enum.Enum): EMPTY: {{> structs/unadapted_name}}.Type = ... {{#struct:fields_ordered_by_id}} {{field:py_name}}: {{> structs/unadapted_name}}.Type = ... {{/struct:fields_ordered_by_id}} @classmethod def fromValue(cls, value: {{ > types/field_value_pep484_union_type}}) -> {{> structs/unadapted_name}}: ... value: _typing.Final[{{ > types/field_value_pep484_union_type}}] type: Type def get_type(self) -> Type:... {{/struct:union?}} {{^struct:union?}} def __iter__(self) -> _typing.Iterator[_typing.Tuple[str, _typing.Union[{{^struct:fields_ordered_by_id}}None{{/struct:fields_ordered_by_id}}{{! }}{{#struct:fields_ordered_by_id}}{{^first?}}, {{/first?}}{{> fields/adapted_type}}{{! }}{{/struct:fields_ordered_by_id}}]]]: ... {{/struct:union?}} {{#struct:legacy_api?}} def _to_python(self) -> _typing.Self: ... def _to_py3(self) -> "{{program:module_path}}.types.{{> structs/unadapted_name}}": ... # type: ignore def _to_py_deprecated(self) -> "{{program:py_deprecated_module_path}}.ttypes.{{> structs/unadapted_name}}": ... # type: ignore {{/struct:legacy_api?}} {{#struct:has_adapter?}} {{struct:name}} = {{adapter:type_hint}}{{#adapter:is_generic?}}[{{> structs/unadapted_name}}]{{/adapter:is_generic?}} {{/struct:has_adapter?}}{{! }}{{/program:structs}} {{#program:constants?}} {{#program:constants}} {{#constant:has_adapter?}}_fbthrift_unadapted_{{/constant:has_adapter?}}{{constant:name}}: {{#constant:type}}{{! }}{{> types/typedef_const_pep484_type}}{{! }}{{/constant:type}} = ... {{#constant:has_adapter?}} {{constant:name}}: {{constant:adapter_type_hint}} = ... {{/constant:has_adapter?}} {{/program:constants}} {{/program:constants?}} {{#program:typedefs?}} {{#program:typedefs}} {{typedef:name}} = {{#typedef:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{#typedef:type}}{{> types/typedef_const_pep484_type}}{{/typedef:type}}]{{/adapter:is_generic?}}{{! }}{{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}{{#typedef:type}}{{> types/typedef_const_pep484_type}}{{/typedef:type}}{{! }}{{/typedef:has_adapter?}} {{/program:typedefs}} {{/program:typedefs?}} {{#program:services?}} {{#program:services}} {{> types/service_arg_types_pyi}} {{#service:interactions}} {{> types/service_arg_types_pyi}} {{/service:interactions}} {{/program:services}} {{/program:services?}} )__FBTHRIFT_TAG__", // python/types/compatible_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-python specific container types. }}{{#type:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{> types/unadapted_pep484_type}}]{{/adapter:is_generic?}}{{! }}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}{{> types/compatible_unadapted_pep484_type}}{{! }}{{/type:has_adapter?}} )__FBTHRIFT_TAG__", // python/types/compatible_unadapted_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-python specific container types. }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{#type:iobuf?}}_fbthrift_iobuf.IOBuf{{/type:iobuf?}}{{^type:iobuf?}}bytes{{/type:iobuf?}}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}_fbthrift_compatible_with_{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:list?}}_typing.Sequence[{{! }}{{#type:list_elem_type}}{{> types/compatible_pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}_typing.AbstractSet[{{! }}{{#type:set_elem_type}}{{> types/compatible_pep484_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}_typing.Mapping[{{! }}{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> types/compatible_pep484_type}}{{/type:value_type}}{{! }}]{{/type:map?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}_fbthrift_compatible_with_{{enum:name}}{{! }}{{/type:enum}} )__FBTHRIFT_TAG__", // python/types/constant_value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Definitions for constant values. These are included from the struct.pyx file and define Python objects that can be imported from the end-user's Python file. }}{{#value:bool?}}{{! }}{{#value:nonzero?}}True{{/value:nonzero?}}{{! }}{{^value:nonzero?}}False{{/value:nonzero?}}{{! }}{{/value:bool?}}{{! }}{{#value:integer?}}{{! }}{{#value:value_for_bool?}}{{! }}{{#value:nonzero?}}True{{/value:nonzero?}}{{! }}{{^value:nonzero?}}False{{/value:nonzero?}}{{! }}{{/value:value_for_bool?}}{{! }}{{^value:value_for_bool?}}{{! }}{{value:integer_value}}{{#value:value_for_floating_point?}}.0{{/value:value_for_floating_point?}}{{! }}{{/value:value_for_bool?}}{{! }}{{/value:integer?}}{{! }}{{#value:double?}}float({{value:double_value}}){{/value:double?}}{{! }}{{#value:const_struct?}}{{! }}{{#value:const_struct_type}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{#type:struct}}{{> structs/unadapted_name}}{{/type:struct}}{{! }}{{/value:const_struct_type}}{{! }}({{#value:const_struct}}{{! }}{{! There might a bug somewhere causing that: For some enum field of a const struct, `value:enum?` yields false. Below is a temporary workaround using `type:enum?` which correctly yields true. Ideally we should fix the `value:enum?` behavior and get rid of this hack. }}{{! }}{{constant:name}}={{#constant:type}}{{#constant:value}}{{! }}{{#type:enum?}}{{! }}{{#value:enum?}}{{ >types/constant_value }}{{/value:enum?}}{{! }}{{^value:enum?}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{type:name}}{{! }}({{#constant:value}}{{value:integer_value}}{{/constant:value}}){{! }}{{/value:enum?}}{{! }}{{/type:enum?}}{{! }}{{^type:enum?}}{{ >types/constant_value }}{{/type:enum?}}{{! }}{{/constant:value}}{{/constant:type}}{{^last?}}, {{/last?}}{{! }}{{/value:const_struct}}){{! }}{{/value:const_struct?}}{{! }}{{^value:const_struct?}}{{! }}{{#value:string?}}{{! }}{{#value:py3_binary?}}b{{/value:py3_binary?}}"{{value:string_value}}"{{! }}{{/value:string?}}{{! }}{{#value:map?}}_fbthrift_python_types.Map({{! }}{{#value:map_key_type}}{{ >types/typeinfo }}{{/value:map_key_type}}, {{! }}{{#value:map_val_type}}{{ >types/typeinfo }}{{/value:map_val_type}}, { {{! purposeful open brace }}{{#value:map_elements}}{{! }}{{#element:key}}{{ > types/constant_value }}{{/element:key}}: {{! }}{{#element:value}}{{ > types/constant_value}}{{/element:value}}{{^last?}}, {{/last?}}{{! }}{{/value:map_elements}}{{! purposeful close brace [next line] }}}){{/value:map?}}{{! }}{{#value:list?}}_fbthrift_python_types.{{! }}{{#value:value_for_set?}}Set{{/value:value_for_set?}}{{! }}{{^value:value_for_set?}}List{{/value:value_for_set?}}({{! }}{{#value:list_elem_type}}{{ >types/typeinfo }}{{/value:list_elem_type}}, {{! }}({{#value:list_elements}}{{ >types/constant_value }}, {{/value:list_elements}}){{! }}){{/value:list?}}{{! }}{{/value:const_struct?}}{{! }}{{#value:enum?}}{{! }}{{^value:enum_value?}}_fbthrift_python_types.BadEnum({{/value:enum_value?}}{{! }}{{#value:const_enum_type}}{{#type:need_module_path?}}{{type:module_path}}.{{! }}{{/type:need_module_path?}}{{/value:const_enum_type}}{{! }}{{value:enum_name}}{{#value:enum_value?}}.{{value:py3_enum_value_name}}{{/value:enum_value?}}{{! }}{{^value:enum_value?}}, {{value:integer_value}}){{/value:enum_value?}}{{! }}{{/value:enum?}} )__FBTHRIFT_TAG__", // python/types/field_value_pep484_union_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Typing for a union field }}_typing.Union[None{{#struct:fields_ordered_by_id}}{{! }}, {{#field:type}}{{> types/pep484_type}}{{/field:type}}{{! }}{{/struct:fields_ordered_by_id}}] )__FBTHRIFT_TAG__", // python/types/function_args_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is the struct that wraps function args }}{{^program:is_types_file?}}{{program:module_path}}.thrift_types.{{/program:is_types_file?}}_fbthrift_{{service:name}}_{{function:name}}_args )__FBTHRIFT_TAG__", // python/types/function_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is the struct that wraps function return }}{{#function:oneway?}}None{{/function:oneway?}}{{!! }}{{^function:oneway?}}{{! }}{{program:module_path}}.thrift_types._fbthrift_{{service:name}}_{{function:name}}_result{{! }}{{/function:oneway?}} )__FBTHRIFT_TAG__", // python/types/function_second_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is the struct that wraps function secondary return type (ie. stream, sink) }}{{#function:stream?}}{{! }}{{program:module_path}}.thrift_types._fbthrift_{{service:name}}_{{function:name}}_result_stream{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // python/types/pep484_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{> types/pep484_type}}{{! }}{{#function:stream?}}{{#function:stream_has_first_response?}}{{#function:stream_first_response_type}}{{! }}{{> types/pep484_type}}, {{/function:stream_first_response_type}}{{/function:stream_has_first_response?}}{{! }}_typing.AsyncGenerator[{{#function:stream_elem_type}}{{> types/pep484_type}}{{/function:stream_elem_type}}, None]{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // python/types/pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-python specific container types. }}{{#type:has_adapter?}}{{! }}{{adapter:type_hint}}{{#adapter:is_generic?}}[{{> types/unadapted_pep484_type}}]{{/adapter:is_generic?}}{{! }}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}{{> types/unadapted_pep484_type}}{{! }}{{/type:has_adapter?}} )__FBTHRIFT_TAG__", // python/types/python_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for python types, used for typedefs aliases. Structs and enums will be namespaced appropriately if they are either defined in a different thrift file, or defined in the same thrift file. }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:integer?}}int{{/type:integer?}}{{! }}{{#type:floating_point?}}float{{/type:floating_point?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{#type:iobuf?}}_fbthrift_iobuf.IOBuf{{/type:iobuf?}}{{^type:iobuf?}}bytes{{/type:iobuf?}}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:list?}}{{! }}_fbthrift_python_types.ListTypeFactory({{! }}{{#type:list_elem_type}}{{ >types/typeinfo }}{{/type:list_elem_type}}{{! }}){{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}_fbthrift_python_types.SetTypeFactory({{! }}{{#type:set_elem_type}}{{ >types/typeinfo }}{{/type:set_elem_type}}{{! }}){{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}_fbthrift_python_types.MapTypeFactory({{! }}{{#type:key_type}}{{ >types/typeinfo }}{{/type:key_type}}, {{! }}{{#type:value_type}}{{ >types/typeinfo }}{{/type:value_type}}){{! }}{{/type:map?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{enum:name}}{{! }}{{/type:enum}}{{! }}{{#type:void?}}None{{/type:void?}} )__FBTHRIFT_TAG__", // python/types/service_arg_type_list.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! A list of the argument and result types for functions on thrift services (and interactions) for the purposes of calling fill_specs on them }}{{#service:supported_functions}} {{> types/function_args_type}}, {{^function:oneway?}} _fbthrift_{{service:name}}_{{function:name}}_result, {{/function:oneway?}} {{#function:stream?}} _fbthrift_{{service:name}}_{{function:name}}_result_stream, {{/function:stream?}} {{/service:supported_functions}} )__FBTHRIFT_TAG__", // python/types/service_arg_types.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The argument and result types for functions on thrift services (and interactions) }}{{#service:supported_functions}} class {{> types/function_args_type}}(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( {{#function:args}} ( {{field:key}}, # id _fbthrift_python_types.FieldQualifier.Unqualified, # qualifier "{{field:py_name}}", # name {{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}{{/field:type}}, # typeinfo None, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/function:args}} ) {{^function:oneway?}} class _fbthrift_{{service:name}}_{{function:name}}_result(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( {{#function:regular_response_type}} {{^type:void?}} ( 0, # id _fbthrift_python_types.FieldQualifier.Optional, # qualifier "success", # name {{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}, # typeinfo None, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/type:void?}} {{/function:regular_response_type}} {{#function:exceptions}} ( {{field:key}}, # id _fbthrift_python_types.FieldQualifier.Optional, # qualifier "{{field:py_name}}", # name {{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}{{/field:type}}, # typeinfo None, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/function:exceptions}} ) {{/function:oneway?}} {{#function:stream?}} class _fbthrift_{{service:name}}_{{function:name}}_result_stream(metaclass=_fbthrift_python_types.StructMeta): _fbthrift_SPEC = ( {{#function:stream_elem_type}} ( 0, # id _fbthrift_python_types.FieldQualifier.Optional, # qualifier "success", # name {{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}, # typeinfo None, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/function:stream_elem_type}} {{#function:stream_exceptions}} ( {{field:key}}, # id _fbthrift_python_types.FieldQualifier.Optional, # qualifier "{{field:py_name}}", # name {{#field:type}}{{^type:base?}}lambda: {{/type:base?}}{{ >types/typeinfo }}{{/field:type}}, # typeinfo None, # default value {{> fields/adapter_info }}, # adapter info {{> fields/is_primitive }}, # field type is primitive ), {{/function:stream_exceptions}} ) {{/function:stream?}} {{/service:supported_functions}} )__FBTHRIFT_TAG__", // python/types/service_arg_types_pyi.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! The argument and result types for functions on thrift services (and interactions) for typing stub }}{{#service:supported_functions}} class {{> types/function_args_type}}(_fbthrift_python_types.Struct): {{#function:args}} {{field:py_name}}: _typing.Final[{{#field:type}}{{> types/pep484_type}}{{/field:type}}] = ... {{/function:args}} def __init__( self,{{#function:args?}} *{{/function:args?}}{{#function:args}}, {{field:py_name}}: _typing.Optional[{{#field:type}}{{> types/pep484_type}}{{/field:type}}]=...{{/function:args}} ) -> None: ... def __iter__(self) -> _typing.Iterator[_typing.Tuple[ str, _typing.Union[None{{#function:args}}, {{! }}{{#field:type}}{{> types/pep484_type}}{{/field:type}}{{! }}{{/function:args}}]]]: ... {{^function:oneway?}} class _fbthrift_{{service:name}}_{{function:name}}_result(_fbthrift_python_types.Struct): {{#function:regular_response_type}} success: _typing.Final[{{ >types/pep484_type }}] {{/function:regular_response_type}} {{#function:exceptions}} {{field:py_name}}: _typing.Final[{{#field:type}}{{> types/pep484_type}}{{/field:type}}] {{/function:exceptions}} def __init__( self, *, success: _typing.Optional[{{#function:regular_response_type}}{{ >types/pep484_type }}{{/function:regular_response_type}}] = ...{{! }}{{#function:exceptions}}{{! }}, {{field:py_name}}: _typing.Optional[{{#field:type}}{{> types/pep484_type}}{{/field:type}}]=...{{! }}{{/function:exceptions}} ) -> None: ... def __iter__(self) -> _typing.Iterator[_typing.Tuple[ str, _typing.Union[ {{#function:regular_response_type}}{{ >types/pep484_type }}{{/function:regular_response_type}}, {{#function:exceptions}} {{#field:type}}{{> types/pep484_type}}{{/field:type}}, {{/function:exceptions}} ]]]: ... {{/function:oneway?}} {{#function:stream?}} class _fbthrift_{{service:name}}_{{function:name}}_result_stream(_fbthrift_python_types._fbthrift_ResponseStreamResult[{{#function:stream_elem_type}}{{ >types/pep484_type }}{{/function:stream_elem_type}}]): {{#function:stream_exceptions}} {{field:py_name}}: _typing.Final[{{#field:type}}{{> types/pep484_type}}{{/field:type}}] {{/function:stream_exceptions}} def __init__( self, *, success: _typing.Optional[{{#function:stream_elem_type}}{{ >types/pep484_type }}{{/function:stream_elem_type}}] = ...{{! }}{{#function:stream_exceptions}}{{! }}, {{field:py_name}}: _typing.Optional[{{#field:type}}{{> types/pep484_type}}{{/field:type}}]=...{{! }}{{/function:stream_exceptions}} ) -> None: ... def __iter__(self) -> _typing.Iterator[_typing.Tuple[ str, _typing.Union[ {{#function:stream_elem_type}}{{ >types/pep484_type }}{{/function:stream_elem_type}}, {{#function:stream_exceptions}} {{#field:type}}{{> types/pep484_type}}{{/field:type}}, {{/function:stream_exceptions}} ]]]: ... {{/function:stream?}} {{/service:supported_functions}} )__FBTHRIFT_TAG__", // python/types/typedef_const_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for typedef/constants PEP484 type }}{{#type:container?}}{{! }}{{#type:list?}}_typing.List[{{! }}{{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}_typing.Set[{{! }}{{#type:set_elem_type}}{{> types/pep484_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}_typing.Dict[{{! }}{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> types/pep484_type}}{{/type:value_type}}{{! }}]{{/type:map?}}{{! }}{{/type:container?}}{{! }}{{^type:container?}}{{> types/pep484_type}}{{/type:container?}} )__FBTHRIFT_TAG__", // python/types/typeinfo.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is used to declare a cython type that is referring to a Python value (ie, something that will be returned to external Python code or just used in Cython). Structs and enums will be namespaced appropriately if they are either defined in a different thrift file, or defined in the same thrift file but this is in the client or server source rather than the type definition source. }}{{#type:has_adapter?}}_fbthrift_python_types.AdaptedTypeInfo({{/type:has_adapter?}}{{! }}{{#type:bool?}}_fbthrift_python_types.typeinfo_bool{{/type:bool?}}{{! }}{{#type:byte?}}_fbthrift_python_types.typeinfo_byte{{/type:byte?}}{{! }}{{#type:i16?}}_fbthrift_python_types.typeinfo_i16{{/type:i16?}}{{! }}{{#type:i32?}}_fbthrift_python_types.typeinfo_i32{{/type:i32?}}{{! }}{{#type:i64?}}_fbthrift_python_types.typeinfo_i64{{/type:i64?}}{{! }}{{#type:double?}}_fbthrift_python_types.typeinfo_double{{/type:double?}}{{! }}{{#type:float?}}_fbthrift_python_types.typeinfo_float{{/type:float?}}{{! }}{{#type:string?}}_fbthrift_python_types.typeinfo_string{{/type:string?}}{{! }}{{#type:binary?}}{{#type:iobuf?}}_fbthrift_python_types.typeinfo_iobuf{{/type:iobuf?}}{{^type:iobuf?}}_fbthrift_python_types.typeinfo_binary{{/type:iobuf?}}{{/type:binary?}}{{! }}{{#type:struct}}_fbthrift_python_types.StructTypeInfo({{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{> structs/unadapted_name}}){{! }}{{/type:struct}}{{! }}{{#type:list?}}_fbthrift_python_types.ListTypeInfo({{#type:list_elem_type}}{{ >types/typeinfo }}{{/type:list_elem_type}}){{/type:list?}}{{! }}{{#type:set?}}_fbthrift_python_types.SetTypeInfo({{#type:set_elem_type}}{{ >types/typeinfo }}{{/type:set_elem_type}}){{/type:set?}}{{! }}{{#type:map?}}_fbthrift_python_types.MapTypeInfo({{! }}{{#type:key_type}}{{ >types/typeinfo }}{{/type:key_type}}, {{! }}{{#type:value_type}}{{ >types/typeinfo }}{{/type:value_type}}{{! }}){{/type:map?}}{{! }}{{#type:enum}}_fbthrift_python_types.EnumTypeInfo({{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{enum:name}}){{/type:enum}}{{! }}{{#type:has_adapter?}}{{! }}, {{adapter:name}}, lambda: {{! }}{{#adapter:is_transitive?}}{{! }}{{#adapter:transitive_annotation}}{{> types/constant_value }}{{/adapter:transitive_annotation}}{{! }}{{/adapter:is_transitive?}}{{! }}{{^adapter:is_transitive?}}{{! }}None{{! }}{{/adapter:is_transitive?}}{{! }}){{/type:has_adapter?}} )__FBTHRIFT_TAG__", // python/types/unadapted_pep484_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! This is for pep 484 typing This is useful for typing call paterns since it allows python container types OR thrift-python specific container types. }}{{#type:bool?}}bool{{/type:bool?}}{{! }}{{#type:byte?}}int{{/type:byte?}}{{! }}{{#type:i16?}}int{{/type:i16?}}{{! }}{{#type:i32?}}int{{/type:i32?}}{{! }}{{#type:i64?}}int{{/type:i64?}}{{! }}{{#type:double?}}float{{/type:double?}}{{! }}{{#type:float?}}float{{/type:float?}}{{! }}{{#type:string?}}str{{/type:string?}}{{! }}{{#type:binary?}}{{#type:iobuf?}}_fbthrift_iobuf.IOBuf{{/type:iobuf?}}{{^type:iobuf?}}bytes{{/type:iobuf?}}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{struct:name}}{{! }}{{/type:struct}}{{! }}{{#type:list?}}_typing.Sequence[{{! }}{{#type:list_elem_type}}{{> types/pep484_type}}{{/type:list_elem_type}}{{! }}]{{/type:list?}}{{! }}{{#type:set?}}_typing.AbstractSet[{{! }}{{#type:set_elem_type}}{{> types/pep484_type}}{{/type:set_elem_type}}{{! }}]{{/type:set?}}{{! }}{{#type:map?}}_typing.Mapping[{{! }}{{#type:key_type}}{{> types/pep484_type}}{{/type:key_type}}, {{! }}{{#type:value_type}}{{> types/pep484_type}}{{/type:value_type}}{{! }}]{{/type:map?}}{{! }}{{#type:void?}}None{{/type:void?}}{{! }}{{#type:enum}}{{! }}{{#type:need_module_path?}}{{type:module_path}}.{{/type:need_module_path?}}{{! }}{{enum:name}}{{! }}{{/type:enum}} )__FBTHRIFT_TAG__", // python_capi/common/auto_generated_cpp.mustache R"__FBTHRIFT_TAG__( /** * Autogenerated by Thrift * * DO NOT EDIT * @generated * */ {{! terminate with newline }} )__FBTHRIFT_TAG__", // python_capi/common/auto_generated_cython.mustache R"__FBTHRIFT_TAG__( # # Autogenerated by Thrift # # DO NOT EDIT # @generated # {{! terminate with newline }} )__FBTHRIFT_TAG__", // python_capi/common/tuple_position.mustache R"__FBTHRIFT_TAG__( {{#struct:marshal_capi?}} {{^struct:union?}} {{#struct:fields?}} static constexpr std::int16_t _fbthrift__{{struct:name}}__tuple_pos[{{struct:fields_size}}] = { {{#struct:tuple_positions}}{{tuple:comma}}{{tuple:index}}{{/struct:tuple_positions}} }; {{/struct:fields?}} {{/struct:union?}} {{/struct:marshal_capi?}} )__FBTHRIFT_TAG__", // python_capi/thrift_types_capi.cpp.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Cpp2 <-> Python converters for Thrift types }} {{> common/auto_generated_cpp}} #include #include #include #include <{{program:includePrefix}}gen-python-capi/{{program:name}}/thrift_types_api.h> #include <{{program:includePrefix}}gen-python-capi/{{program:name}}/thrift_types_capi.h> {{#program:capi_includes}} #include "{{header_include}}" {{/program:capi_includes}} namespace apache { namespace thrift { namespace python { namespace capi { namespace { {{#program:generate_capi?}} bool ensure_module_imported() { static ::folly::python::import_cache_nocapture import(( ::import_{{program:capi_module_prefix}}__thrift_types_capi)); return import(); } {{#program:structs}} {{> common/tuple_position }} {{/program:structs}} {{/program:generate_capi?}} } // namespace {{#program:structs}} {{#struct:marshal_capi?}} ExtractorResult<{{struct:cpp_name}}> Extractor<{{struct:cpp_name}}>::operator()(PyObject* obj) { int tCheckResult = typeCheck(obj); if (tCheckResult != 1) { if (tCheckResult == 0) { PyErr_SetString(PyExc_TypeError, "Not a {{struct:name}}"); } return extractorError<{{struct:cpp_name}}>( "Marshal error: {{struct:name}}"); } {{#struct:fields?}} {{! getThriftData increments tuple struct refcnt}} StrongRef fbThriftData(get{{#struct:exception?}}Exception{{/struct:exception?}}ThriftData(obj)); return Extractor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>>{}(*fbThriftData); {{/struct:fields?}} {{^struct:fields?}} return {{struct:cpp_name}}{}; {{/struct:fields?}} } {{/struct:marshal_capi?}} {{^struct:marshal_capi?}} ExtractorResult<{{struct:cpp_name}}> Extractor<{{struct:cpp_name}}>::operator()(PyObject* obj) { if (!ensure_module_imported()) { DCHECK(PyErr_Occurred() != nullptr); return extractorError<{{struct:cpp_name}}>( "Module {{program:module_path}} import error"); } std::unique_ptr val( extract__{{program:capi_module_prefix}}__{{struct:name}}(obj)); if (!val) { CHECK(PyErr_Occurred()); return extractorError<{{struct:cpp_name}}>( "Thrift serialize error: {{struct:name}}"); } {{#struct:cpp_adapter?}} return detail::deserialize_iobuf_to_adapted< {{struct:cpp_name}}, {{cpp_adapter:name}} >(std::move(val)); {{/struct:cpp_adapter?}} {{^struct:cpp_adapter?}} return detail::deserialize_iobuf<{{struct:cpp_name}}>(std::move(val)); {{/struct:cpp_adapter?}} } {{/struct:marshal_capi?}} {{#struct:marshal_capi?}} ExtractorResult<{{struct:cpp_name}}> Extractor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>>::operator()(PyObject* fbThriftData) { {{struct:cpp_name}} cpp; {{#struct:fields?}} std::optional error; {{^struct:union?}} {{#struct:fields}} Extractor<{{field:marshal_type}}>{}.extractInto( cpp.{{field:cpp_name}}_ref(), PyTuple_GET_ITEM(fbThriftData, _fbthrift__{{struct:name}}__tuple_pos[{{field:index}}]), error); {{/struct:fields}} {{/struct:union?}} {{#struct:union?}} auto type_tag = Extractor{}(PyTuple_GET_ITEM(fbThriftData, 0)); if (type_tag.hasError()) { return folly::makeUnexpected(type_tag.error()); } switch (*type_tag) { case 0: break; // union is unset {{#struct:fields}} case {{field:key}}: Extractor<{{field:marshal_type}}>{}.extractInto( cpp.{{field:cpp_name}}_ref(), PyTuple_GET_ITEM(fbThriftData, 1), error); break; {{/struct:fields}} } {{/struct:union?}} if (error) { return folly::makeUnexpected(*error); } {{/struct:fields?}} {{^struct:fields?}} (void)fbThriftData; {{/struct:fields?}} return cpp; } {{/struct:marshal_capi?}} {{^struct:marshal_capi?}} ExtractorResult<{{struct:cpp_name}}> Extractor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>>::operator()(PyObject* fbthrift_data) { if (!ensure_module_imported()) { DCHECK(PyErr_Occurred() != nullptr); return extractorError<{{struct:cpp_name}}>( "Module {{program:module_path}} import error"); } auto obj = StrongRef(init__{{program:capi_module_prefix}}__{{struct:name}}(fbthrift_data)); if (!obj) { return extractorError<{{struct:cpp_name}}>( "Init from fbthrift error: {{struct:name}}"); } return Extractor<{{struct:cpp_name}}>{}(*obj); } {{/struct:marshal_capi?}} int Extractor<{{struct:cpp_name}}>::typeCheck(PyObject* obj) { if (!ensure_module_imported()) { ::folly::python::handlePythonError( "Module {{program:module_path}} import error"); } int result = can_extract__{{program:capi_module_prefix}}__{{struct:name}}(obj); if (result < 0) { ::folly::python::handlePythonError( "Unexpected type check error: {{struct:name}}"); } return result; } PyObject* Constructor<{{struct:cpp_name}}>::operator()( const {{struct:cpp_name}}& val) { if (!ensure_module_imported()) { DCHECK(PyErr_Occurred() != nullptr); return nullptr; } {{#struct:marshal_capi?}} Constructor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>> ctor; StrongRef fbthrift_data(ctor(val)); if (!fbthrift_data) { return nullptr; } return init__{{program:capi_module_prefix}}__{{struct:name}}(*fbthrift_data); {{/struct:marshal_capi?}} {{^struct:marshal_capi?}} auto ptr = construct__{{program:capi_module_prefix}}__{{struct:name}}( {{#struct:cpp_adapter?}} detail::serialize_adapted_to_iobuf<{{cpp_adapter:name}}>(val)); {{/struct:cpp_adapter?}} {{^struct:cpp_adapter?}} detail::serialize_to_iobuf(val)); {{/struct:cpp_adapter?}} if (!ptr) { CHECK(PyErr_Occurred()); } return ptr; {{/struct:marshal_capi?}} } {{#struct:marshal_capi?}} PyObject* Constructor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>>::operator()( [[maybe_unused]] const {{struct:cpp_name}}& val) { {{^struct:union?}} StrongRef fbthrift_data(createStructTuple({{struct:fields_size}})); {{#struct:fields}} StrongRef _fbthrift__{{field:name}}( Constructor<{{field:marshal_type}}>{} .constructFrom(val.{{field:cpp_name}}_ref())); {{#field:optional?}} if (_fbthrift__{{field:name}}.isNone()) { Py_INCREF(Py_None); PyTuple_SET_ITEM( *fbthrift_data, _fbthrift__{{struct:name}}__tuple_pos[{{field:index}}], Py_None); } else {{/field:optional?}} if (!_fbthrift__{{field:name}} || setStructField( *fbthrift_data, _fbthrift__{{struct:name}}__tuple_pos[{{field:index}}], *_fbthrift__{{field:name}}) == -1) { {{! struct and previous fields auto-decref'd by StrongRef}} return nullptr; } {{/struct:fields}} return std::move(fbthrift_data).release(); {{/struct:union?}} {{#struct:union?}} int64_t type_key = static_cast(val.getType()); StrongRef py_val; switch (type_key) { case 0: Py_INCREF(Py_None); py_val = StrongRef(Py_None); break; {{#struct:fields}} case {{field:key}}: py_val = StrongRef( Constructor<{{field:marshal_type}}>{} .constructFrom(val.{{field:cpp_name}}_ref())); break; {{/struct:fields}} } if (!py_val) { return nullptr; } return unionTupleFromValue(type_key, *py_val); {{/struct:union?}} } {{/struct:marshal_capi?}} {{^struct:marshal_capi?}} PyObject* Constructor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>>::operator()( const {{struct:cpp_name}}& val) { auto obj = StrongRef(Constructor<{{struct:cpp_name}}>{}(val)); if (!obj) { return nullptr; } return get{{#struct:exception?}}Exception{{/struct:exception?}}ThriftData(*obj); } {{/struct:marshal_capi?}} {{/program:structs}} {{#program:enums}} ExtractorResult<{{program:cpp_namespaces}}::{{enum:cpp_name}}> Extractor<{{program:cpp_namespaces}}::{{enum:cpp_name}}>::operator()(PyObject* obj) { {{! thrift-python enums have int parent class}} long val = PyLong_AsLong(obj); if (val == -1 && PyErr_Occurred()) { return extractorError<{{program:cpp_namespaces}}::{{enum:cpp_name}}>( "Error getting python int value: {{enum:name}}"); } return static_cast<{{program:cpp_namespaces}}::{{enum:cpp_name}}>(val); } int Extractor<{{program:cpp_namespaces}}::{{enum:cpp_name}}>::typeCheck(PyObject* obj) { if (!ensure_module_imported()) { ::folly::python::handlePythonError( "Module {{program:module_path}} import error"); } int result = can_extract__{{program:capi_module_prefix}}__{{enum:name}}(obj); if (result < 0) { ::folly::python::handlePythonError( "Unexpected type check error: {{enum:name}}"); } return result; } PyObject* Constructor<{{program:cpp_namespaces}}::{{enum:cpp_name}}>::operator()( {{program:cpp_namespaces}}::{{enum:cpp_name}} val) { if (!ensure_module_imported()) { DCHECK(PyErr_Occurred() != nullptr); return nullptr; } auto ptr = construct__{{program:capi_module_prefix}}__{{enum:name}}( static_cast(val)); if (!ptr) { CHECK(PyErr_Occurred()); } return ptr; } {{/program:enums}} } // namespace capi } // namespace python } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // python_capi/thrift_types_capi.h.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Cpp2 <-> Python converters for Thrift types }} {{> common/auto_generated_cpp}} #pragma once #include #include #include <{{program:includePrefix}}gen-cpp2/{{program:name}}_types.h> namespace apache { namespace thrift { namespace python { namespace capi { {{#program:structs}} template <> struct Extractor<{{struct:cpp_name}}> : public BaseExtractor<{{struct:cpp_name}}> { ExtractorResult<{{struct:cpp_name}}> operator()(PyObject* obj); int typeCheck(PyObject* obj); }; template <> struct Extractor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>> : public BaseExtractor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>> { ExtractorResult<{{struct:cpp_name}}> operator()(PyObject* obj); }; template <> struct Constructor<{{struct:cpp_name}}> : public BaseConstructor<{{struct:cpp_name}}> { PyObject* operator()(const {{struct:cpp_name}}& val); }; template <> struct Constructor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>> : public BaseConstructor<::apache::thrift::python::capi::ComposedStruct< {{struct:cpp_name}}>> { PyObject* operator()(const {{struct:cpp_name}}& val); }; {{/program:structs}} {{#program:enums}} template <> struct Extractor<{{program:cpp_namespaces}}::{{enum:cpp_name}}> : public BaseExtractor<{{program:cpp_namespaces}}::{{enum:cpp_name}}> { ExtractorResult<{{program:cpp_namespaces}}::{{enum:cpp_name}}> operator()(PyObject* obj); int typeCheck(PyObject* obj); }; template <> struct Constructor<{{program:cpp_namespaces}}::{{enum:cpp_name}}> { PyObject* operator()({{program:cpp_namespaces}}::{{enum:cpp_name}} val); }; {{/program:enums}} } // namespace capi } // namespace python } // namespace thrift } // namespace apache )__FBTHRIFT_TAG__", // python_capi/thrift_types_capi.pxd.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Cpp2 <-> Python converters for Thrift types }} {{> common/auto_generated_cython}} from cpython.ref cimport PyObject from libc.stdint cimport int64_t from libcpp.memory cimport unique_ptr as __unique_ptr from folly.iobuf cimport cIOBuf as __cIOBuf {{#program:structs}} cdef api int can_extract__{{program:capi_module_prefix}}__{{struct:name}}(object) except -1 {{^struct:marshal_capi?}} cdef api __cIOBuf* extract__{{program:capi_module_prefix}}__{{struct:name}}(object) except NULL cdef api object construct__{{program:capi_module_prefix}}__{{struct:name}}(__unique_ptr[__cIOBuf]) {{/struct:marshal_capi?}} cdef api object init__{{program:capi_module_prefix}}__{{struct:name}}(object data) {{/program:structs}} {{#program:enums}} cdef api int can_extract__{{program:capi_module_prefix}}__{{enum:name}}(object) except -1 cdef api object construct__{{program:capi_module_prefix}}__{{enum:name}}(int64_t) {{/program:enums}} )__FBTHRIFT_TAG__", // python_capi/thrift_types_capi.pyx.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! Generated Cpp2 <-> Python converters for Thrift types }} {{> common/auto_generated_cython}} from cpython.ref cimport PyObject from libcpp.utility cimport move as __move from folly.iobuf cimport ( from_unique_ptr as __IOBuf_from_unique_ptr, IOBuf as __IOBuf, ) from thrift.python.serializer import ( deserialize as __deserialize, Protocol as __Protocol, serialize_iobuf as __serialize_iobuf, ) import {{program:module_path}}.thrift_types as __thrift_types {{#program:structs}} cdef api int can_extract__{{program:capi_module_prefix}}__{{struct:name}}(object __obj) except -1: return 1 if isinstance(__obj, __thrift_types.{{struct:name}}) else 0 {{^struct:marshal_capi?}} cdef api __cIOBuf* extract__{{program:capi_module_prefix}}__{{struct:name}}(object __obj) except NULL: cdef __IOBuf __buf = __serialize_iobuf(__obj, protocol=__Protocol.BINARY) return __buf._ours.release() cdef api object construct__{{program:capi_module_prefix}}__{{struct:name}}(__unique_ptr[__cIOBuf] __s): return __deserialize( __thrift_types.{{struct:name}}, __IOBuf_from_unique_ptr(__move(__s)), protocol=__Protocol.BINARY ) {{/struct:marshal_capi?}} cdef api object init__{{program:capi_module_prefix}}__{{struct:name}}(object data): return __thrift_types.{{struct:name}}._fbthrift_create(data) {{/program:structs}} {{#program:enums}} cdef api int can_extract__{{program:capi_module_prefix}}__{{enum:name}}(object __obj) except -1: return 1 if isinstance(__obj, __thrift_types.{{enum:name}}) else 0 cdef api object construct__{{program:capi_module_prefix}}__{{enum:name}}(int64_t __val): return __thrift_types.{{enum:name}}(__val) {{/program:enums}} )__FBTHRIFT_TAG__", // rust/client.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! {{#program:services?}} //! Client implementation for each service in `{{program:name}}`. {{^program:multifile?}} #![recursion_limit = "100000000"] {{/program:multifile?}} #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals{{! }}{{^program:multifile?}}, unused_crate_dependencies{{/program:multifile?}}{{! }}, unused_imports, clippy::all)] #[doc(inline)] pub use {{program:types}} as types; pub mod errors {{>lib/block}}{{#program:services}} {{>lib/client_errors}} {{#service:interactions}} {{>lib/client_errors}} {{/service:interactions}} {{/program:services}} } pub(crate) use {{program:crate}} as client; pub(crate) use {{program:types}}::services; // Used by Thrift-generated code to implement service inheritance. #[doc(hidden)] #[deprecated] pub mod dependencies {{>lib/block}}{{! }}{{#program:includes}}{{! }}{{#program:label}} #[deprecated = "use `{{.}}` ({{program:namespace}})"]{{/program:label}} pub mod {{program:name}} { pub use {{program:client_package}}::*; }{{/program:includes}} } {{#program:services}}{{>lib/client}}{{! }}{{/program:services}} {{/program:services?}} {{^program:services?}} #![doc(hidden)] #![allow({{! }}{{^program:multifile?}}non_snake_case, unused_crate_dependencies, {{/program:multifile?}}{{! }}unused_imports)] pub use {{program:types}} as types; pub(crate) use {{program:crate}} as client; {{/program:services?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/consts.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! //! Thrift constant definitions for `{{program:name}}`. {{#program:constants}}{{>lib/const}}{{/program:constants}} {{#program:has_const_tests?}} {{>lib/adapter/const_test}} {{/program:has_const_tests?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/errors.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} // @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! //! Thrift error definitions for `{{program:name}}`. {{#program:services}}{{>lib/errors}}{{! }}{{/program:services}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/adapter/const_test.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} /// These are here to ensure adapted consts do not panic with `from_thrift`. #[cfg(test)] mod tests { {{#program:consts_for_test}} #[test] fn test_const_{{.}}_force_does_not_panic() { let _ = ::once_cell::sync::Lazy::force(&super::{{.}}); } {{/program:consts_for_test}} } // This is here to ensure you enable unittests on your Thrift library. #[cfg(feature = "thrift_library_unittests_disabled")] compile_error!("You are using Rust adapters in a Thrift library that does not have unittests enabled. For safety reasons, this is forbidden. Please enable Rust unittests for this Thrift library."); {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/adapter/default_test.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} /// These are here to ensure the `from_thrift_default` methods on adapters don't panic. #[cfg(test)] mod tests { {{#program:structs_for_default_test}} #[test] fn test_struct_{{struct:rust_name}}_default_does_not_panic() { {{#struct:has_adapter?}} let _ = super::unadapted::{{struct:rust_name}}::default(); {{/struct:has_adapter?}} {{^struct:has_adapter?}} let _ = super::{{struct:rust_name}}::default(); {{/struct:has_adapter?}} } {{/program:structs_for_default_test}} } // This is here to ensure you enable unittests on your Thrift library. #[cfg(feature = "thrift_library_unittests_disabled")] compile_error!("You are using Rust adapters in a Thrift library that does not have unittests enabled. For safety reasons, this is forbidden. Please enable Rust unittests for this Thrift library."); {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/adapter/name.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#adapter:layered?}}::fbthrift::adapter::LayeredThriftAdapter<{{/adapter:layered?}}{{! }}{{#adapter:name?}}{{! }}{{.}}{{! }}{{/adapter:name?}}{{! }}{{#adapter:is_generic?}}{{! }}<{{#adapter:underlying_type}}{{>lib/type}}{{/adapter:underlying_type}}>{{! }}{{/adapter:is_generic?}}{{! }}{{#adapter:layered?}}, {{/adapter:layered?}}{{! }}{{#adapter:transitive_type?}}{{! }}{{#type:typedef}}{{! }}{{type:package}}::adapters::{{type:rust_name}}{{! }}{{/type:typedef}}{{! }}{{^type:typedef?}}{{! }}{{#type:struct?}}{{! }}{{type:package}}::adapters::{{type:rust_name}}{{! }}{{/type:struct?}}{{! }}{{#type:list?}}{{! }}::fbthrift::adapter::ListMapAdapter<{{! }}{{#type:list_elem_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/name}}{{/type:has_adapter?}}{{! }}{{/type:list_elem_type}}{{! }}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}::fbthrift::adapter::SetMapAdapter<{{! }}{{#type:set_elem_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/name}}{{/type:has_adapter?}}{{! }}{{/type:set_elem_type}}{{! }}>{{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}::fbthrift::adapter::MapMapAdapter<{{! }}{{#type:key_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/name}}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}::fbthrift::adapter::IdentityAdapter<{{>lib/type}}>{{! }}{{/type:has_adapter?}}{{! }}{{/type:key_type}}{{! }}, {{! }}{{#type:value_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/name}}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}::fbthrift::adapter::IdentityAdapter<{{>lib/type}}>{{! }}{{/type:has_adapter?}}{{! }}{{/type:value_type}}{{! }}>{{! }}{{/type:map?}}{{! }}{{/type:typedef?}}{{! }}{{/adapter:transitive_type?}}{{! }}{{#adapter:layered?}}>{{/adapter:layered?}} )__FBTHRIFT_TAG__", // rust/lib/adapter/qualified.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}<{{>lib/adapter/name}} as ::fbthrift::adapter::ThriftAdapter> )__FBTHRIFT_TAG__", // rust/lib/annfieldread.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type_nonstandard?}}{{program:crate}}::r#impl::read{{/field:type_nonstandard?}}{{! }}{{^field:type_nonstandard?}}::fbthrift::Deserialize::read{{/field:type_nonstandard?}} )__FBTHRIFT_TAG__", // rust/lib/annfieldtype.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:numeric_or_void?}}::{{field:type_rust}}{{/type:numeric_or_void?}}{{! }}{{#type:string?}}::std::string::String{{/type:string?}}{{! }}{{#type:binary?}}::{{field:type_rust}}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#struct:has_adapter?}}{{! }}{{struct:package}}::unadapted::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}{{struct:package}}::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{/type:struct}}{{! }}{{#type:enum}}{{enum:package}}::{{enum:rust_name}}{{/type:enum}}{{! }}{{#type:list?}} }}::std::vec::Vec<{{#type:list_elem_type}}{{>lib/type}}{{/type:list_elem_type}}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}::{{field:type_rust}}{{! }}<{{! }}{{#type:set_elem_type}}{{! }}{{#type:floating_point?}}::fbthrift::export::OrderedFloat<{{>lib/type}}>{{/type:floating_point?}}{{! }}{{^type:floating_point?}}{{>lib/type}}{{/type:floating_point?}}{{! }}{{/type:set_elem_type}}{{! }}>{{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}::{{field:type_rust}}{{! }}<{{! }}{{#type:key_type}}{{! }}{{#type:floating_point?}}::fbthrift::export::OrderedFloat<{{>lib/type}}>{{/type:floating_point?}}{{! }}{{^type:floating_point?}}{{>lib/type}}{{/type:floating_point?}}{{! }}{{/type:key_type}}, {{! }}{{#type:value_type}}{{>lib/type}}{{/type:value_type}}{{! }}>{{! }}{{/type:map?}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/annfieldwrite.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type_nonstandard?}}{{program:crate}}::r#impl::write{{/field:type_nonstandard?}}{{! }}{{^field:type_nonstandard?}}::fbthrift::Serialize::write{{/field:type_nonstandard?}} )__FBTHRIFT_TAG__", // rust/lib/arg.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^field:primitive?}}&{{/field:primitive?}}{{>lib/arg_inner}} )__FBTHRIFT_TAG__", // rust/lib/arg_inner.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:type}}{{! }}{{#type:string?}}::std::primitive::str{{/type:string?}}{{! }}{{#type:list?}}{{! }}[{{#type:list_elem_type}}{{>lib/type}}{{/type:list_elem_type}}]{{! }}{{/type:list?}}{{! }}{{^type:string?}}{{^type:list?}}{{! }}{{>lib/type}}{{! }}{{/type:list?}}{{/type:string?}}{{! }}{{/field:type}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/arg_life.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^field:primitive?}}&'a {{/field:primitive?}}{{>lib/arg_inner}} )__FBTHRIFT_TAG__", // rust/lib/block.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{ )__FBTHRIFT_TAG__", // rust/lib/client.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:interactions}}{{>lib/client}} {{/service:interactions}} /// Client definitions for `{{service:rust_name}}`. pub struct {{service:rust_name}}Impl { {{#service:extends}} parent: {{service:client_package}}::{{service:rust_name}}Impl, {{/service:extends}} {{^service:extends}} transport: T, _phantom: ::std::marker::PhantomData (P, S)>, {{/service:extends}} } impl {{service:rust_name}}Impl where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, {{! require P::Frame and T to have compatible DecBuf and EncBuf::Final }} P::Frame: ::fbthrift::Framing>, ::fbthrift::ProtocolEncoded

: ::fbthrift::BufMutExt>, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { pub fn new( transport: T, ) -> Self { {{#service:extends}} let parent = {{service:client_package}}::{{service:rust_name}}Impl::::new(transport); Self { parent } {{/service:extends}} {{^service:extends}} Self { transport, _phantom: ::std::marker::PhantomData, } {{/service:extends}} } pub fn transport(&self) -> &T { {{#service:extends}} self.parent.transport() {{/service:extends}} {{^service:extends}} &self.transport {{/service:extends}} } {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} fn _{{function:name}}_impl( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} rpc_options: T::RpcOptions, ) -> {{>lib/client_return_type}} { use ::const_cstr::const_cstr; use ::tracing::Instrument as _; use ::futures::FutureExt as _; {{#function:stream?}} use ::futures::StreamExt as _; use ::fbthrift::Deserialize as _; {{/function:stream?}} const_cstr! { SERVICE_NAME = "{{service:parent_service_name}}"; SERVICE_METHOD_NAME = "{{service:parent_service_name}}.{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}}"; {{#function:creates_interaction?}} INTERACTION_NAME = "{{function:interaction_name}}"; {{/function:creates_interaction?}} } let args = self::Args_{{service:rust_name}}_{{function:name}} { {{#function:args}} {{field:rust_name}}: arg_{{field:name}}, {{/function:args}} _phantom: ::std::marker::PhantomData, }; {{#function:creates_interaction?}} let interaction_transport = match self.transport().create_interaction(INTERACTION_NAME.as_cstr()) { ::std::result::Result::Ok(res) => res, ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(), }; let interaction_impl = {{function:interaction_name}}Impl::::new(interaction_transport); let transport = interaction_impl.transport(); {{/function:creates_interaction?}}{{^function:creates_interaction?}} let transport = self.transport(); {{/function:creates_interaction?}} // need to do call setup outside of async block because T: Transport isn't Send let request_env = match ::fbthrift::help::serialize_request_envelope::("{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}}", &args) { ::std::result::Result::Ok(res) => res, ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(), }; {{#function:stream?}} 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 = "{{service:name}}.{{function:name}}")); {{/function:stream?}}{{^function:stream?}} let call = transport .call(SERVICE_NAME.as_cstr(), SERVICE_METHOD_NAME.as_cstr(), request_env, rpc_options) .instrument(::tracing::trace_span!("call", method = "{{service:name}}.{{function:name}}")); {{/function:stream?}} async move { {{#function:stream?}}{{! ****************************** ******* STREAMING BODY ******* ****************************** }} 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({{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}StreamError::from(err)), ::std::result::Result::Ok(item_enc) => { S::spawn(move || { match item_enc { ::fbthrift::ClientStreamElement::Reply(payload) => { let mut de = P::deserializer(payload); <{{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}StreamReader as ::fbthrift::help::DeserializeExn>::read_result(&mut de) } ::fbthrift::ClientStreamElement::ApplicationEx(payload) => { let mut de = P::deserializer(payload); let aexn = ::fbthrift::ApplicationException::read(&mut de)?; ::std::result::Result::Ok(::std::result::Result::Err({{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}StreamError::ApplicationException(aexn))) } } }).await? } } } }) .boxed(); let de = P::deserializer(initial); let res = ::fbthrift::help::async_deserialize_response_envelope::(de) .await?? .map({{! }}{{#function:stream_has_first_response?}}move |initial| (initial, new_stream){{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}move |_| new_stream{{/function:stream_has_first_response?}}{{! }}); {{/function:stream?}}{{^function:stream?}}{{! ****************************** **** SINGLE RESPONSE BODY **** ****************************** }} 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({{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error::ApplicationException(aexn)) } }; {{/function:stream?}} {{#function:return_type}}{{#function:creates_interaction?}}{{! *********************************** **** Add interaction to result **** *********************************** }} let interaction_client: {{program:crate}}::client::{{function:interaction_name}}Client = ::std::sync::Arc::new(interaction_impl); {{#type:void?}} res?; ::std::result::Result::Ok(interaction_client) {{/type:void?}}{{^type:void?}} ::std::result::Result::Ok((interaction_client, res?)) {{/type:void?}}{{! }}{{/function:creates_interaction?}}{{^function:creates_interaction?}} res {{/function:creates_interaction?}}{{/function:return_type}} } .instrument(::tracing::info_span!("stream", method = "{{service:name}}.{{function:name}}")) .boxed() } {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} } {{#service:extendedServers}} #[allow(deprecated)]{{! `dependencies` modules are deprecated other than for packagePrefix to use }} impl {{! }}{{#extendedService:service}}{{! }}::std::convert::AsRef {{! }}{{/extendedService:service}}{{! }}for {{service:rust_name}}Impl where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, {{! require P::Frame and T to have compatible DecBuf and EncBuf::Final }} P::Frame: ::fbthrift::Framing>, ::fbthrift::ProtocolEncoded

: ::fbthrift::BufMutExt>, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { fn as_ref(&self) -> &(dyn {{#extendedService:service}}{{! }}{{extendedService:packagePrefix}}::{{service:rust_name}}{{! }}{{/extendedService:service}}{{! }} + 'static) { {{extendedService:asRefImpl}} } } #[allow(deprecated)]{{! `dependencies` modules are deprecated other than for packagePrefix to use }} impl {{! }}{{#extendedService:service}}{{! }}::std::convert::AsRef + 'static> {{! }}{{/extendedService:service}}{{! }}for {{service:rust_name}}Impl where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, {{! require P::Frame and T to have compatible DecBuf and EncBuf::Final }} P::Frame: ::fbthrift::Framing>, ::fbthrift::ProtocolEncoded

: ::fbthrift::BufMutExt>, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { fn as_ref(&self) -> &(dyn {{#extendedService:service}}{{! }}{{extendedService:packagePrefix}}::{{service:rust_name}}Ext{{! }}{{/extendedService:service}}{{! }} + 'static) { {{extendedService:asRefImpl}} } } {{/service:extendedServers}} {{#service:docs?}} #[doc = {{service:docs}}] {{/service:docs?}} pub trait {{service:rust_name}}: {{! }}{{#service:extends}}{{service:client_package}}::{{service:rust_name}} + {{/service:extends}}{{! }}::std::marker::Send {{>lib/block}}{{! }}{{#service:rustFunctions}} {{#function:docs?}} #[doc = {{function:docs}}] {{/function:docs?}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}( &self, {{#function:args}} arg_{{field:name}}: {{>lib/arg}}, {{/function:args}} ) -> {{>lib/client_return_type}}; {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:rust_name}}( &self, ) -> ::std::result::Result<{{! }}{{function:interaction_name}}Client, {{! }}::anyhow::Error>; {{/function:starts_interaction?}}{{/service:rustFunctions}} } pub trait {{service:rust_name}}Ext: {{service:rust_name}}{{! }}{{#service:extends}} + {{service:client_package}}::{{service:rust_name}}Ext{{/service:extends}} where T: ::fbthrift::Transport, {{>lib/block}} {{#service:rustFunctions}} {{#function:docs?}} #[doc = {{function:docs}}] {{/function:docs?}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}_with_rpc_opts( &self, {{#function:args}} arg_{{field:name}}: {{>lib/arg}}, {{/function:args}} rpc_options: T::RpcOptions, ) -> {{>lib/client_return_type}}; {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} fn transport(&self) -> &T; } {{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} struct Args_{{service:rust_name}}_{{function:name}}<'a> { {{#function:args}} {{field:rust_name}}: {{>lib/arg_life}}, {{/function:args}} _phantom: ::std::marker::PhantomData<&'a ()>, } impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize

for self::Args_{{service:rust_name}}_{{function:name}}<'a> { #[inline]{{! No cost because there's only one caller; with luck will mitigate move cost of args. }} #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "{{service:name}}.{{function:name}}"))] fn write(&self, p: &mut P) { p.write_struct_begin("args");{{! }}{{#function:args}} p.write_field_begin({{! }}"{{field:name}}", {{! }}{{#field:type}}{{>lib/ttype}}{{/field:type}}, {{! }}{{field:key}}i16{{! }}); {{#field:type}}{{! }}{{#type:has_adapter?}}{{! }}::fbthrift::Serialize::write(&{{>lib/adapter/qualified}}::to_thrift_field::(&self.{{field:rust_name}}, {{field:key}}), p){{! }}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{! }}{{>lib/write}}(&self.{{field:rust_name}}, p){{! }}{{/type:has_adapter?}}{{! }}{{/field:type}}; p.write_field_end();{{! }}{{/function:args}} p.write_field_stop(); p.write_struct_end(); } } {{/function:sink?}}{{/function:starts_interaction?}}{{/service:rustFunctions}} impl {{service:rust_name}} for {{service:rust_name}}Impl where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, {{! require P::Frame and T to have compatible DecBuf and EncBuf::Final }} P::Frame: ::fbthrift::Framing>, ::fbthrift::ProtocolEncoded

: ::fbthrift::BufMutExt>, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, {{>lib/block}} {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} ) -> {{>lib/client_return_type}} { let rpc_options = T::RpcOptions::default(); self._{{function:name}}_impl( {{#function:args}} arg_{{field:name}}, {{/function:args}} rpc_options, ) } {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:name}}( &self, ) -> ::std::result::Result<{{! }}{{function:interaction_name}}Client, {{! }}::anyhow::Error> { use ::const_cstr::const_cstr; const_cstr! { INTERACTION_NAME = "{{function:interaction_name}}"; } Ok( ::std::sync::Arc::new( {{function:interaction_name}}Impl::::new( self.transport().create_interaction(INTERACTION_NAME.as_cstr())? ) ) ) } {{/function:starts_interaction?}}{{/service:rustFunctions}} } impl {{service:rust_name}}Ext for {{service:rust_name}}Impl where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, {{! require P::Frame and T to have com)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(patible DecBuf and EncBuf::Final }} P::Frame: ::fbthrift::Framing>, ::fbthrift::ProtocolEncoded

: ::fbthrift::BufMutExt>, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, {{>lib/block}} {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}_with_rpc_opts( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} rpc_options: T::RpcOptions, ) -> {{>lib/client_return_type}} { self._{{function:name}}_impl( {{#function:args}} arg_{{field:name}}, {{/function:args}} rpc_options, ) } {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} fn transport(&self) -> &T { self.transport() } } #[allow(deprecated)]{{! `dependencies` modules are deprecated other than for packagePrefix to use }} impl<'a, S> {{service:rust_name}} for S where S: ::std::convert::AsRef, {{#service:extendedServers}} {{#extendedService:service}} S: {{extendedService:packagePrefix}}::{{service:rust_name}}, {{/extendedService:service}} {{/service:extendedServers}} S: ::std::marker::Send, { {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} ) -> {{>lib/client_return_type}} { self.as_ref().{{function:rust_name}}( {{#function:args}} arg_{{field:name}}, {{/function:args}} ) } {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:rust_name}}( &self, ) -> ::std::result::Result<{{! }}{{function:interaction_name}}Client, {{! }}::anyhow::Error> { self.as_ref().{{function:rust_name}}() } {{/function:starts_interaction?}}{{/service:rustFunctions}} } #[allow(deprecated)]{{! `dependencies` modules are deprecated other than for packagePrefix to use }} impl {{service:rust_name}}Ext for S where S: ::std::convert::AsRef, S: ::std::convert::AsRef + 'static>, {{#service:extendedServers}} {{#extendedService:service}} S: {{extendedService:packagePrefix}}::{{service:rust_name}}, S: {{extendedService:packagePrefix}}::{{service:rust_name}}Ext, {{/extendedService:service}} {{/service:extendedServers}} S: ::std::marker::Send, T: ::fbthrift::Transport, { {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} fn {{function:rust_name}}_with_rpc_opts( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} rpc_options: T::RpcOptions, ) -> {{>lib/client_return_type}} { >>::as_ref(self).{{function:rust_name}}_with_rpc_opts( {{#function:args}} arg_{{field:name}}, {{/function:args}} rpc_options, ) } {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} fn transport(&self) -> &T { as {{service:rust_name}}Ext>::transport(>>::as_ref(self)) } } #[derive(Clone)] pub struct make_{{service:rust_name}}; /// To be called by user directly setting up a client. Avoids /// needing ClientFactory trait in scope, avoids unidiomatic /// make_Trait name. /// /// ``` /// # const _: &str = stringify! { /// use bgs::client::BuckGraphService; /// /// let protocol = BinaryProtocol::new(); /// let transport = HttpClient::new(); /// let client = ::new(protocol, transport); /// # }; /// ``` impl dyn {{service:rust_name}} { {{#service:annotations}} {{#annotation:value?}} pub const {{annotation:rust_name}}: &'static ::std::primitive::str = {{annotation:rust_value}}; {{/annotation:value?}} {{/service:annotations}} pub fn new( protocol: P, transport: T, ) -> ::std::sync::Arc where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, P::Deserializer: ::std::marker::Send, { let spawner = ::fbthrift::help::NoopSpawner; Self::with_spawner(protocol, transport, spawner) } pub fn with_spawner( protocol: P, transport: T, spawner: S, ) -> ::std::sync::Arc where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { let _ = protocol; let _ = spawner; ::std::sync::Arc::new({{service:rust_name}}Impl::::new(transport)) } } impl dyn {{service:rust_name}}Ext where T: ::fbthrift::Transport, { pub fn new

( protocol: P, transport: T, ) -> ::std::sync::Arc + ::std::marker::Send + ::std::marker::Sync + 'static> where P: ::fbthrift::Protocol, P::Deserializer: ::std::marker::Send, { let spawner = ::fbthrift::help::NoopSpawner; Self::with_spawner(protocol, transport, spawner) } pub fn with_spawner( protocol: P, transport: T, spawner: S, ) -> ::std::sync::Arc + ::std::marker::Send + ::std::marker::Sync + 'static> where P: ::fbthrift::Protocol, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { let _ = protocol; let _ = spawner; ::std::sync::Arc::new({{service:rust_name}}Impl::::new(transport)) } } pub type {{service:rust_name}}DynClient = ::Api; pub type {{service:rust_name}}Client = ::std::sync::Arc<{{service:rust_name}}DynClient>; /// The same thing, but to be called from generic contexts where we are /// working with a type parameter `C: ClientFactory` to produce clients. impl ::fbthrift::ClientFactory for make_{{service:rust_name}} { type Api = dyn {{service:rust_name}} + ::std::marker::Send + ::std::marker::Sync + 'static; fn with_spawner(protocol: P, transport: T, spawner: S) -> ::std::sync::Arc where P: ::fbthrift::Protocol, T: ::fbthrift::Transport, P::Deserializer: ::std::marker::Send, S: ::fbthrift::help::Spawner, { ::with_spawner(protocol, transport, spawner) } } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/client_errors.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} #[doc(inline)] pub use {{program:types}}::errors::{{service:snake}}; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use {{program:types}}::errors::{{service:snake}}::*; )__FBTHRIFT_TAG__", // rust/lib/client_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}::futures::future::BoxFuture<'static, ::std::result::Result<{{! }}{{#function:return_type}}{{! }}{{#function:creates_interaction?}}{{! }}{{#type:void?}}{{! }}{{program:crate}}::client::{{function:interaction_name}}Client{{! }}{{/type:void?}}{{^type:void?}}{{! }}({{program:crate}}::client::{{function:interaction_name}}Client, {{>lib/return_type}}){{! }}{{/type:void?}}{{! }}{{/function:creates_interaction?}}{{^function:creates_interaction?}}{{! }}{{>lib/return_type}}{{! }}{{/function:creates_interaction?}}{{! }}{{/function:return_type}}{{! }}, {{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error{{! }}>> )__FBTHRIFT_TAG__", // rust/lib/const.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#constant:rust}} {{#constant:type}} {{#constant:docs?}} #[doc = {{constant:docs}}] {{/constant:docs?}}{{^constant:lazy?}} pub const {{constant:name}}{{! }}: {{! }}{{#type:string?}}&::std::primitive::str = {{value:quoted}}{{/type:string?}}{{! }}{{^type:string?}}{{>lib/type}} = {{>lib/value}}{{/type:string?}}{{! }}; {{/constant:lazy?}} {{#constant:lazy?}} pub static {{constant:name}}{{! }}: ::once_cell::sync::Lazy<{{! }}{{#constant:type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/qualified}}::AdaptedType{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}{{>lib/type}}{{/type:has_adapter?}}{{! }}{{/constant:type}}{{! }}> = ::once_cell::sync::Lazy::new(|| {{! }}{{#constant:type}}{{#type:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift({{/type:has_adapter?}}{{/constant:type}}{{! }}{{>lib/value}}{{! }}{{#constant:type}}{{#type:has_adapter?}}).expect("constant Thrift value should adapt without error"){{/type:has_adapter?}}{{/constant:type}}{{! }}); {{/constant:lazy?}} {{/constant:type}} {{/constant:rust}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/enum.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#enum:docs?}} #[doc = {{enum:docs}}] {{/enum:docs?}} #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash{{! }}{{#enum:serde?}}, ::serde_derive::Serialize, ::serde_derive::Deserialize{{/enum:serde?}}{{! }}{{#enum:derive}}, {{.}}{{/enum:derive}}{{! }})] pub struct {{enum:rust_name}}(pub ::std::primitive::i32); impl {{enum:rust_name}} {{>lib/block}}{{! }}{{#enum:values}} {{#enum_value:docs?}} #[doc = {{enum_value:docs}}] {{/enum_value:docs?}} pub const {{enum_value:rust_name}}: Self = {{! }}{{enum:rust_name}}({{enum_value:value}}i32);{{! }}{{/enum:values}} } impl ::fbthrift::ThriftEnum for {{enum:rust_name}} { fn enumerate() -> &'static [(Self, &'static str)] { &[ {{#enum:values}} (Self::{{enum_value:rust_name}}, "{{enum_value:name}}"), {{/enum:values}} ] } fn variants() -> &'static [&'static str] { &[ {{#enum:values}} "{{enum_value:name}}", {{/enum:values}} ] } fn variant_values() -> &'static [Self] { &[ {{#enum:values}} Self::{{enum_value:rust_name}}, {{/enum:values}} ] } } #[allow(clippy::derivable_impls)] impl ::std::default::Default for {{enum:rust_name}} { fn default() -> Self { {{^program:deprecated_default_enum_min_i32?}} Self(0) {{/program:deprecated_default_enum_min_i32?}} {{#program:deprecated_default_enum_min_i32?}} Self(::std::primitive::i32::MIN) {{/program:deprecated_default_enum_min_i32?}} } } impl<'a> ::std::convert::From<&'a {{enum:rust_name}}> for ::std::primitive::i32 { #[inline] fn from(x: &'a {{enum:rust_name}}) -> Self { x.0 } } impl ::std::convert::From<{{enum:rust_name}}> for ::std::primitive::i32 { #[inline] fn from(x: {{enum:rust_name}}) -> Self { x.0 } } impl ::std::convert::From<::std::primitive::i32> for {{enum:rust_name}} { #[inline] fn from(x: ::std::primitive::i32) -> Self { Self(x) } } impl ::std::fmt::Display for {{enum:rust_name}} { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {{>lib/block}} static VARIANTS_BY_NUMBER: &[(&::std::primitive::str, ::std::primitive::i32)] = &[ {{#enum:variants_by_number}} ("{{enum_value:name}}", {{enum_value:value}}), {{/enum:variants_by_number}} ]; ::fbthrift::help::enum_display(VARIANTS_BY_NUMBER, fmt, self.0) } } impl ::std::fmt::Debug for {{enum:rust_name}} { fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(fmt, "{{enum:name}}::{}", self) } } impl ::std::str::FromStr for {{enum:rust_name}} { type Err = ::anyhow::Error; fn from_str(string: &::std::primitive::str) -> ::std::result::Result { static VARIANTS_BY_NAME: &[(&::std::primitive::str, ::std::primitive::i32)] = &[ {{#enum:variants_by_name}} ("{{enum_value:name}}", {{enum_value:value}}), {{/enum:variants_by_name}} ]; ::fbthrift::help::enum_from_str(VARIANTS_BY_NAME, string, "{{enum:name}}").map(Self) } } impl ::fbthrift::GetTType for {{enum:rust_name}} { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::I32; } {{!newline}} {{#enum:thrift_uri}} impl ::fbthrift::GetUri for self::{{enum:rust_name}} { fn uri() -> &'static str { "{{enum:thrift_uri}}" } } {{/enum:thrift_uri}} impl

::fbthrift::Serialize

for {{enum:rust_name}} where P: ::fbthrift::ProtocolWriter, { #[inline] fn write(&self, p: &mut P) { p.write_i32(self.into()) } } impl

::fbthrift::Deserialize

for {{enum:rust_name}} where P: ::fbthrift::ProtocolReader, { #[inline] fn read(p: &mut P) -> ::anyhow::Result { ::std::result::Result::Ok(Self::from(::anyhow::Context::context(p.read_i32(), "Expected a number indicating enum variant")?)) } } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/errors.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:interactions}}{{>lib/errors}} {{/service:interactions}} /// Error definitions for `{{service:rust_name}}`. pub mod {{service:snake}} { {{#service:rust_exceptions}} pub trait As{{#rust_exception:type}}{{type:rust_name}}{{/rust_exception:type}} { fn as_{{#rust_exception:type}}{{type:rust_name_snake}}{{/rust_exception:type}}(&self) -> Option<&{{#rust_exception:type}}{{>lib/type}}{{/rust_exception:type}}>; } impl As{{#rust_exception:type}}{{type:rust_name}}{{/rust_exception:type}} for ::anyhow::Error { fn as_{{#rust_exception:type}}{{type:rust_name_snake}}{{/rust_exception:type}}(&self) -> Option<&{{#rust_exception:type}}{{>lib/type}}{{/rust_exception:type}}> { for cause in self.chain() { {{#rust_exception:functions}} {{#rust_exception_function:function}} if let Some({{function:upcamel}}Error::{{#rust_exception_function:field}}{{field:rust_name}}{{/rust_exception_function:field}}(e)) = cause.downcast_ref::<{{function:upcamel}}Error>() { return Some(e); } {{/rust_exception_function:function}} {{/rust_exception:functions}} } None } } {{/service:rust_exceptions}} {{#service:rustFunctions}} {{^function:starts_interaction?}} {{#function:exceptions?}} /// Errors for {{function:rust_name}} (client side). #[derive(Debug)] pub enum {{function:upcamel}}Error { {{#function:exceptions}} {{field:rust_name}}({{#field:type}}{{>lib/type}}{{/field:type}}), {{/function:exceptions}} ApplicationException(::fbthrift::ApplicationException), ThriftError(::anyhow::Error), } /// Human-readable string representation of the Thrift client error. /// /// By default, this will not print the full cause chain. If you would like to print the underlying error /// cause, either use `format!("{:?}", anyhow::Error::from(client_err))` or print this using the /// alternate formatter `{:#}` instead of just `{}`. impl ::std::fmt::Display for {{function:upcamel}}Error { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::result::Result<(), ::std::fmt::Error> { match self { {{#function:exceptions}} Self::{{field:rust_name}}(inner) => { if f.alternate() { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with variant `{{field:rust_name}}`: {:#}", inner)?; } else { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with {{field:rust_name}}({{#field:type}}{{type:rust_name}}{{/field:type}})")?; } } {{/function:exceptions}} Self::ApplicationException(inner) => { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with ApplicationException")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } Self::ThriftError(inner) => { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with ThriftError")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } } Ok(()) } } impl ::std::error::Error for {{function:upcamel}}Error { fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { match self { {{#function:exceptions}} Self::{{field:rust_name}}(ref inner) => { Some(inner) } {{/function:exceptions}} Self::ApplicationException(ref inner) => { Some(inner) } Self::ThriftError(ref inner) => { Some(inner.as_ref()) } } } } {{#function:uniqueExceptions}} impl ::std::convert::From<{{#field:type}}{{>lib/type}}{{/field:type}}> for {{function:upcamel}}Error { fn from(e: {{#field:type}}{{>lib/type}}{{/field:type}}) -> Self { Self::{{field:rust_name}}(e) } } impl As{{#field:type}}{{type:rust_name}}{{/field:type}} for {{function:upcamel}}Error { fn as_{{#field:type}}{{type:rust_name_snake}}{{/field:type}}(&self) -> Option<&{{#field:type}}{{>lib/type}}{{/field:type}}> { match self { Self::{{field:rust_name}}(inner) => Some(inner), _ => None, } } } {{/function:uniqueExceptions}} impl ::std::convert::From<::anyhow::Error> for {{function:upcamel}}Error { fn from(err: ::anyhow::Error) -> Self { Self::ThriftError(err) } } impl ::std::convert::From<::fbthrift::ApplicationException> for {{function:upcamel}}Error { fn from(ae: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(ae) } } {{/function:exceptions?}} {{^function:sink?}} {{^function:exceptions?}} pub type {{function:upcamel}}Error = ::fbthrift::NonthrowingFunctionError; {{/function:exceptions?}} impl ::std::convert::From<{{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn> for {{function:upcamel}}Error { fn from(e: {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn) -> Self { match e { {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn::ApplicationException(aexn) => {{function:upcamel}}Error::ApplicationException(aexn), {{#function:exceptions}} {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn::{{field:rust_name}}(exn) => {{function:upcamel}}Error::{{field:rust_name}}(exn), {{/function:exceptions}} } } } #[doc(hidden)] pub enum {{function:upcamel}}Reader {} impl ::fbthrift::help::DeserializeExn for {{function:upcamel}}Reader { type Success = {{! }}{{^function:stream?}}{{>lib/server_ok_type}}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}{{! }}{{#function:return_type}}{{#function:stream_first_response_type}}{{>lib/type}}{{/function:stream_first_response_type}}{{/function:return_type}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}(){{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}; type Error = {{function:upcamel}}Error; fn read_result

(p: &mut P) -> ::anyhow::Result<::std::result::Result> where P: ::fbthrift::ProtocolReader, { static RETURNS: &[::fbthrift::Field] = &[ {{#function:returns_by_name}} {{.}}, {{/function:returns_by_name}} ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = {{! }}{{#function:void_or_void_stream?}}{{! }}::std::result::Result::Ok(()){{! }}{{/function:void_or_void_stream?}}{{! }}{{^function:void_or_void_stream?}}::std::option::Option::None{{/function:void_or_void_stream?}}{{! }}; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } (({{! }}{{^function:stream?}}{{! }}{{#function:return_type}}{{>lib/ttype}}{{/function:return_type}}{{! }}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}{{^function:stream_has_first_response?}}::fbthrift::TType::Void{{/function:stream_has_first_response?}}{{! }}{{#function:stream_has_first_response?}}{{#function:return_type}}{{#function:stream_first_response_type}}{{>lib/ttype}}{{/function:stream_first_response_type}}{{/function:return_type}}{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}, 0i32), false) => { once = true; alt = {{! }}{{^function:void_or_void_stream?}}::std::option::Option::Some({{/function:void_or_void_stream?}}{{! }}::std::result::Result::Ok({{! }}{{^function:stream?}}{{#function:return_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_field::(fbthrift::Deserialize::read(p)?, 0)?{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}::fbthrift::Deserialize::read(p)?{{/type:has_adapter?}}{{! }}{{/function:return_type}}{{/function:stream?}}{{! }}{{#function:stream?}}::fbthrift::Deserialize::read(p)?{{/function:stream?}}{{! }}){{! }}{{^function:void_or_void_stream?}}){{/function:void_or_void_stream?}}{{! }}; }{{! }}{{#function:exceptions}} (({{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}), false) => { once = true; alt = {{! }}{{^function:void_or_void_stream?}}::std::option::Option::Some({{/function:void_or_void_stream?}}{{! }}::std::result::Result::Err(Self::Error::{{field:rust_name}}({{! }}{{^function:stream?}}{{#function:return_type}}{{! }}{{#type:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_field::(fbthrift::Deserialize::read(p)?, 0)?{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}::fbthrift::Deserialize::read(p)?{{/type:has_adapter?}}{{! }}{{/function:return_type}}{{/function:stream?}}{{! }}{{#function:stream?}}::fbthrift::Deserialize::read(p)?{{/function:stream?}}{{! }})){{! }}{{^function:void_or_void_stream?}}){{/function:void_or_void_stream?}}{{! }}; }{{! }}{{/function:exceptions}} ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "{{function:upcamel}}Error", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?;{{! }}{{#function:void_or_void_stream?}} ::std::result::Result::Ok(alt){{! }}{{/function:void_or_void_stream?}}{{! }}{{^function:void_or_void_stream?}} alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "{{function:upcamel}}Error"), ) .into(), ){{! }}{{/function:void_or_void_stream?}} } } {{/function:sink?}} {{#function:stream?}} {{#function:stream_exceptions?}} #[derive(Debug)] pub enum {{function:upcamel}}StreamError { {{#function:stream_exceptions}} {{field:rust_name}}({{#field:type}}{{>lib/type}}{{/field:type}}), {{/function:stream_exceptions}} ApplicationException(::fbthrift::ApplicationException), ThriftError(::anyhow::Error), } /// Human-readable string representation of the Thrift client error. /// /// By default, this will not print the full cause chain. If you would like to print the underlying error /// cause, either use `format!("{:?}", anyhow::Error::from(client_err))` or print this using the /// alternate formatter `{:#}` instead of just `{}`. impl ::std::fmt::Display for {{function:upcamel}}StreamError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::result::Result<(), ::std::fmt::Error> { match self { {{#function:stream_exceptions}} Self::{{field:rust_name}}(inner) => { if f.alternate() { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with variant `{{field:rust_name}}`: {:#}", inner)?; } else { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with {{field:rust_name}}({{#field:type}}{{type:rust_name}}{{/field:type}})")?; } } {{/function:stream_exceptions}} Self::ApplicationException(inner) => { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with ApplicationException")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } Self::ThriftError(inner) => { write!(f, "{{service:rust_name}}::{{function:rust_name}} failed with ThriftError")?; if f.alternate() { write!(f, ": {:#}", inner)?; } } } Ok(()) } } impl ::std::error::Error for {{function:upcamel}}StreamError { fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> { match self { {{#function:stream_exceptions}} Self::{{field:rust_name}}(ref inner) => { Some(inner) } {{/function:stream_exceptions}} Self::ApplicationException(ref inner) => { Some(inner) } Self::ThriftError(ref inner) => { Some(inner.as_ref()) } } } } {{#function:uniqueStreamExceptions}} impl ::std::convert::From<{{#field:type}}{{>lib/type}}{{/field:type}}> for {{function:upcamel}}StreamError { fn from(e: {{#field:type}}{{>lib/type}}{{/field:type}}) -> Self { Self::{{field:rust_name}}(e) } } {{/function:uniqueStreamExceptions}} impl ::std::convert::From<::anyhow::Error> for {{function:upcamel}}StreamError { fn from(err: ::anyhow::Error) -> Self { Self::ThriftError(err) } } impl ::std::convert::From<::fbthrift::Appli)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(cationException> for {{function:upcamel}}StreamError { fn from(ae: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(ae) } } {{/function:stream_exceptions?}} {{^function:stream_exceptions?}} pub type {{function:upcamel}}StreamError = ::fbthrift::NonthrowingFunctionError; {{/function:stream_exceptions?}} impl ::std::convert::From<{{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn> for {{function:upcamel}}StreamError { fn from(e: {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn) -> Self { match e { {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn::ApplicationException(aexn) => {{function:upcamel}}StreamError::ApplicationException(aexn), {{#function:stream_exceptions}} {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn::{{field:rust_name}}(exn) => {{function:upcamel}}StreamError::{{field:rust_name}}(exn), {{/function:stream_exceptions}} } } } #[doc(hidden)] pub enum {{function:upcamel}}StreamReader {} impl ::fbthrift::help::DeserializeExn for {{function:upcamel}}StreamReader { type Success = {{#function:stream_elem_type}}{{>lib/type}}{{/function:stream_elem_type}}; type Error = {{function:upcamel}}StreamError; fn read_result

(p: &mut P) -> ::anyhow::Result<::std::result::Result> where P: ::fbthrift::ProtocolReader, { static RETURNS: &[::fbthrift::Field] = &[ {{#function:returns_by_name}} {{.}}, {{/function:returns_by_name}} ]; let _ = p.read_struct_begin(|_| ())?; let mut once = false; let mut alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?; match ((fty, fid as ::std::primitive::i32), once) { ((::fbthrift::TType::Stop, _), _) => { p.read_field_end()?; break; } (({{#function:stream_elem_type}}{{>lib/ttype}}{{/function:stream_elem_type}}, 0i32), false) => { once = true; alt = ::std::option::Option::Some(::std::result::Result::Ok(::fbthrift::Deserialize::read(p)?)); }{{! }}{{#function:stream_exceptions}} (({{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}), false) => { once = true; alt = ::std::option::Option::Some(::std::result::Result::Err(Self::Error::{{field:rust_name}}(::fbthrift::Deserialize::read(p)?))); }{{! }}{{/function:stream_exceptions}} ((ty, _id), false) => p.skip(ty)?, ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from( ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::ProtocolError, format!( "unwanted extra union {} field ty {:?} id {}", "{{function:upcamel}}StreamError", badty, badid, ), ) )), } p.read_field_end()?; } p.read_struct_end()?; alt.ok_or_else(|| ::fbthrift::ApplicationException::new( ::fbthrift::ApplicationExceptionErrorCode::MissingResult, format!("Empty union {}", "{{function:upcamel}}StreamError"), ) .into(), ) } } {{/function:stream?}} {{/function:starts_interaction?}} {{/service:rustFunctions}} } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/fieldtype.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:optional?}}::std::option::Option<{{/field:optional?}}{{! }}{{#field:box?}}::std::boxed::Box<{{/field:box?}}{{! }}{{#field:arc?}}::std::sync::Arc<{{/field:arc?}}{{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::AdaptedType{{/field:has_adapter?}}{{! }}{{^field:has_adapter?}}{{! }}{{#field:type}}{{! }}{{#field:type_annotation?}}{{>lib/annfieldtype}}{{/field:type_annotation?}}{{! }}{{^field:type_annotation?}}{{>lib/type}}{{/field:type_annotation?}}{{! }}{{/field:type}}{{! }}{{/field:has_adapter?}}{{! }}{{#field:arc?}}>{{/field:arc?}}{{! }}{{#field:box?}}>{{/field:box?}}{{! }}{{#field:optional?}}>{{/field:optional?}} )__FBTHRIFT_TAG__", // rust/lib/fieldvalue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#field:optional?}}::std::option::Option::Some({{/field:optional?}}{{! }}{{#field:box?}}::std::boxed::Box::new({{/field:box?}}{{! }}{{#field:arc?}}::std::sync::Arc::new({{/field:arc?}}{{! }}{{>lib/value}}{{! }}{{#field:arc?}}){{/field:arc?}}{{! }}{{#field:box?}}){{/field:box?}}{{! }}{{#field:optional?}}){{/field:optional?}} )__FBTHRIFT_TAG__", // rust/lib/function_stream_elem_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:return_type}}{{! }}{{#function:stream_elem_type}}{{! }}{{>lib/type}}{{! }}{{/function:stream_elem_type}}{{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // rust/lib/function_stream_first_response_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#function:return_type}}{{! }}{{#function:stream_first_response_type}}{{! }}{{>lib/type}}{{! }}{{/function:stream_first_response_type}}{{! }}{{/function:return_type}} )__FBTHRIFT_TAG__", // rust/lib/metadata/struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{! Annotations on generated patch structs implicitly assume all dependencies of `thrift/annotation/patch.thrift` are immediately available in the crate, e.g. they require a dependency on `thrift/annotation/cpp.thrift`. This might be fine in C++, but Rust crates have isolated dependencies, so this doesn't work for us. Disable generating annotations on patch structs for now. }}{{^struct:generated?}} impl ::fbthrift::metadata::ThriftAnnotations for {{struct:rust_name}} { fn get_structured_annotation() -> ::std::option::Option { {{! We can't use a match statement as `TypeId::of` must be const, which is blocked by https://github.com/rust-lang/rust/issues/77125. We assume there won't be a large number of annotations, so linear search should be fine here. }} #[allow(unused_variables)] let type_id = ::std::any::TypeId::of::(); {{#struct:rust_structured_annotations}} {{#structured_annotation:direct}} if type_id == ::std::any::TypeId::of::<{{#value:type}}{{>lib/type}}{{/value:type}}>() { let mut tmp = Some({{>lib/value}}); let r: &mut dyn ::std::any::Any = &mut tmp; let r: &mut Option = r.downcast_mut().unwrap(); return r.take(); } {{/structured_annotation:direct}} {{#structured_annotation:transitive?}} if let Some(r) = <{{>lib/type}} as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::() { return Some(r); } {{/structured_annotation:transitive?}} {{/struct:rust_structured_annotations}} None } fn get_field_structured_annotation(field_id: i16) -> ::std::option::Option { #[allow(unused_variables)] let type_id = ::std::any::TypeId::of::(); #[allow(clippy::match_single_binding)] match field_id { {{#struct:fields}} {{field:key}} => { {{#field:rust_structured_annotations}} {{#structured_annotation:direct}} if type_id == ::std::any::TypeId::of::<{{#value:type}}{{>lib/type}}{{/value:type}}>() { let mut tmp = Some({{>lib/value}}); let r: &mut dyn ::std::any::Any = &mut tmp; let r: &mut Option = r.downcast_mut().unwrap(); return r.take(); } {{/structured_annotation:direct}} {{#structured_annotation:transitive?}} if let Some(r) = <{{>lib/type}} as ::fbthrift::metadata::ThriftAnnotations>::get_structured_annotation::() { return Some(r); } {{/structured_annotation:transitive?}} {{/field:rust_structured_annotations}} }, {{/struct:fields}} _ => {} } None } } {{/struct:generated?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/method_names.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:extends?}}{{#service:extendedServers}}{{#extendedService:service}} {{>lib/method_names}} {{/extendedService:service}}{{/service:extendedServers}}{{/service:extends?}} {{^service:interaction?}} // from {{service:name}} {{#service:rustFunctions}}{{^function:starts_interaction?}} "{{function:name}}", {{/function:starts_interaction?}}{{/service:rustFunctions}} {{#service:interactions}}{{#service:rustFunctions}} "{{service:name}}.{{function:name}}", {{/service:rustFunctions}}{{/service:interactions}} {{/service:interaction?}} {{#service:interaction?}} // interaction's method names are never queried directly. // they are always queried from the "main" processor. {{/service:interaction?}} )__FBTHRIFT_TAG__", // rust/lib/mod.adapted_types.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} #[allow(dead_code)] mod adapted_types {{>lib/block}}{{! }}{{#program:structs}}{{#struct:has_adapter?}} pub type {{struct:rust_name}} = {{>lib/adapter/qualified}}::AdaptedType;{{! }}{{/struct:has_adapter?}}{{/program:structs}} } pub use self::adapted_types::*; {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/mod.adapters.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} /// Type aliases for the adapter used on an adapted typedef or struct. pub mod adapters { {{#program:adapters}} pub type {{type:rust_name}} = {{! }}{{#type:typedef}}{{! }}{{#typedef:has_adapter?}}{{>lib/adapter/name}}{{/typedef:has_adapter?}}{{! }}{{/type:typedef}}{{! }}{{^type:typedef}}{{! }}{{#type:struct}}{{! }}{{#struct:has_adapter?}}{{>lib/adapter/name}}{{/struct:has_adapter?}}{{! }}{{/type:struct}}{{! }}{{/type:typedef}}{{! }}; {{/program:adapters}} } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/mod.impl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} use ref_cast::RefCast; #[derive(RefCast)] #[repr(transparent)] pub(crate) struct LocalImpl(T); #[allow(unused)] pub(crate) fn write(value: &T, p: &mut P) where LocalImpl: ::fbthrift::Serialize

, P: ::fbthrift::ProtocolWriter, { ::fbthrift::Serialize::write(LocalImpl::ref_cast(value), p); } #[allow(unused)] pub(crate) fn read(p: &mut P) -> ::anyhow::Result where LocalImpl: ::fbthrift::Deserialize

, P: ::fbthrift::ProtocolReader, { let value: LocalImpl = ::fbthrift::Deserialize::read(p)?; ::std::result::Result::Ok(value.0) }{{! }}{{#program:nonstandardTypes}}{{! }}{{#type:set?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_set_begin( <{{#type:set_elem_type}}{{>lib/type}}{{/type:set_elem_type}} as ::fbthrift::GetTType>::TTYPE, self.0.len(), ); for v in &self.0 { p.write_set_value_begin(); {{#type:set_elem_type}}{{>lib/write}}{{/type:set_elem_type}}(v, p); } p.write_set_end(); } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { let (_elem_ty, len) = p.read_set_begin()?; let mut set = <{{>lib/type}}>::with_capacity(len.unwrap_or_default()); if let Some(0) = len { return Ok(LocalImpl(set)); } let mut idx = 0; loop { let more = p.read_set_value_begin()?; if !more { break; } {{#type:set_elem_type}}let v: {{>lib/type}} = {{>lib/read}}(p){{/type:set_elem_type}}?; p.read_set_value_end()?; set.insert(v); idx += 1; if ::fbthrift::protocol::should_break(len, more, idx) { break; } } p.read_set_end()?; ::std::result::Result::Ok(LocalImpl(set)) } }{{! }}{{/type:set?}}{{! }}{{#type:map?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_map_begin( <{{#type:key_type}}{{>lib/type}}{{/type:key_type}} as ::fbthrift::GetTType>::TTYPE, <{{#type:value_type}}{{>lib/type}}{{/type:value_type}} as ::fbthrift::GetTType>::TTYPE, self.0.len(), ); for (k, v) in &self.0 { p.write_map_key_begin(); {{#type:key_type}}{{>lib/write}}{{/type:key_type}}(k, p); p.write_map_value_begin(); {{#type:value_type}}{{>lib/write}}{{/type:value_type}}(v, p); } p.write_map_end(); } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { let (_key_ty, _val_ty, len) = p.read_map_begin()?; let mut map = <{{>lib/type}}>::with_capacity(len.unwrap_or_default()); if let Some(0) = len { return Ok(LocalImpl(map)); } let mut idx = 0; loop { let more = p.read_map_key_begin()?; if !more { break; } {{#type:key_type}}let k: {{>lib/type}} = {{>lib/read}}(p){{/type:key_type}}?; p.read_map_value_begin()?; {{#type:value_type}}let v: {{>lib/type}} = {{>lib/read}}(p){{/type:value_type}}?; p.read_map_value_end()?; map.insert(k, v); idx += 1; if ::fbthrift::protocol::should_break(len, more, idx) { break; } } p.read_map_end()?; ::std::result::Result::Ok(LocalImpl(map)) } }{{! }}{{/type:map?}}{{! }}{{#type:binary?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { self.0.as_slice().write(p) } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/rawtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { p.read_binary() } } impl ::fbthrift::binary_type::BinaryType for LocalImpl<{{>lib/rawtype}}> { fn with_capacity(capacity: usize) -> Self { LocalImpl(<{{>lib/rawtype}}>::with_capacity(capacity)) } fn extend_from_slice(&mut self, other: &[u8]) { self.0.extend_from_slice(other) } fn from_vec(vec: ::std::vec::Vec) -> Self { LocalImpl(::std::convert::Into::into(vec)) } }{{! }}{{/type:binary?}}{{! }}{{^typedef:newtype?}}{{#type:i64?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/type}}> where P: ::fbthrift::ProtocolWriter, {{>lib/type}}: ::fbthrift::Serialize

, { fn write(&self, p: &mut P) { self.0.write(p) } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/type}}> where P: ::fbthrift::ProtocolReader, {{>lib/type}}: ::fbthrift::Deserialize

, { fn read(p: &mut P) -> ::anyhow::Result { Ok(LocalImpl({{>lib/type}}::read(p)?)) } }{{! }}{{/type:i64?}}{{/typedef:newtype?}}{{! }}{{/program:nonstandardTypes}}{{! }}{{#program:nonstandardFields}}{{#field:type}}{{! }}{{#type:set?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_set_begin( <{{#type:set_elem_type}}{{>lib/type}}{{/type:set_elem_type}} as ::fbthrift::GetTType>::TTYPE, self.0.len(), ); for v in &self.0 { p.write_set_value_begin(); {{#type:set_elem_type}}{{>lib/write}}{{/type:set_elem_type}}(v, p); } p.write_set_end(); } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { let (_elem_ty, len) = p.read_set_begin()?; let mut set = <{{>lib/annfieldtype}}>::with_capacity(len.unwrap_or_default()); if let Some(0) = len { return Ok(LocalImpl(set)); } let mut idx = 0; loop { let more = p.read_set_value_begin()?; if !more { break; } {{#type:set_elem_type}}let v: {{>lib/type}} = {{>lib/read}}(p){{/type:set_elem_type}}?; p.read_set_value_end()?; set.insert(v); idx += 1; if ::fbthrift::protocol::should_break(len, more, idx) { break; } } p.read_set_end()?; ::std::result::Result::Ok(LocalImpl(set)) } }{{! }}{{/type:set?}}{{! }}{{#type:map?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_map_begin( <{{#type:key_type}}{{>lib/type}}{{/type:key_type}} as ::fbthrift::GetTType>::TTYPE, <{{#type:value_type}}{{>lib/type}}{{/type:value_type}} as ::fbthrift::GetTType>::TTYPE, self.0.len(), ); for (k, v) in &self.0 { p.write_map_key_begin(); {{#type:key_type}}{{>lib/write}}{{/type:key_type}}(k, p); p.write_map_value_begin(); {{#type:value_type}}{{>lib/write}}{{/type:value_type}}(v, p); } p.write_map_end(); } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { let (_key_ty, _val_ty, len) = p.read_map_begin()?; let mut map = <{{>lib/annfieldtype}}>::with_capacity(len.unwrap_or_default()); if let Some(0) = len { return Ok(LocalImpl(map)); } let mut idx = 0; loop { let more = p.read_map_key_begin()?; if !more { break; } {{#type:key_type}}let k: {{>lib/type}} = {{>lib/read}}(p){{/type:key_type}}?; p.read_map_value_begin()?; {{#type:value_type}}let v: {{>lib/type}} = {{>lib/read}}(p){{/type:value_type}}?; p.read_map_value_end()?; map.insert(k, v); idx += 1; if ::fbthrift::protocol::should_break(len, more, idx) { break; } } p.read_map_end()?; ::std::result::Result::Ok(LocalImpl(map)) } }{{! }}{{/type:map?}}{{! }}{{#type:binary?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { self.0.as_slice().write(p) } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { p.read_binary() } } impl ::fbthrift::binary_type::BinaryType for LocalImpl<{{>lib/annfieldtype}}> { fn with_capacity(capacity: usize) -> Self { LocalImpl(<{{>lib/annfieldtype}}>::with_capacity(capacity)) } fn extend_from_slice(&mut self, other: &[u8]) { self.0.extend_from_slice(other) } fn from_vec(vec: ::std::vec::Vec) -> Self { LocalImpl(::std::convert::Into::into(vec)) } }{{! }}{{/type:binary?}}{{! }}{{^typedef:newtype?}}{{#type:i64?}} impl

::fbthrift::Serialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolWriter, {{>lib/annfieldtype}}: ::fbthrift::Serialize

, { fn write(&self, p: &mut P) { self.0.write(p) } } impl

::fbthrift::Deserialize

for LocalImpl<{{>lib/annfieldtype}}> where P: ::fbthrift::ProtocolReader, {{>lib/annfieldtype}}: ::fbthrift::Deserialize

, { fn read(p: &mut P) -> ::anyhow::Result { Ok(LocalImpl({{>lib/annfieldtype}}::read(p)?)) } }{{! }}{{/type:i64?}}{{/typedef:newtype?}}{{! }}{{/field:type}}{{/program:nonstandardFields}} {{! newline}} )__FBTHRIFT_TAG__", // rust/lib/mod.unadapted.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} /// Contains the unadapted version of any adapted Thrift structs. pub mod unadapted { {{#program:adapted_structs}} {{>lib/struct}} {{>lib/structimpl}} {{/program:adapted_structs}} } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/rawtype.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==== If we ever add a type here which may not have a Send or Sync impl, the unsafe impls in structimpl.mustache need to be revisited. ==== }}{{#type:numeric_or_void?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}{{! }}{{#type:void?}}(){{/type:void?}}{{! }}{{#type:bool?}}::std::primitive::bool{{/type:bool?}}{{! }}{{#type:byte?}}::std::primitive::i8{{/type:byte?}}{{! }}{{#type:i16?}}::std::primitive::i16{{/type:i16?}}{{! }}{{#type:i32?}}::std::primitive::i32{{/type:i32?}}{{! }}{{#type:i64?}}::std::primitive::i64{{/type:i64?}}{{! }}{{#type:double?}}::std::primitive::f64{{/type:double?}}{{! }}{{#type:float?}}::std::primitive::f32{{/type:float?}}{{! }}{{/type:rust}}{{! }}{{/type:numeric_or_void?}}{{! }}{{#type:string?}}::std::string::String{{/type:string?}}{{! }}{{#type:binary?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::vec::Vec<::std::primitive::u8>{{/type:rust}}{{! }}{{/type:binary?}}{{! }}{{#type:struct}}{{! }}{{#struct:has_adapter?}}{{! }}{{struct:package}}::unadapted::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}{{struct:package}}::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{/type:struct}}{{! }}{{#type:enum}}{{! }}{{enum:package}}::{{enum:rust_name}}{{! }}{{/type:enum}}{{! }}{{#type:list?}}{{! }}::std::vec::Vec<{{#type:list_elem_type}}{{>lib/type}}{{/type:list_elem_type}}>{{! }}{{/type:list?}}{{! }}{{#type:set?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeSet{{/type:rust}}{{! }}<{{! }}{{#type:set_elem_type}}{{! }}{{#type:floating_point?}}::fbthrift::export::OrderedFloat<{{>lib/type}}>{{/type:floating_point?}}{{! }}{{^type:floating_point?}}{{>lib/type}}{{/type:floating_point?}}{{! }}{{/type:set_elem_type}}{{! }}>{{! }}{{/type:set?}}{{! }}{{#type:map?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeMap{{/type:rust}}{{! }}<{{! }}{{#type:key_type}}{{! }}{{#type:floating_point?}}::fbthrift::export::OrderedFloat<{{>lib/type}}>{{/type:floating_point?}}{{! }}{{^type:floating_point?}}{{>lib/type}}{{/type:floating_point?}}{{! }}{{/type:key_type}}, {{! }}{{#type:value_type}}{{>lib/type}}{{/type:value_type}}{{! }}>{{! }}{{/type:map?}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/read.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:nonstandard?}}{{program:crate}}::r#impl::read{{/type:nonstandard?}}{{! }}{{^type:nonstandard?}}::fbthrift::Deserialize::read{{/type:nonstandard?}} )__FBTHRIFT_TAG__", // rust/lib/return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==== If we ever add a type here which may not have a Send or Sync impl, the unsafe impls in structimpl.mustache need to be revisited. ==== }}{{>lib/type}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}{{! }}({{#function:stream_first_response_type}}{{>lib/type}}{{/function:stream_first_response_type}}, {{! }}{{/function:stream_has_first_response?}}{{! }}::futures::stream::BoxStream<'static, ::std::result::Result<{{! }}{{#function:stream_elem_type}}{{>lib/type}}{{/function:stream_elem_type}}, {{! }}{{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}StreamError{{! }}>>{{! }}{{#function:stream_has_first_response?}}{{! }}){{! }}{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}} )__FBTHRIFT_TAG__", // rust/lib/server.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:interactions}}{{>lib/server}} {{/service:interactions}} {{#service:docs?}} #[doc = {{service:docs}}] {{/service:docs?}} #[::async_trait::async_trait] pub trait {{service:rust_name}}: ::std::marker::Send + ::std::marker::Sync + 'static {{>lib/block}}{{! }}{{#service:requestContext?}} type RequestContext: ::std::marker::Sync;{{! }}{{/service:requestContext?}} {{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} {{#function:docs?}} #[doc = {{function:docs}}] {{/function:docs?}} async fn {{function:rust_name}}( &self,{{! }}{{#service:requestContext?}} _request_context: &Self::RequestContext,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} _{{field:name}}: {{#field:type}}{{>lib/type}}{{/field:type}},{{! }}{{/function:args}} ) -> {{>lib/server_return_type}} { ::std::result::Result::Err({{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn::ApplicationException( ::fbthrift::ApplicationException::unimplemented_method( "{{service:name}}", "{{function:name}}", ), )) } {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} {{#function:docs?}} #[doc = {{function:docs}}] {{/function:docs?}} fn {{function:rust_name}}( &self, ) -> ::anyhow::Result<::std::boxed::Box> { ::anyhow::bail!("{{service:name}}.{{function:name}} not implemented"); } {{/function:starts_interaction?}}{{/service:rustFunctions}} {{#service:interaction?}} async fn on_termination(&self) {} {{/service:interaction?}} } #[::async_trait::async_trait] impl {{service:rust_name}} for ::std::boxed::Box where T: {{service:rust_name}} + Send + Sync + ?Sized, {{>lib/block}} {{#service:requestContext?}} type RequestContext = T::RequestContext;{{! }}{{/service:requestContext?}} {{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} async fn {{function:rust_name}}( &self,{{! }}{{#service:requestContext?}} request_context: &Self::RequestContext,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} {{field:rust_name}}: {{#field:type}}{{>lib/type}}{{/field:type}},{{! }}{{/function:args}} ) -> {{>lib/server_return_type}} { (**self).{{function:rust_name}}({{! }}{{#service:requestContext?}} request_context,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} {{field:rust_name}},{{! }}{{/function:args}} ).await } {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:rust_name}}( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).{{function:rust_name}}() } {{/function:starts_interaction?}}{{/service:rustFunctions}} {{#service:interaction?}} async fn on_termination(&self) { (**self).on_termination().await; } {{/service:interaction?}} } #[::async_trait::async_trait] impl {{service:rust_name}} for ::std::sync::Arc where T: {{service:rust_name}} + Send + Sync + ?Sized, {{>lib/block}} {{#service:requestContext?}} type RequestContext = T::RequestContext;{{! }}{{/service:requestContext?}} {{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} async fn {{function:rust_name}}( &self,{{! }}{{#service:requestContext?}} request_context: &Self::RequestContext,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} {{field:rust_name}}: {{#field:type}}{{>lib/type}}{{/field:type}},{{! }}{{/function:args}} ) -> {{>lib/server_return_type}} { (**self).{{function:rust_name}}({{! }}{{#service:requestContext?}} request_context,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} {{field:rust_name}},{{! }}{{/function:args}} ).await } {{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:rust_name}}( &self, ) -> ::anyhow::Result<::std::boxed::Box> { (**self).{{function:rust_name}}() } {{/function:starts_interaction?}}{{/service:rustFunctions}} {{#service:interaction?}} async fn on_termination(&self) { (**self).on_termination().await; } {{/service:interaction?}} } /// Processor for {{service:rust_name}}'s methods. #[derive(Clone, Debug)] pub struct {{service:rust_name}}Processor { service: H,{{! }}{{#service:extends?}} supa: SS,{{! }}{{/service:extends?}}{{! }}{{^service:extends?}} supa: ::fbthrift::NullServiceProcessor,{{! }}{{/service:extends?}} _phantom: ::std::marker::PhantomData<(P, H, R, RS)>, } {{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} struct Args_{{service:rust_name}}_{{function:name}} { {{#function:args}} {{field:rust_name}}: {{>lib/fieldtype}}, {{/function:args}} } impl ::fbthrift::Deserialize

for self::Args_{{service:rust_name}}_{{function:name}} { #[inline]{{! No cost because there's only one caller; with luck will mitigate move cost of args. }} #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "{{service:name}}.{{function:name}}"))] fn read(p: &mut P) -> ::anyhow::Result { static ARGS: &[::fbthrift::Field] = &[ {{#function:args_by_name}} ::fbthrift::Field::new("{{field:name}}", {{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}), {{/function:args_by_name}} ]; {{#function:args}} let mut field_{{field:name}} = ::std::option::Option::None; {{/function:args}} 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,{{! }}{{#function:args}} ({{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}) => {{! }}field_{{field:name}} = ::std::option::Option::Some({{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_field::({{/field:has_adapter?}}{{! }}{{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldread}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/read}}{{/field:type_annotation?}}{{/field:type}}(p)?{{! }}{{#field:has_adapter?}}, {{field:key}})?{{/field:has_adapter?}}{{! }}),{{! }}{{/function:args}} (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; {{! Use formatting in errors to try to maximize string sharing }} ::std::result::Result::Ok(Self {{>lib/block}}{{! }}{{#function:args}} {{field:rust_name}}: field_{{field:name}}.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "{{service:name}}.{{function:name}}", "{{field:name}}"))?,{{! }}{{/function:args}} }) } } {{/function:sink?}}{{/function:starts_interaction?}}{{/service:rustFunctions}} impl {{service:rust_name}}Processor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Frame: ::std::marker::Send + 'static, P::Deserializer: ::std::marker::Send, H: {{service:rust_name}}{{! }}{{#service:requestContext?}}{{/service:requestContext?}}, 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,{{! }}{{#service:extends?}} SS: ::fbthrift::ThriftService, SS::Handler: {{>lib/super}}{{! }}{{/service:extends?}} { pub fn new({{! }}service: H{{! }}{{#service:extends?}}, supa: SS{{/service:extends?}}{{! }}) -> Self { Self { service, supa{{^service:extends?}}{{! }}: ::fbthrift::NullServiceProcessor::new(){{! }}{{/service:extends?}}, _phantom: ::std::marker::PhantomData, } } pub fn into_inner(self) -> H { self.service }{{! }}{{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} #[::tracing::instrument(skip_all, name = "handler", fields(method = "{{service:name}}.{{function:name}}"))] async fn handle_{{function:name}}<'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 = "{{service:parent_service_name}}"; METHOD_NAME = "{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}}"; SERVICE_METHOD_NAME = "{{service:parent_service_name}}.{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}}"; } 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_{{service:rust_name}}_{{function:name}} = ::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.{{function:rust_name}}({{! }}{{#service:requestContext?}} req_ctxt,{{! }}{{/service:requestContext?}}{{! }}{{#function:args}} _args.{{field:rust_name}},{{! }}{{/function:args}} ) ) .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 = "{{service:name}}.{{function:name}}", "success"); {{#function:creates_interaction?}} {{#function:return_type}}{{#type:void?}} let (interaction_handler, res) = (res, ()); {{/type:void?}}{{^type:void?}} let (interaction_handler, res) = res; {{/type:void?}}{{/function:return_type}} let interaction_processor = ::std::sync::Arc::new({{function:interaction_name}}Processor::, R, RS>::new(interaction_handler)); reply_state.set_interaction_processor(interaction_processor)?; {{/function:creates_interaction?}} ::std::result::Result::Ok(res) } ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { {{!TODO: Remove this once debug for stream is implemented.}} {{^function:stream?}} ::tracing::info!(method = "{{service:name}}.{{function:name}}", exception = ?exn); {{/function:stream?}} ::std::result::Result::Err(exn) } ::std::result::Result::Err(exn) => { let aexn = ::fbthrift::ApplicationException::handler_panic("{{service:name}}.{{function:name}}", exn); ::tracing::error!(method = "{{service:name}}.{{function:name}}", panic = ?aexn); ::std::result::Result::Err({{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn::ApplicationException(aexn)) } }; {{^function:stream?}} let env = ::fbthrift::help::serialize_result_envelope::( "{{function:name}}", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, res, )?; reply_state.send_reply(env); Ok(()) {{/function:stream?}} {{#function:stream?}} use ::futures::StreamExt as _; let (response, stream) = match res { ::std::result::Result::Ok(res) => { {{#function:stream_has_first_response?}} let (response, stream) = res; let response = ::std::result::Result::Ok(response); {{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}} let response = ::std::result::Result::Ok(()); let stream = res; {{/function:stream_has_first_response?}} let stream = ::std::panic::AssertUnwindSafe(stream) .catch_unwind() .map(|item| { match item { ::std::result::Result::Ok(::std::result::Result::Ok(success)) => { let payload = ::fbthrift::help::serialize_stream_item::( ::std::result::Result::Ok(success), ); ::fbthrift::SerializedStreamElement::Success(payload) } ::std::result::Result::Ok(::std::result::Result::Err({{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn::ApplicationException(aexn))) => { tracing::info!(?aexn, method="{{service:name}}.{{function:name}}", "Streaming ApplicationException"); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } {{#function:stream_exceptions?}} ::std::result::Result::Ok(::std::result::Result::Err(exn)) => { tracing::debug!(?exn, method="{{service:name}}.{{function:name}}", "Streaming declared exception"); let payload = ::fbthrift::help::serialize_stream_item::( ::std::result::Resu)__FBTHRIFT_TAG__" /* stitch */ R"__FBTHRIFT_TAG__(lt::Err(exn), ); ::fbthrift::SerializedStreamElement::DeclaredException(payload) } {{/function:stream_exceptions?}} ::std::result::Result::Err(exn) => { tracing::error!(?exn, method="{{service:name}}.{{function:name}}", "Streaming unwind"); let aexn = ::fbthrift::ApplicationException::handler_panic("{{service:name}}.{{function:name}}", exn); ::fbthrift::SerializedStreamElement::ApplicationException(aexn) } } }) {{!TODO(T125947234): should we instrument with tracing?}} .boxed(); (response, Some(stream)) }, ::std::result::Result::Err(exn) => (::std::result::Result::Err(exn), None), }; let response = ::fbthrift::help::serialize_result_envelope::( "{{function:name}}", METHOD_NAME.as_cstr(), _seqid, req_ctxt, &mut ctx_stack, response, )?; let _ = reply_state.send_stream_reply(response, stream, P::PROTOCOL_ID); Ok(()) {{/function:stream?}} }{{! }}{{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn handle_{{function:name}}( &self, ) -> ::anyhow::Result<::std::boxed::Box> { self.service.{{function:rust_name}}() }{{! }}{{/function:starts_interaction?}}{{! }}{{/service:rustFunctions}} } #[::async_trait::async_trait] impl ::fbthrift::ServiceProcessor

for {{service:rust_name}}Processor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, H: {{service:rust_name}}{{! }}{{#service:requestContext?}}{{/service:requestContext?}},{{! }}{{#service:extends?}} SS: ::fbthrift::ThriftService, SS::Handler: {{>lib/super}},{{! }}{{/service:extends?}} 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 {{>lib/block}}{{! }}{{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} b"{{#service:interaction?}}{{service:name}}.{{/service:interaction?}}{{function:name}}" => ::std::result::Result::Ok({{function:index}}usize),{{! }}{{/function:sink?}}{{/function:starts_interaction?}}{{/service:rustFunctions}} _ => ::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 {{>lib/block}}{{! }}{{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}} {{function:index}}usize => { self.handle_{{function:name}}(_p, _req, _req_ctxt, _reply_state, _seqid).await }{{! }}{{/function:sink?}}{{/function:starts_interaction?}}{{/service:rustFunctions}} bad => panic!( "{}: unexpected method idx {}", "{{service:rust_name}}Processor", bad ), } } #[allow(clippy::match_single_binding)] #[inline] fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> { match name {{>lib/block}}{{! }}{{#service:rustFunctions}}{{#function:starts_interaction?}} "{{function:interaction_name}}" => ::std::result::Result::Ok({{function:index}}usize),{{! }}{{/function:starts_interaction?}}{{/service:rustFunctions}} _ => ::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 {{>lib/block}}{{! }}{{#service:rustFunctions}}{{#function:starts_interaction?}} {{function:index}}usize => { let handler = self.handle_{{function:name}}()?; let server = ::std::sync::Arc::new({{function:interaction_name}}Processor::, R, RS>::new(handler)); Ok(server) }{{! }}{{/function:starts_interaction?}}{{/service:rustFunctions}} bad => panic!( "{}: unexpected method idx {}", "{{service:rust_name}}Processor", bad ), } } async fn handle_on_termination(&self) { {{#service:interaction?}} self.service.on_termination().await {{/service:interaction?}} } } #[::async_trait::async_trait] impl ::fbthrift::ThriftService for {{service:rust_name}}Processor where P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static, P::Deserializer: ::std::marker::Send, P::Frame: ::std::marker::Send + 'static, H: {{service:rust_name}}{{! }}{{#service:requestContext?}}{{/service:requestContext?}},{{! }}{{#service:extends?}} SS: ::fbthrift::ThriftService, SS::Handler: {{>lib/super}}, P::Frame: ::std::marker::Send + 'static,{{! }}{{/service:extends?}} 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, { {{#service:interaction?}} // Interactions have () as their handler associated type // to make `create_interaction` have a common return type. type Handler = (); {{/service:interaction?}}{{^service:interaction?}} type Handler = H; {{/service:interaction?}} type RequestContext = R; type ReplyState = RS; #[tracing::instrument(level="trace", skip_all, fields(service = "{{service:name}}"))] 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] { &[ {{>lib/method_names}} ] } async fn on_termination(&self) { use ::fbthrift::{ServiceProcessor as _}; self.handle_on_termination().await } } {{^service:interaction?}} /// Construct a new instance of a {{service:rust_name}} 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_{{service:rust_name}}_server( proto: ::fbthrift::ProtocolID, handler: H,{{! }}{{#service:extends?}} supa: SMAKE,{{! }}{{/service:extends?}} ) -> ::std::result::Result<::std::boxed::Box + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException> where F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static, H: {{service:rust_name}}{{! }}{{#service:requestContext?}}{{/service:requestContext?}},{{! }}{{#service:extends?}} SMAKE: ::std::ops::FnOnce(::fbthrift::ProtocolID) -> ::std::result::Result, SS: ::fbthrift::ThriftService, SS::Handler: {{>lib/super}},{{! }}{{/service:extends?}} 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({{service:rust_name}}Processor::<::fbthrift::BinaryProtocol, H, R, RS{{! }}{{#service:extends?}}, SS{{/service:extends?}}{{! }}>::new(handler{{! }}{{#service:extends?}}, supa(proto)?{{/service:extends?}}{{! }}))) } ::fbthrift::ProtocolID::CompactProtocol => { ::std::result::Result::Ok(::std::boxed::Box::new({{service:rust_name}}Processor::<::fbthrift::CompactProtocol, H, R, RS{{! }}{{#service:extends?}}, SS{{/service:extends?}}{{! }}>::new(handler{{! }}{{#service:extends?}}, supa(proto)?{{/service:extends?}}{{! }}))) } bad => { ::tracing::error!(method = "{{service:name}}.{{function:name}}", invalid_protocol = ?bad); ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)) } } } {{/service:interaction?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/server_errors.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} #[doc(inline)] pub use {{program:types}}::services::{{service:snake}}; #[doc(inline)] #[allow(ambiguous_glob_reexports)] pub use {{program:types}}::services::{{service:snake}}::*; )__FBTHRIFT_TAG__", // rust/lib/server_ok_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}{{#function:stream?}} {{#function:stream_has_first_response?}} ( {{#function:return_type}}{{#function:stream_first_response_type}}{{>lib/type}}{{/function:stream_first_response_type}}{{/function:return_type}}, {{/function:stream_has_first_response?}} ::futures::stream::BoxStream<'static, ::std::result::Result<{{#function:stream_elem_type}}{{>lib/type}}{{/function:stream_elem_type}}, {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}StreamExn>> {{#function:stream_has_first_response?}} ) {{/function:stream_has_first_response?}} {{/function:stream?}} {{^function:stream?}}{{^function:sink?}} {{#function:return_type}}{{>lib/return_type}}{{/function:return_type}} {{/function:sink?}}{{/function:stream?}} )__FBTHRIFT_TAG__", // rust/lib/server_return_type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{! }}::std::result::Result<{{! }}{{#function:return_type}}{{! }}{{#function:creates_interaction?}}{{! }}{{#type:void?}}{{! }}::std::boxed::Box{{! }}{{/type:void?}}{{^type:void?}}{{! }}(::std::boxed::Box, {{>lib/server_ok_type}}){{! }}{{/type:void?}}{{! }}{{/function:creates_interaction?}}{{^function:creates_interaction?}}{{! }}{{>lib/server_ok_type}}{{! }}{{/function:creates_interaction?}}{{! }}{{/function:return_type}}{{! }}, {{program:crate}}::services::{{service:snake}}::{{function:upcamel}}Exn{{! }}> )__FBTHRIFT_TAG__", // rust/lib/service.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#service:interactions}}{{>lib/service}} {{/service:interactions}} /// Service definitions for `{{service:rust_name}}`. pub mod {{service:snake}} {{>lib/block}}{{! }}{{#service:docs?}} #![doc = {{service:docs}}] {{/service:docs?}}{{! }}{{#service:rustFunctions}}{{^function:starts_interaction?}}{{^function:sink?}}{{#function:stream?}} #[derive(Clone, Debug)] pub enum {{function:upcamel}}StreamExn { {{#function:stream_exceptions}} {{field:rust_name}}({{#field:type}}{{>lib/type}}{{/field:type}}),{{! }}{{/function:stream_exceptions}} ApplicationException(::fbthrift::ApplicationException), } impl ::fbthrift::ExceptionInfo for {{function:upcamel}}StreamExn { fn exn_name(&self) -> &'static str { match self { Self::ApplicationException(aexn) => aexn.exn_name(), {{#function:stream_exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_name(), {{/function:stream_exceptions}} } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), {{#function:stream_exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_value(), {{/function:stream_exceptions}} } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), {{#function:stream_exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_is_declared(), {{/function:stream_exceptions}} } } } impl ::fbthrift::ResultInfo for {{function:upcamel}}StreamExn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, {{#function:stream_exceptions}} Self::{{field:rust_name}}(_exn) => fbthrift::ResultType::Error, {{/function:stream_exceptions}} } } }{{! }}{{#function:uniqueStreamExceptions}} impl ::std::convert::From<{{#field:type}}{{>lib/type}}{{/field:type}}> for {{function:upcamel}}StreamExn { fn from(exn: {{#field:type}}{{>lib/type}}{{/field:type}}) -> Self { Self::{{field:rust_name}}(exn) } }{{! }}{{/function:uniqueStreamExceptions}} impl ::std::convert::From<::fbthrift::ApplicationException> for {{function:upcamel}}StreamExn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } {{#function:enable_anyhow_to_application_exn}} impl ::std::convert::From<::anyhow::Error> for {{function:upcamel}}StreamExn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } {{/function:enable_anyhow_to_application_exn}} impl

::fbthrift::Serialize

for {{function:upcamel}}StreamExn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for {{function:upcamel}}StreamExn { type Success = {{#function:stream_elem_type}}{{>lib/type}}{{/function:stream_elem_type}}; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("{{function:upcamel}}"); match res { ::std::result::Result::Ok(success) => { p.write_field_begin( "Success", {{#function:stream_elem_type}}{{>lib/ttype}}{{/function:stream_elem_type}}, 0i16, ); ::fbthrift::Serialize::write(success, p); p.write_field_end(); } {{#function:stream_exceptions}} ::std::result::Result::Err(Self::{{field:rust_name}}(inner)) => { p.write_field_begin( "{{field:name}}", {{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}, ); ::fbthrift::Serialize::write(inner, p); p.write_field_end(); }{{! }}{{/function:stream_exceptions}} ::std::result::Result::Err(Self::ApplicationException(_)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } {{/function:stream?}} #[derive(Clone, Debug)] pub enum {{function:upcamel}}Exn { {{#function:exceptions}} {{field:rust_name}}({{#field:type}}{{>lib/type}}{{/field:type}}),{{! }}{{/function:exceptions}} ApplicationException(::fbthrift::ApplicationException), }{{! }}{{#function:uniqueExceptions}} impl ::std::convert::From<{{#field:type}}{{>lib/type}}{{/field:type}}> for {{function:upcamel}}Exn { fn from(exn: {{#field:type}}{{>lib/type}}{{/field:type}}) -> Self { Self::{{field:rust_name}}(exn) } }{{! }}{{/function:uniqueExceptions}} {{#function:enable_anyhow_to_application_exn}} impl ::std::convert::From<::anyhow::Error> for {{function:upcamel}}Exn { fn from(exn: ::anyhow::Error) -> Self { Self::ApplicationException( ::fbthrift::ApplicationException { message: format!("{exn:#}"), type_: ::fbthrift::ApplicationExceptionErrorCode::Unknown, } ) } } {{/function:enable_anyhow_to_application_exn}} impl ::std::convert::From<{{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error> for {{function:upcamel}}Exn { fn from(err: {{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error) -> Self { match err { {{#function:exceptions}} {{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error::{{field:rust_name}}(err) => {{function:upcamel}}Exn::{{field:rust_name}}(err), {{/function:exceptions}} {{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error::ApplicationException(aexn) => {{function:upcamel}}Exn::ApplicationException(aexn), {{program:crate}}::errors::{{service:snake}}::{{function:upcamel}}Error::ThriftError(err) => {{function:upcamel}}Exn::ApplicationException(::fbthrift::ApplicationException { message: err.to_string(), type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError, }), } } } impl ::std::convert::From<::fbthrift::ApplicationException> for {{function:upcamel}}Exn { fn from(exn: ::fbthrift::ApplicationException) -> Self { Self::ApplicationException(exn) } } impl ::fbthrift::ExceptionInfo for {{function:upcamel}}Exn { fn exn_name(&self) -> &'static str { match self { Self::ApplicationException(aexn) => aexn.exn_name(), {{#function:exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_name(), {{/function:exceptions}} } } fn exn_value(&self) -> String { match self { Self::ApplicationException(aexn) => aexn.exn_value(), {{#function:exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_value(), {{/function:exceptions}} } } fn exn_is_declared(&self) -> bool { match self { Self::ApplicationException(aexn) => aexn.exn_is_declared(), {{#function:exceptions}} Self::{{field:rust_name}}(exn) => exn.exn_is_declared(), {{/function:exceptions}} } } } impl ::fbthrift::ResultInfo for {{function:upcamel}}Exn { fn result_type(&self) -> ::fbthrift::ResultType { match self { Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception, {{#function:exceptions}} Self::{{field:rust_name}}(_exn) => fbthrift::ResultType::Error, {{/function:exceptions}} } } } impl

::fbthrift::Serialize

for {{function:upcamel}}Exn where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { ::fbthrift::help::SerializeExn::write_result(Err(self), p); } } impl ::fbthrift::help::SerializeExn for {{function:upcamel}}Exn { type Success = {{! }}{{^function:stream?}}{{>lib/server_ok_type}}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}{{! }}{{#function:return_type}}{{#function:stream_first_response_type}}{{>lib/type}}{{/function:stream_first_response_type}}{{/function:return_type}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}(){{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}; fn write_result

(res: ::std::result::Result<&Self::Success, &Self>, p: &mut P) where P: ::fbthrift::ProtocolWriter, { if let ::std::result::Result::Err(Self::ApplicationException(aexn)) = res { ::fbthrift::Serialize::write(aexn, p); return; } p.write_struct_begin("{{function:upcamel}}"); match res { ::std::result::Result::Ok(_success) => { p.write_field_begin("Success", {{! }}{{^function:stream?}}{{! }}{{#function:return_type}}{{>lib/ttype}}{{/function:return_type}}{{! }}{{/function:stream?}}{{! }}{{#function:stream?}}{{! }}{{#function:stream_has_first_response?}}{{! }}{{#function:return_type}}{{#function:stream_first_response_type}}{{>lib/ttype}}{{/function:stream_first_response_type}}{{/function:return_type}}{{! }}{{/function:stream_has_first_response?}}{{! }}{{^function:stream_has_first_response?}}::fbthrift::TType::Void{{/function:stream_has_first_response?}}{{! }}{{/function:stream?}}{{! }}, 0i16); {{^function:stream?}} ::fbthrift::Serialize::write({{#function:return_type}}{{! }}{{#type:has_adapter?}}{{! }}&{{>lib/adapter/qualified}}::to_thrift_field::<::fbthrift::metadata::NoThriftAnnotations>(_success, 0){{! }}{{/type:has_adapter?}}{{! }}{{^type:has_adapter?}}_success{{/type:has_adapter?}}{{! }}{{/function:return_type}}, p); {{/function:stream?}} {{#function:stream?}}{{#function:stream_has_first_response?}} ::fbthrift::Serialize::write(_success, p); {{/function:stream_has_first_response?}}{{/function:stream?}} p.write_field_end(); } {{#function:exceptions}} ::std::result::Result::Err(Self::{{field:rust_name}}(inner)) => { p.write_field_begin( "{{field:name}}", {{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}, ); ::fbthrift::Serialize::write(inner, p); p.write_field_end(); }{{! }}{{/function:exceptions}} ::std::result::Result::Err(Self::ApplicationException(_aexn)) => unreachable!(), } p.write_field_stop(); p.write_struct_end(); } } {{/function:sink?}}{{/function:starts_interaction?}}{{/service:rustFunctions}} } {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/struct.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} #[derive({{! }}{{#struct:copy?}}Copy, {{/struct:copy?}}{{! }}Clone, PartialEq{{! }}{{#struct:ord?}}, Eq, PartialOrd, Ord, Hash{{/struct:ord?}}{{! }}{{#struct:union?}}, Debug{{/struct:union?}}{{! }}{{#struct:serde?}}, ::serde_derive::Serialize, ::serde_derive::Deserialize{{/struct:serde?}}{{! }}{{#struct:exception?}}{{#struct:union?}}, ::thiserror::Error{{/struct:union?}}{{/struct:exception?}}{{! }}{{#struct:derive}}, {{.}}{{/struct:derive}}{{! }})] {{#struct:docs?}} #[doc = {{struct:docs}}] {{/struct:docs?}}{{! }}{{^struct:union?}} pub struct {{struct:rust_name}} {{>lib/block}}{{! }}{{#struct:fields}}{{! }}{{#struct:serde?}}{{#field:rename?}} #[serde(rename = "{{field:name}}")]{{! }}{{/field:rename?}}{{^field:optional?}} #[serde(default)]{{! }}{{/field:optional?}}{{! }}{{#field:optional?}}{{#struct:serde?}}{{#program:skip_none_serialization?}} #[serde(skip_serializing_if = "Option::is_none")]{{! }}{{/program:skip_none_serialization?}}{{/struct:serde?}}{{/field:optional?}}{{! }}{{/struct:serde?}}{{#field:docs?}} #[doc = {{field:docs}}]{{! }}{{/field:docs?}} pub {{field:rust_name}}: {{>lib/fieldtype}},{{! }}{{/struct:fields}}{{! }}{{^struct:exhaustive?}} // This field forces `..Default::default()` when instantiating this // struct, to make code future-proof against new fields added later to // the definition in Thrift. If you don't want this, add the annotation // `@rust.Exhaustive` to the Thrift struct to eliminate this field. #[doc(hidden)]{{! }}{{#struct:serde?}} #[serde(skip, default = "self::dot_dot::default_for_serde_deserialize")]{{! }}{{/struct:serde?}} pub _dot_dot_Default_default: {{! }}{{#struct:has_adapter?}}{{! }}super::dot_dot::OtherFields,{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}self::dot_dot::OtherFields,{{! }}{{/struct:has_adapter?}}{{! }}{{/struct:exhaustive?}} } {{#struct:exception?}} impl ::fbthrift::ExceptionInfo for {{struct:rust_name}} { fn exn_value(&self) -> String { format!("{:?}", self) } #[inline] fn exn_is_declared(&self) -> bool { true } } impl ::std::error::Error for {{struct:rust_name}} {} impl ::std::fmt::Display for {{struct:rust_name}} {{>lib/block}} fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { {{#struct:exception?}} write!(f, {{! }}{{#struct:has_exception_message?}}{{! }}{{#struct:is_exception_message_optional?}}{{! }}"{{struct:rust_name}}: {:?}", self.{{struct:exception_message}}{{! }}{{/struct:is_exception_message_optional?}}{{! }}{{^struct:is_exception_message_optional?}}{{! }}"{{struct:rust_name}}: {}", self.{{struct:exception_message}}{{! }}{{/struct:is_exception_message_optional?}}{{! }}{{/struct:has_exception_message?}}{{! }}{{^struct:has_exception_message?}}{{! }}"{:?}", self{{! }}{{/struct:has_exception_message?}}{{! }}) {{/struct:exception?}} {{^struct:exception?}} write!(f, "{:?}", self) {{/struct:exception?}} } } {{/struct:exception?}} {{/struct:union?}} {{#struct:union?}} pub enum {{struct:rust_name}} {{>lib/block}}{{! }}{{#struct:fields}} {{#field:docs?}} #[doc = {{field:docs}}] {{/field:docs?}} {{#struct:exception?}} #[error("{0:?}")] {{/struct:exception?}} {{field:rust_name}}({{>lib/fieldtype}}),{{! }}{{/struct:fields}} UnknownField(::std::primitive::i32), } {{/struct:union?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/structimpl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{^struct:union?}} #[allow(clippy::derivable_impls)] impl ::std::default::Default for self::{{struct:rust_name}} { fn default() -> Self { Self {{>lib/block}}{{! }}{{#struct:fields}} {{field:rust_name}}: {{! }}{{#field:default}}{{! }}{{#field:optional?}}{{! }}{{#program:deprecated_optional_with_default_is_some?}}{{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_default::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}{{>lib/fieldvalue}}{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}{{/program:deprecated_optional_with_default_is_some?}}{{! }}{{^program:deprecated_optional_with_default_is_some?}}{{! }}::std::option::Option::None{{! }}{{/program:deprecated_optional_with_default_is_some?}}{{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_default::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}{{>lib/fieldvalue}}{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}{{/field:optional?}}{{! }}{{/field:default}}{{! }}{{^field:default}}{{! }}{{#field:optional?}}{{! }}::std::option::Option::None{{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_default::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}::std::default::Default::default(){{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}{{/field:optional?}}{{! }}{{/field:default}}{{! }},{{! }}{{/struct:fields}} {{>lib/structvalue_epilogue}} } } } impl ::std::fmt::Debug for self::{{struct:rust_name}} { fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { formatter .debug_struct("{{struct:rust_name}}"){{! }}{{#struct:fields}} .field("{{field:rust_name}}", &self.{{field:rust_name}}){{! }}{{/struct:fields}} .finish() } } {{! Avoid needing to raise the recursion_limit for the trait solver to figure out autotrait impls for deeply nested data structures. These unsafe impls are fine because all possible field types we allow (primitives, string, vec, maps, sets) are Send and Sync and Unpin. }} unsafe impl ::std::marker::Send for self::{{struct:rust_name}} {} unsafe impl ::std::marker::Sync for self::{{struct:rust_name}} {} impl ::std::marker::Unpin for self::{{struct:rust_name}} {} impl ::std::panic::RefUnwindSafe for self::{{struct:rust_name}} {} impl ::std::panic::UnwindSafe for self::{{struct:rust_name}} {} impl ::fbthrift::GetTType for self::{{struct:rust_name}} { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } {{!newline}} {{#struct:thrift_uri}} impl ::fbthrift::GetUri for self::{{struct:rust_name}} { fn uri() -> &'static str { "{{struct:thrift_uri}}" } } {{/struct:thrift_uri}} impl

::fbthrift::Serialize

for self::{{struct:rust_name}} where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_struct_begin("{{struct:name}}");{{! }}{{#struct:fields}}{{! }}{{#field:optional?}} if let ::std::option::Option::Some(some) = &self.{{field:rust_name}} { p.write_field_begin({{! }}"{{field:name}}", {{! }}{{#field:type}}{{>lib/ttype}}{{/field:type}}, {{! }}{{field:key}}{{! }}); {{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldwrite}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/write}}{{/field:type_annotation?}}{{/field:type}}({{! }}{{#field:has_adapter?}}&{{>lib/adapter/qualified}}::to_thrift_field::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}some{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}, p); p.write_field_end(); }{{! }}{{/field:optional?}}{{! }}{{^field:optional?}} p.write_field_begin({{! }}"{{field:name}}", {{! }}{{#field:type}}{{>lib/ttype}}{{/field:type}}, {{! }}{{field:key}}{{! }}); {{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldwrite}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/write}}{{/field:type_annotation?}}{{/field:type}}({{! }}{{#field:has_adapter?}}&{{>lib/adapter/qualified}}::to_thrift_field::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}&self.{{field:rust_name}}{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}, p); p.write_field_end();{{! }}{{/field:optional?}}{{! }}{{/struct:fields}} p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for self::{{struct:rust_name}} where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static FIELDS: &[::fbthrift::Field] = &[ {{#struct:fields_by_name}} ::fbthrift::Field::new("{{field:name}}", {{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}), {{/struct:fields_by_name}} ]; {{#struct:fields}} let mut field_{{field:name}} = ::std::option::Option::None; {{/struct:fields}} let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a {{struct:name}}")?; loop { let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; match (fty, fid as ::std::primitive::i32) { (::fbthrift::TType::Stop, _) => break,{{! }}{{#struct:fields}} ({{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}) => {{! }}field_{{field:name}} = ::std::option::Option::Some({{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_field::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}{{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldread}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/read}}{{/field:type_annotation?}}{{/field:type}}(p)?{{! }}{{#field:has_adapter?}}, {{field:key}})?{{/field:has_adapter?}}{{! }}),{{! }}{{/struct:fields}} (fty, _) => p.skip(fty)?, } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(Self {{>lib/block}}{{! }}{{#struct:fields}} {{field:rust_name}}: field_{{field:name}}{{! }}{{^field:optional?}}{{! }}{{#field:has_adapter?}}{{! }}.unwrap_or_else(|| {{>lib/adapter/qualified}}::from_thrift_default::<{{struct:rust_name}}>({{! }}{{#field:default}}{{>lib/value}}{{/field:default}}{{! }}{{^field:default}}::std::default::Default::default(){{/field:default}}{{! }}, {{field:key}})){{! }}{{/field:has_adapter?}}{{! }}{{^field:has_adapter?}}{{! }}{{#field:default}}{{! }}{{#value:simpleLiteral?}}{{! }}.unwrap_or({{>lib/value}}){{! }}{{/value:simpleLiteral?}}{{! }}{{^value:simpleLiteral?}}{{! }}.unwrap_or_else(|| {{>lib/value}}){{! }}{{/value:simpleLiteral?}}{{! }}{{/field:default}}{{! }}{{^field:default}}{{! }}.unwrap_or_default(){{! }}{{/field:default}}{{! }}{{/field:has_adapter?}}{{! }}{{/field:optional?}}{{! }},{{! }}{{/struct:fields}} {{>lib/structvalue_epilogue}} }) } } {{#program:rust_gen_native_metadata?}} {{>lib/metadata/struct}} {{/program:rust_gen_native_metadata?}} {{/struct:union?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/structvalue_epilogue.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{^struct:exhaustive?}}{{! }}_dot_dot_Default_default: {{! }}{{#struct:has_adapter?}}{{! }}super::dot_dot::OtherFields(()),{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}self::dot_dot::OtherFields(()),{{! }}{{/struct:has_adapter?}}{{! }}{{/struct:exhaustive?}} )__FBTHRIFT_TAG__", // rust/lib/super.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#service:extends}}{{! }}{{service:server_package}}::{{service:rust_name}}{{! }}{{#service:requestContext?}}{{/service:requestContext?}}{{! }}{{/service:extends}} )__FBTHRIFT_TAG__", // rust/lib/ttype.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:typedef_type}}{{>lib/ttype}}{{/type:typedef_type}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}::fbthrift::TType::{{! }}{{#type:void?}}Void{{/type:void?}}{{! }}{{#type:string?}}String{{/type:string?}}{{! }}{{#type:binary?}}String{{/type:binary?}}{{! }}{{#type:bool?}}Bool{{/type:bool?}}{{! }}{{#type:byte?}}Byte{{/type:byte?}}{{! }}{{#type:i16?}}I16{{/type:i16?}}{{! }}{{#type:i32?}}I32{{/type:i32?}}{{! }}{{#type:i64?}}I64{{/type:i64?}}{{! }}{{#type:double?}}Double{{/type:double?}}{{! }}{{#type:float?}}Float{{/type:float?}}{{! }}{{#type:struct}}Struct{{/type:struct}}{{! }}{{#type:enum?}}I32{{/type:enum?}}{{! }}{{#type:list?}}List{{/type:list?}}{{! }}{{#type:set?}}Set{{/type:set?}}{{! }}{{#type:map?}}Map{{/type:map?}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/type.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:typedef?}}{{! }}{{#type:type_annotation?}}{{>lib/rawtype}}{{/type:type_annotation?}}{{! }}{{^type:type_annotation?}}{{type:package}}::{{type:rust_name}}{{/type:type_annotation?}}{{! }}{{/type:typedef?}}{{! }}{{^type:typedef?}}{{! }}{{>lib/rawtype}}{{! }}{{/type:typedef?}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/typedef.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#typedef:docs?}} #[doc = {{typedef:docs}}] {{/typedef:docs?}}{{! }}{{^typedef:newtype?}}{{! }}{{#typedef:has_adapter?}} pub type {{typedef:rust_name}} = {{! }}{{#adapter:transitive_only?}}{{! }}{{#adapter:underlying_type}}{{>lib/type}}{{/adapter:underlying_type}}{{! }}{{/adapter:transitive_only?}}{{! }}{{^adapter:transitive_only?}}{{! }}{{>lib/adapter/qualified}}::AdaptedType{{! }}{{/adapter:transitive_only?}}; {{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}{{#typedef:type}}{{! }}{{#type:enum}} pub use {{type:package}}::{{type:rust_name}} as {{typedef:rust_name}}; {{/type:enum}}{{! }}{{^type:enum}} pub type {{typedef:rust_name}} = {{>lib/type}}; {{/type:enum}}{{! }}{{/typedef:type}}{{! }}{{/typedef:has_adapter?}}{{! }}{{/typedef:newtype?}}{{! }}{{#typedef:newtype?}} #[derive({{! }}{{^typedef:has_adapter?}}{{! }}Default, {{! }}{{/typedef:has_adapter?}}{{! }}{{#typedef:copy?}}Copy, {{/typedef:copy?}}{{! }}Clone, Debug, PartialEq{{! }}{{#typedef:ord?}}, Eq, PartialOrd, Ord, Hash{{/typedef:ord?}}{{! }}{{#typedef:serde?}}, ::serde_derive::Serialize, ::serde_derive::Deserialize{{/typedef:serde?}}{{! }})] pub struct {{typedef:rust_name}}(pub {{! }}{{#typedef:has_adapter?}}{{! }}{{>lib/adapter/qualified}}::AdaptedType{{! }}{{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}{{#typedef:rust_type}}::{{typedef:rust_type}}{{/typedef:rust_type}}{{! }}{{^typedef:rust_type}}{{#typedef:type}}{{>lib/type}}{{/typedef:type}}{{/typedef:rust_type}}{{! }}{{/typedef:has_adapter?}}{{! }}); {{/typedef:newtype?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/typedefimpl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#typedef:newtype?}} impl ::fbthrift::GetTType for {{typedef:rust_name}} { const TTYPE: ::fbthrift::TType = {{! }}{{#typedef:has_adapter?}}{{! }}<{{>lib/adapter/qualified}}::StandardType as ::fbthrift::GetTType>::TTYPE{{! }}{{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}<{{#typedef:type}}{{>lib/type}}{{/typedef:type}} as ::fbthrift::GetTType>::TTYPE{{! }}{{/typedef:has_adapter?}}{{! }}; } {{#typedef:nonstandard?}} impl

::fbthrift::Serialize

for {{typedef:rust_name}} where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { {{program:crate}}::r#impl::write(&self.0, p) } } impl

::fbthrift::Deserialize

for {{typedef:rust_name}} where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { {{program:crate}}::r#impl::read(p).map({{typedef:rust_name}}) } } {{/typedef:nonstandard?}} {{^typedef:nonstandard?}} impl

::fbthrift::Serialize

for {{typedef:rust_name}} where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { {{#typedef:has_adapter?}}{{! }}{{>lib/adapter/qualified}}::to_thrift(&self.0).write(p){{! }}{{/typedef:has_adapter?}}{{! }}{{^typedef:has_adapter?}}{{! }}self.0.write(p){{! }}{{/typedef:has_adapter?}} } } impl

::fbthrift::Deserialize

for {{typedef:rust_name}} where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { {{#typedef:has_adapter?}}{{! }}{{>lib/adapter/qualified}}::from_thrift({{! }}{{/typedef:has_adapter?}}{{! }}::fbthrift::Deserialize::read({{! }}p){{! }}{{#typedef:has_adapter?}}?).map_err(Into::<::anyhow::Error>::into){{/typedef:has_adapter?}}{{! }}.map({{typedef:rust_name}}) } } {{/typedef:nonstandard?}} {{/typedef:newtype?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/unionimpl.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{#struct:union?}} impl ::std::default::Default for {{struct:rust_name}} { fn default() -> Self { Self::UnknownField(-1) } } impl ::fbthrift::GetTType for {{struct:rust_name}} { const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct; } {{!newline}} {{#struct:thrift_uri}} impl ::fbthrift::GetUri for self::{{struct:rust_name}} { fn uri() -> &'static str { "{{struct:thrift_uri}}" } } {{/struct:thrift_uri}} impl

::fbthrift::Serialize

for {{struct:rust_name}} where P: ::fbthrift::ProtocolWriter, { fn write(&self, p: &mut P) { p.write_struct_begin("{{struct:name}}"); match self {{>lib/block}}{{! }}{{#struct:fields}} Self::{{field:rust_name}}(inner) => { p.write_field_begin({{! }}"{{field:name}}", {{! }}{{#field:type}}{{>lib/ttype}}{{/field:type}}, {{! }}{{field:key}}{{! }}); {{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldwrite}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/write}}{{/field:type_annotation?}}{{/field:type}}({{! }}{{#field:has_adapter?}}&{{>lib/adapter/qualified}}::to_thrift_field::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}inner{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }}, p); p.write_field_end(); }{{! }}{{/struct:fields}} Self::UnknownField(_) => {} } p.write_field_stop(); p.write_struct_end(); } } impl

::fbthrift::Deserialize

for {{struct:rust_name}} where P: ::fbthrift::ProtocolReader, { fn read(p: &mut P) -> ::anyhow::Result { static FIELDS: &[::fbthrift::Field] = &[ {{#struct:fields_by_name}} ::fbthrift::Field::new("{{field:name}}", {{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}), {{/struct:fields_by_name}} ]; let _ = ::anyhow::Context::context(p.read_struct_begin(|_| ()), "Expected a {{struct:name}}")?; let {{#struct:fields?}}mut {{/struct:fields?}}once = false; let {{#struct:fields?}}mut {{/struct:fields?}}alt = ::std::option::Option::None; loop { let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?; match (fty, fid as ::std::primitive::i32, once) { (::fbthrift::TType::Stop, _, _) => break,{{! }}{{#struct:fields}} ({{#field:type}}{{>lib/ttype}}{{/field:type}}, {{field:key}}, false) => { once = true; alt = ::std::option::Option::Some(Self::{{field:rust_name}}({{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_field::<{{struct:rust_name}}>({{/field:has_adapter?}}{{! }}{{#field:type}}{{#field:type_annotation?}}{{>lib/annfieldread}}{{/field:type_annotation?}}{{^field:type_annotation?}}{{>lib/read}}{{/field:type_annotation?}}{{/field:type}}(p)?{{! }}{{#field:has_adapter?}}, {{field:key}})?{{/field:has_adapter?}}{{! }})); }{{! }}{{/struct:fields}} (fty, _, false) => p.skip(fty)?, (badty, badid, true) => return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ProtocolError::UnwantedExtraUnionField( "{{struct:name}}".to_string(), badty, badid, ))), } p.read_field_end()?; } p.read_struct_end()?; ::std::result::Result::Ok(alt.unwrap_or_default()) } } impl {{struct:rust_name}} { /// Return current union variant name as a tuple of (Rust name, original name). pub fn variant_name(&self) -> Option<(&'static str, &'static str)> { match self { {{#struct:fields}} Self::{{field:rust_name}}(_) => Some(("{{field:rust_name}}", "{{field:name}}")), {{/struct:fields}} Self::UnknownField(_) => None, } } } {{#program:rust_gen_native_metadata?}} {{>lib/metadata/struct}} {{/program:rust_gen_native_metadata?}} {{/struct:union?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/lib/value.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#value:type}}{{! }}{{#value:newtype?}}{{! }}{{type:package}}::{{type:rust_name}}({{! }}{{#value:type}}{{#type:typedef}}{{#typedef:has_adapter?}}{{! }}{{>lib/adapter/qualified}}::from_thrift({{! }}{{/typedef:has_adapter?}}{{/type:typedef}}{{/value:type}}{{! }}{{#value:inner}}{{>lib/value}}{{/value:inner}}{{! }}{{#value:type}}{{#type:typedef}}{{#typedef:has_adapter?}}{{! }}).expect("constant Thrift value should adapt without error"){{! }}{{/typedef:has_adapter?}}{{/type:typedef}}{{/value:type}}{{! }}){{! }}{{/value:newtype?}}{{! }}{{#value:bool?}}{{value:bool_value}}{{/value:bool?}}{{! }}{{#value:integer?}}{{value:integer_value}}{{/value:integer?}}{{! }}{{#value:floatingPoint?}}{{value:floatingPointValue}}{{/value:floatingPoint?}}{{! }}{{#value:string?}}{{! }}{{#value:empty?}}::std::string::String::new(){{/value:empty?}}{{! }}{{^value:empty?}}{{value:quoted}}.to_owned(){{/value:empty?}}{{! }}{{/value:string?}}{{! }}{{#value:binary?}}{{! }}{{#value:empty?}}{{! }}{{#type:rust}}<::{{type:rust}}>::new(){{/type:rust}}{{! }}{{^type:rust}}::std::vec::Vec::new(){{/type:rust}}{{! }}{{/value:empty?}}{{! }}{{^value:empty?}}{{value:quoted}}.as_bytes().into(){{/value:empty?}}{{! }}{{/value:binary?}}{{! }}{{#value:list?}}{{! }}{{#value:empty?}}::std::vec::Vec::new(){{/value:empty?}}{{! }}{{^value:empty?}}{{! }}vec![{{! }}{{#value:list_elements}} {{value:indent}}{{>lib/value}},{{! }}{{/value:list_elements}} {{value:indent}}]{{! }}{{/value:empty?}}{{! }}{{/value:list?}}{{! }}{{#value:set?}}{{! }}{{#value:empty?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeSet{{/type:rust}}{{! }}::new(){{! }}{{/value:empty?}}{{! }}{{^value:empty?}}{{! }}{ {{value:indent}}let mut set = {{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeSet{{/type:rust}}{{! }}::new();{{! }}{{#value:setMembers}} {{value:indent}}set.insert({{! }}{{#value:floatingPoint?}}{{! }}::fbthrift::export::OrderedFloat({{>lib/value}}){{! }}{{/value:floatingPoint?}}{{! }}{{^value:floatingPoint?}}{{>lib/value}}{{/value:floatingPoint?}}{{! }});{{! }}{{/value:setMembers}} {{value:indent}}set {{value:indent}}}{{! }}{{/value:empty?}}{{! }}{{/value:set?}}{{! }}{{#value:map?}}{{! }}{{#value:empty?}}{{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeMap{{/type:rust}}{{! }}::new(){{! }}{{/value:empty?}}{{! }}{{^value:empty?}}{{! }}{ {{value:indent}}let mut map = {{! }}{{#type:rust}}::{{type:rust}}{{/type:rust}}{{! }}{{^type:rust}}::std::collections::BTreeMap{{/type:rust}}{{! }}::new();{{! }}{{#value:mapEntries}} {{value:indent}}map.insert({{! }}{{#entry:key}}{{! }}{{#value:floatingPoint?}}{{! }}::fbthrift::export::OrderedFloat({{>lib/value}}){{! }}{{/value:floatingPoint?}}{{! }}{{^value:floatingPoint?}}{{>lib/value}}{{/value:floatingPoint?}}{{! }}{{/entry:key}}, {{! }}{{#entry:value}}{{>lib/value}}{{/entry:value}}{{! }});{{! }}{{/value:mapEntries}} {{value:indent}}map {{value:indent}}}{{! }}{{/value:empty?}}{{! }}{{/value:map?}}{{! }}{{#value:struct?}}{{! }}{{>lib/type}} {{>lib/block}}{{! }}{{#value:structFields}} {{value:indent}}{{field:rust_name}}: {{! }}{{#field:has_adapter?}}{{>lib/adapter/qualified}}::from_thrift_default::<{{! }}{{#value:type}}{{#type:struct}}{{! }}{{#struct:has_adapter?}}{{! }}{{type:package}}::unadapted::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}{{type:package}}::{{struct:rust_name}}{{! }}{{/struct:has_adapter?}}{{! }}{{/type:struct}}{{/value:type}}{{! }}>({{/field:has_adapter?}}{{! }}{{#field:explicit_value}}{{! }}{{>lib/fieldvalue}}{{! }}{{/field:explicit_value}}{{! }}{{^field:explicit_value}}{{! }}{{#field:default}}{{! }}{{#field:optional?}}{{! }}{{#program:deprecated_optional_with_default_is_some?}}{{! }}{{>lib/fieldvalue}}{{! }}{{/program:deprecated_optional_with_default_is_some?}}{{! }}{{^program:deprecated_optional_with_default_is_some?}}{{! }}::std::option::Option::None{{! }}{{/program:deprecated_optional_with_default_is_some?}}{{! }}{{/field:optional?}}{{! }}{{^field:optional?}}{{! }}{{>lib/fieldvalue}}{{! }}{{/field:optional?}}{{! }}{{/field:default}}{{! }}{{^field:default}}{{! }}::std::default::Default::default(){{! }}{{/field:default}}{{! }}{{/field:explicit_value}}{{! }}{{#field:has_adapter?}}, {{field:key}}){{/field:has_adapter?}}{{! }},{{! }}{{/value:structFields}}{{! }}{{^value:exhaustive?}} {{value:indent}}..::std::default::Default::default(){{! }}{{/value:exhaustive?}} {{value:indent}}}{{! }}{{/value:struct?}}{{! }}{{#value:union?}}{{! }}{{#value:unionVariant}}{{! }}{{>lib/type}}::{{value:unionVariant}}({{! }}{{#value:unionValue}}{{>lib/value}}{{/value:unionValue}}{{! }}){{! }}{{/value:unionVariant}}{{! }}{{^value:unionVariant}}{{! }}{{>lib/type}}::default(){{! }}{{/value:unionVariant}}{{! }}{{/value:union?}}{{! }}{{#value:enum?}}{{! }}{{#value:local_type}}{{type:package}}::{{type:rust_name}}{{/value:local_type}}{{! }}{{#value:enumVariant}}::{{value:enumVariant}}{{/value:enumVariant}}{{! }}{{^value:enumVariant}}({{value:integer_value}}){{/value:enumVariant}}{{! }}{{/value:enum?}}{{! }}{{/value:type}}{{! }} )__FBTHRIFT_TAG__", // rust/lib/write.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}{{#type:nonstandard?}}{{program:crate}}::r#impl::write{{/type:nonstandard?}}{{! }}{{^type:nonstandard?}}::fbthrift::Serialize::write{{/type:nonstandard?}} )__FBTHRIFT_TAG__", // rust/mock.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! {{#program:services?}} //! Mock definitions for `{{program:name}}`. //! //! Client mocks. For every service, a struct TheService that implements //! client::TheService. //! //! As an example of the generated API, for the following thrift service in //! example.thrift: //! //! ```thrift //! service MyService { //! FunctionResponse myFunction( //! 1: FunctionRequest request, //! ) throws { //! 1: StorageException s, //! 2: NotFoundException n, //! ), //! //! // other functions //! } //! ``` //! //! we would end up with this mock object in an `example_mocks` crate: //! //! ``` //! # const _: &str = stringify! { //! impl example_clients::MyService for MyService<'mock> {...} //! //! pub struct MyService<'mock> { //! pub myFunction: myFunction<'mock>, //! // ... //! } //! //! impl myFunction<'mock> { //! // directly return the given success response //! pub fn ret(&self, value: FunctionResponse); //! //! // invoke closure to compute success response //! pub fn mock( //! &self, //! mock: impl FnMut(FunctionRequest) -> FunctionResponse + Send + Sync + 'mock, //! ); //! //! // invoke closure to compute response //! pub fn mock_result( //! &self, //! mock: impl FnMut(FunctionRequest) -> Result + Send + Sync + 'mock, //! ); //! //! // return one of the function's declared exceptions //! pub fn throw(&self, exception: E) //! where //! E: Clone + Into + Send + Sync + 'mock; //! } //! # }; //! ``` //! //! The intended usage from a test would be: //! //! ``` //! # const _: &str = stringify! { //! use std::sync::Arc; //! use example_clients::MyService; //! //! #[tokio::test] //! async fn test_my_client() { //! let mock = Arc::new(example_mocks::new::()); //! //! // directly return a success response //! let resp = FunctionResponse {...}; //! mock.myFunction.ret(resp); //! //! // or give a closure to compute the success response //! mock.myFunction.mock(|request| FunctionResponse {...}); //! //! // or throw one of the function's exceptions //! mock.myFunction.throw(StorageException::ItFailed); //! //! // or compute a Result (useful if your exceptions aren't Clone) //! mock.myFunction.mock_result(|request| Err(...)); //! //! let out = do_the_thing(mock).await.unwrap(); //! assert!(out.what_i_expected()); //! } //! //! async fn do_the_thing( //! client: Arc, //! ) -> Out {...} //! # }; //! ``` {{^program:multifile?}} #![recursion_limit = "100000000"] {{/program:multifile?}} #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals{{! }}{{^program:multifile?}}, unused_crate_dependencies{{/program:multifile?}}{{! }}, unused_imports, clippy::all)] pub(crate) use {{program:types}} as types; pub(crate) use {{program:clients}} as client; #[allow(deprecated)] pub(crate) use {{program:clients}}::dependencies; pub(crate) use {{program:clients}}::errors; {{^program:multifile?}} pub fn new<'mock, Client>() -> Client::Mock<'mock> where Client: ?::std::marker::Sized + DynClient, { Client::mock() } pub trait DynClient { type Mock<'mock>; fn mock<'mock>() -> Self::Mock<'mock>; } {{/program:multifile?}} {{#program:services}} pub struct {{service:rust_name}}<'mock> {{>lib/block}} {{#service:extends}} pub parent: {{service:mock_package}}::{{service:rust_name}}<'mock>, {{/service:extends}} {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} pub {{function:rust_name}}: r#impl::{{service:snake}}::{{function:rust_name}}<'mock>, {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} _marker: ::std::marker::PhantomData<&'mock ()>, } impl crate::DynClient for dyn {{program:clients}}::{{service:rust_name}} { type Mock<'mock> = {{service:rust_name}}<'mock>; fn mock<'mock>() -> Self::Mock<'mock> { {{service:rust_name}} { {{#service:extends}} parent: {{service:mock_crate}}::new::(), {{/service:extends}} {{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} {{function:rust_name}}: {{! }}r#impl::{{service:snake}}::{{function:rust_name}}::unimplemented(), {{/function:sink?}}{{/function:starts_interaction?}} {{/service:rustFunctions}} _marker: ::std::marker::PhantomData, } } } impl<'mock> {{program:clients}}::{{service:rust_name}} for {{service:rust_name}}<'mock> {{>lib/block}}{{! }}{{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}}{{^function:creates_interaction?}} fn {{function:rust_name}}( &self,{{! }}{{#function:args}} arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} ) -> {{>lib/client_return_type}} { let mut closure = self.{{function:rust_name}}.closure.lock().unwrap(); let closure: &mut dyn ::std::ops::FnMut({{! }}{{#function:args}}{{! }}{{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) -> _ = &mut **closure; ::std::boxed::Box::pin(::futures::future::ready(closure({{! }}{{#function:args}}{{! }}arg_{{field:name}}{{#field:type}}{{! }}{{#type:string?}}.to_owned(){{/type:string?}}{{! }}{{#type:list?}}.to_owned(){{/type:list?}}{{! }}{{^type:string?}}{{^type:list?}}{{! }}.clone(){{! }}{{/type:list?}}{{/type:string?}}{{! }}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}))) }{{! }}{{/function:creates_interaction?}}{{#function:creates_interaction?}} fn {{function:rust_name}}( &self,{{! }}{{#function:args}} _arg_{{field:name}}: {{>lib/arg}},{{! }}{{/function:args}} ) -> {{>lib/client_return_type}} { unimplemented!("Mocking interactions is not yet implemented"); }{{! }}{{/function:creates_interaction?}}{{/function:sink?}}{{/function:starts_interaction?}}{{#function:starts_interaction?}} fn {{function:rust_name}}( &self, ) -> ::std::result::Result<{{! }}{{service:client_package}}::{{function:interaction_name}}Client, {{! }}::anyhow::Error> { unimplemented!("Mocking interactions is not yet implemented"); }{{! }}{{/function:starts_interaction?}}{{/service:rustFunctions}} } {{#service:extendedClients}} #[::async_trait::async_trait] #[allow(deprecated)]{{! `dependencies` modules are deprecated other than for packagePrefix to use }} impl<'mock> {{! }}{{#extendedService:service}}{{! }}::std::convert::AsRef {{! }}{{/extendedService:service}}{{! }}for {{service:rust_name}}<'mock> { {{#extendedService:service}} fn as_ref(&self) -> &(dyn {{extendedService:packagePrefix}}::{{service:rust_name}} + 'mock) { &self.parent } {{/extendedService:service}} } {{/service:extendedClients}}{{! }}{{/program:services}} pub mod r#impl {{>lib/block}}{{! }}{{#program:services}} pub mod {{service:snake}} {{>lib/block}}{{! }}{{#service:rustFunctions}} {{^function:starts_interaction?}}{{^function:sink?}} pub struct {{function:rust_name}}<'mock> { pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box< dyn ::std::ops::FnMut({{! }}{{#function:args}}{{! }}{{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) -> ::std::result::Result< {{#function:return_type}}{{>lib/return_type}}{{/function:return_type}}, {{program:clients}}::errors::{{service:snake}}::{{function:upcamel}}Error, > + ::std::marker::Send + ::std::marker::Sync + 'mock, >>, } #[allow(clippy::redundant_closure)] impl<'mock> {{function:rust_name}}<'mock> { pub(crate) fn unimplemented() -> Self { Self { closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|{{! }}{{#function:args}}{{! }}_: {{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}| panic!( "{}::{} is not mocked", "{{service:rust_name}}", "{{function:name}}", ))), } } pub fn ret({{! }}&self, {{! }}{{#function:stream?}}_{{/function:stream?}}value: {{#function:return_type}}{{>lib/return_type}}{{/function:return_type}}{{! }}) { {{#function:stream?}} unimplemented!("Mocking streams is not yet implemented, as value isn't cloneable") {{/function:stream?}}{{^function:stream?}} self.mock(move |{{! }}{{#function:args}}{{! }}_: {{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}| value.clone()); {{/function:stream?}} } pub fn mock(&self, mut mock: impl ::std::ops::FnMut({{! }}{{#function:args}}{{! }}{{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) -> {{#function:return_type}}{{>lib/return_type}}{{/function:return_type}}{{! }} + ::std::marker::Send + ::std::marker::Sync + 'mock) {{! }}{ let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |{{! }}{{#function:args}}{{! }}{{field:rust_name}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}| ::std::result::Result::Ok(mock({{! }}{{#function:args}}{{! }}{{field:rust_name}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}))); } pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut({{! }}{{#function:args}}{{! }}{{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}) -> ::std::result::Result<{{! }}{{#function:return_type}}{{>lib/return_type}}{{/function:return_type}}, {{! }}{{program:clients}}::errors::{{service:snake}}::{{function:upcamel}}Error>{{! }} + ::std::marker::Send + ::std::marker::Sync + 'mock) {{! }}{ let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |{{! }}{{#function:args}}{{! }}{{field:rust_name}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}| mock({{! }}{{#function:args}}{{! }}{{field:rust_name}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }})); } pub fn throw(&self, exception: E) where E: ::std::convert::Into<{{program:clients}}::errors::{{service:snake}}::{{function:upcamel}}Error>, E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock, { let mut closure = self.closure.lock().unwrap(); *closure = ::std::boxed::Box::new(move |{{! }}{{#function:args}}{{! }}_: {{#field:type}}{{>lib/type}}{{/field:type}}{{! }}{{^last?}}, {{/last?}}{{! }}{{/function:args}}{{! }}| ::std::result::Result::Err(exception.clone().into())); } }{{! }}{{/function:sink?}}{{/function:starts_interaction?}}{{! }}{{/service:rustFunctions}} }{{! }}{{/program:services}} } {{/program:services?}} {{^program:services?}} #![doc(hidden)] #![allow({{! }}{{^program:multifile?}}non_snake_case, unused_crate_dependencies, {{/program:multifile?}}{{! }}unused_imports)] pub(crate) use {{program:types}} as types; {{/program:services?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/server.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! {{#program:services?}} //! Server definitions for `{{program:name}}`. {{^program:multifile?}} #![recursion_limit = "100000000"] {{/program:multifile?}} #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals{{! }}{{^program:multifile?}}, unused_crate_dependencies{{/program:multifile?}}{{! }}, unused_imports, clippy::all)] #[doc(inline)] pub use {{program:types}} as types; pub mod errors {{>lib/block}}{{#program:services}} {{>lib/server_errors}} {{#service:interactions}} {{>lib/server_errors}} {{/service:interactions}} {{/program:services}} } pub(crate) use {{program:crate}} as server; pub(crate) use {{program:types}}::services; {{#program:services}}{{>lib/server}}{{! }}{{/program:services}} {{/program:services?}} {{^program:services?}} #![doc(hidden)] {{^program:multifile?}} #![allow(non_snake_case, unused_crate_dependencies)] {{/program:multifile?}} #[doc(inline)] pub use {{program:types}} as types; {{/program:services?}} {{!newline}} )__FBTHRIFT_TAG__", // rust/services.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! //! Thrift service definitions for `{{program:name}}`. {{#program:services}} {{>lib/service}}{{! }}{{/program:services}} )__FBTHRIFT_TAG__", // rust/types.rs.mustache R"__FBTHRIFT_TAG__({{! Copyright (c) Meta Platforms, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }}// @{{}}generated by Thrift for {{program:autogen_path}} // This file is probably not the place you want to edit! {{#program:docs?}} #![doc = {{program:docs}}] {{/program:docs?}} {{^program:multifile?}} #![recursion_limit = "100000000"] {{/program:multifile?}} #![allow(non_camel_case_types, non_snake_case, non_upper_case_globals{{! }}{{^program:multifile?}}, unused_crate_dependencies{{/program:multifile?}}{{! }}, clippy::redundant_closure, clippy::type_complexity)] {{#program:serde?}} {{! Work around https://github.com/rust-lang/rust/issues/46991 }} extern crate serde; {{/program:serde?}}{{! }}{{#program:types_include_srcs}} include!("{{.}}"); {{/program:types_include_srcs}}{{! }} {{#program:constants?}} pub mod consts; #[doc(inline)] pub use self::consts::*; {{/program:constants?}}{{! }}{{#program:services?}} pub mod services; {{/program:services?}} pub mod errors; {{! Allows lib/type.mustache to use `crate::types::Type` regardless of which crate it's called from }} #[allow(unused_imports)] pub(crate) use {{program:crate}} as types; {{! }}{{#program:typedefs}}{{>lib/typedef}}{{/program:typedefs}}{{! }}{{#program:structs}}{{! }}{{#struct:has_adapter?}}{{! }}{{! }}{{/struct:has_adapter?}}{{! }}{{^struct:has_adapter?}}{{! }}{{>lib/struct}}{{! }}{{/struct:has_adapter?}}{{! }}{{/program:structs}}{{! }}{{#program:enums}}{{>lib/enum}}{{/program:enums}}{{! }}{{#program:typedefs}}{{>lib/typedefimpl}}{{/program:typedefs}}{{! }}{{#program:structs}}{{^struct:has_adapter?}}{{>lib/structimpl}}{{>lib/unionimpl}}{{/struct:has_adapter?}}{{/program:structs}}{{! }}{{#program:has_adapted_structs?}}{{! }}{{>lib/mod.unadapted}}{{! }}{{>lib/mod.adapted_types}}{{! }}{{/program:has_adapted_structs?}}{{! }}{{#program:has_adapters?}}{{! }}{{>lib/mod.adapters}}{{! }}{{/program:has_adapters?}}{{! }}{{#program:nonexhaustiveStructs?}} mod dot_dot {{>lib/block}}{{! NOTE: intentionally no Default impl}} #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct OtherFields(pub(crate) ()); #[allow(dead_code)] // if serde isn't being used pub(super) fn default_for_serde_deserialize() -> OtherFields { OtherFields(()) } }{{! }}{{/program:nonexhaustiveStructs?}} pub(crate) mod r#impl {{>lib/block}}{{>lib/mod.impl}}} {{! }}{{#program:has_default_tests?}}{{>lib/adapter/default_test}}{{/program:has_default_tests?}} )__FBTHRIFT_TAG__", // starlark/consts.mustache R"__FBTHRIFT_TAG__({{#program:constants}}{{! }}{{#constant:type}}{{! }}{{#type:starlark_supported?}} {{constant:name}} = {{! }}{{#constant:value}}{{! }}{{> consts/value}}{{! }}{{/constant:value}} {{!newline after constant}} {{/type:starlark_supported?}}{{! }}{{/constant:type}}{{! }}{{/program:constants}} )__FBTHRIFT_TAG__", // starlark/consts/value.mustache R"__FBTHRIFT_TAG__({{#type:byte?}}{{value:integer_value}}{{/type:byte?}}{{! }}{{#type:i16?}}{{value:integer_value}}{{/type:i16?}}{{! }}{{#type:i32?}}{{value:integer_value}}{{/type:i32?}}{{! }}{{#type:i64?}}{{value:integer_value}}{{/type:i64?}}{{! }}{{#type:string?}}"{{value:string_value}}"{{/type:string?}}{{! }}{{#type:bool?}}{{! }}{{#value:nonzero?}}True{{/value:nonzero?}}{{! }}{{^value:nonzero?}}False{{/value:nonzero?}}{{! }}{{/type:bool?}}{{! }}{{#type:float?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:float?}}{{! }}{{#type:double?}}{{! }}{{#value:double?}}{{value:double_value}}{{/value:double?}}{{! }}{{#value:integer?}}{{value:integer_value}}.0{{/value:integer?}}{{! }}{{/type:double?}}{{! List constants }}{{#type:list?}}[ {{#value:list_elements}} {{#type:list_elem_type}}{{! }}{{> consts/value}},{{! }}{{/type:list_elem_type}} {{/value:list_elements}} ]{{/type:list?}}{{! Map constants }}{{#type:map?}}{ {{#value:map_elements}} {{#element:key}}{{! }}{{#type:key_type}}{{! }}{{> consts/value}}{{! }}{{/type:key_type}}{{! }}{{/element:key}}: {{! }}{{#element:value}}{{! }}{{#type:value_type}}{{! }}{{> consts/value}}{{! }}{{/type:value_type}}{{! }}{{/element:value}}, {{/value:map_elements}} }{{/type:map?}}{{! Enum constants }}{{#type:enum?}}{{! }}{{#type:enum}}{{! }}{{#value:enum_value?}}{{! }}{{#value:enum_value}}{{! Known enum value with a name. }}{{enum:name}}.{{enum_value:name}}{{! }}{{/value:enum_value}}{{! }}{{/value:enum_value?}}{{! }}{{/type:enum}}{{! }}{{/type:enum?}} )__FBTHRIFT_TAG__", // starlark/definitions.star.mustache R"__FBTHRIFT_TAG__({{> enums}} {{> consts}} )__FBTHRIFT_TAG__", // starlark/enums.mustache R"__FBTHRIFT_TAG__({{#program:enums?}} __StarlarkEnum__ = record(name=str, value=int) {{#program:enums}} __{{enum:name}}_enum__ = record( {{#enum:values}} {{enum_value:name}} = __StarlarkEnum__, {{/enum:values}} ) {{enum:name}} = __{{enum:name}}_enum__( {{#enum:values}} {{enum_value:name}} = __StarlarkEnum__(name="{{enum_value:name}}", value={{enum_value:value}}), {{/enum:values}} ) {{/program:enums}} {{/program:enums?}} )__FBTHRIFT_TAG__", }; } // namespace compiler } // namespace thrift } // namespace apache