| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/internal.h> |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/buffer_allocator.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/memory.h> |
| #include <lib/fidl/llcpp/service_handler_interface.h> |
| #include <lib/fidl/llcpp/string_view.h> |
| #include <lib/fidl/llcpp/sync_call.h> |
| #include <lib/fidl/llcpp/tracking_ptr.h> |
| #include <lib/fidl/llcpp/traits.h> |
| #include <lib/fidl/llcpp/transaction.h> |
| #include <lib/fidl/llcpp/vector_view.h> |
| #include <lib/fidl/txn_header.h> |
| #include <lib/fit/function.h> |
| #include <lib/zx/channel.h> |
| #include <zircon/fidl.h> |
| |
| namespace llcpp { |
| |
| namespace test { |
| namespace name { |
| |
| class SecondProtocol; |
| class FirstProtocol; |
| class SingleMemberService; |
| class MultiHomogeneousMemberService; |
| class MultiHeterogeneousMemberService; |
| |
| extern "C" const fidl_type_t |
| v1_test_name_SecondProtocolMethodOnSecondRequestTable; |
| extern "C" const fidl_type_t |
| v1_test_name_SecondProtocolMethodOnSecondResponseTable; |
| class SecondProtocol final { |
| SecondProtocol() = delete; |
| |
| public: |
| using MethodOnSecondRequest = ::fidl::AnyZeroArgMessage; |
| |
| // Collection of return types of FIDL calls in this protocol. |
| class ResultOf final { |
| ResultOf() = delete; |
| |
| private: |
| class MethodOnSecond_Impl final : private ::fidl::internal::StatusAndError { |
| using Super = ::fidl::internal::StatusAndError; |
| |
| public: |
| MethodOnSecond_Impl(::zx::unowned_channel _client_end); |
| ~MethodOnSecond_Impl() = default; |
| MethodOnSecond_Impl(MethodOnSecond_Impl&& other) = default; |
| MethodOnSecond_Impl& operator=(MethodOnSecond_Impl&& other) = default; |
| using Super::error; |
| using Super::ok; |
| using Super::status; |
| }; |
| |
| public: |
| using MethodOnSecond = MethodOnSecond_Impl; |
| }; |
| |
| // Collection of return types of FIDL calls in this protocol, |
| // when the caller-allocate flavor or in-place call is used. |
| class UnownedResultOf final { |
| UnownedResultOf() = delete; |
| |
| private: |
| class MethodOnSecond_Impl final : private ::fidl::internal::StatusAndError { |
| using Super = ::fidl::internal::StatusAndError; |
| |
| public: |
| MethodOnSecond_Impl(::zx::unowned_channel _client_end); |
| ~MethodOnSecond_Impl() = default; |
| MethodOnSecond_Impl(MethodOnSecond_Impl&& other) = default; |
| MethodOnSecond_Impl& operator=(MethodOnSecond_Impl&& other) = default; |
| using Super::error; |
| using Super::ok; |
| using Super::status; |
| }; |
| |
| public: |
| using MethodOnSecond = MethodOnSecond_Impl; |
| }; |
| |
| class SyncClient final { |
| public: |
| SyncClient() = default; |
| explicit SyncClient(::zx::channel channel) : channel_(std::move(channel)) {} |
| ~SyncClient() = default; |
| SyncClient(SyncClient&&) = default; |
| SyncClient& operator=(SyncClient&&) = default; |
| |
| const ::zx::channel& channel() const { return channel_; } |
| |
| ::zx::channel* mutable_channel() { return &channel_; } |
| |
| // Allocates 16 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| ResultOf::MethodOnSecond MethodOnSecond(); |
| |
| private: |
| ::zx::channel channel_; |
| }; |
| |
| // Methods to make a sync FIDL call directly on an unowned channel, avoiding |
| // setting up a client. |
| class Call final { |
| Call() = delete; |
| |
| public: |
| // Allocates 16 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| static ResultOf::MethodOnSecond MethodOnSecond( |
| ::zx::unowned_channel _client_end); |
| }; |
| |
| // Messages are encoded and decoded in-place when these methods are used. |
| // Additionally, requests must be already laid-out according to the FIDL |
| // wire-format. |
| class InPlace final { |
| InPlace() = delete; |
| |
| public: |
| static ::fidl::internal::StatusAndError MethodOnSecond( |
| ::zx::unowned_channel _client_end); |
| }; |
| |
| // Pure-virtual interface to be implemented by a server. |
| class Interface { |
| public: |
| Interface() = default; |
| virtual ~Interface() = default; |
| using _Outer = SecondProtocol; |
| using _Base = ::fidl::CompleterBase; |
| |
| using MethodOnSecondCompleter = ::fidl::Completer<>; |
| |
| virtual void MethodOnSecond(MethodOnSecondCompleter::Sync _completer) = 0; |
| }; |
| |
| // Attempts to dispatch the incoming message to a handler function in the |
| // server implementation. If there is no matching handler, it returns false, |
| // leaving the message and transaction intact. In all other cases, it consumes |
| // the message and returns true. It is possible to chain multiple TryDispatch |
| // functions in this manner. |
| static bool TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Dispatches the incoming message to one of the handlers functions in the |
| // protocol. If there is no matching handler, it closes all the handles in |
| // |msg| and closes the channel with a |ZX_ERR_NOT_SUPPORTED| epitaph, before |
| // returning false. The message should then be discarded. |
| static bool Dispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Same as |Dispatch|, but takes a |void*| instead of |Interface*|. Only used |
| // with |fidl::Bind| to reduce template expansion. Do not call this method |
| // manually. Use |Dispatch| instead. |
| static bool TypeErasedDispatch(void* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return Dispatch(static_cast<Interface*>(impl), msg, txn); |
| } |
| |
| // Helper functions to fill in the transaction header in a |
| // |DecodedMessage<TransactionalMessage>|. |
| class SetTransactionHeaderFor final { |
| SetTransactionHeaderFor() = delete; |
| |
| public: |
| static void MethodOnSecondRequest( |
| const ::fidl::DecodedMessage<SecondProtocol::MethodOnSecondRequest>& |
| _msg); |
| }; |
| }; |
| |
| extern "C" const fidl_type_t |
| v1_test_name_FirstProtocolMethodOnFirstRequestTable; |
| extern "C" const fidl_type_t |
| v1_test_name_FirstProtocolMethodOnFirstResponseTable; |
| class FirstProtocol final { |
| FirstProtocol() = delete; |
| |
| public: |
| using MethodOnFirstRequest = ::fidl::AnyZeroArgMessage; |
| |
| // Collection of return types of FIDL calls in this protocol. |
| class ResultOf final { |
| ResultOf() = delete; |
| |
| private: |
| class MethodOnFirst_Impl final : private ::fidl::internal::StatusAndError { |
| using Super = ::fidl::internal::StatusAndError; |
| |
| public: |
| MethodOnFirst_Impl(::zx::unowned_channel _client_end); |
| ~MethodOnFirst_Impl() = default; |
| MethodOnFirst_Impl(MethodOnFirst_Impl&& other) = default; |
| MethodOnFirst_Impl& operator=(MethodOnFirst_Impl&& other) = default; |
| using Super::error; |
| using Super::ok; |
| using Super::status; |
| }; |
| |
| public: |
| using MethodOnFirst = MethodOnFirst_Impl; |
| }; |
| |
| // Collection of return types of FIDL calls in this protocol, |
| // when the caller-allocate flavor or in-place call is used. |
| class UnownedResultOf final { |
| UnownedResultOf() = delete; |
| |
| private: |
| class MethodOnFirst_Impl final : private ::fidl::internal::StatusAndError { |
| using Super = ::fidl::internal::StatusAndError; |
| |
| public: |
| MethodOnFirst_Impl(::zx::unowned_channel _client_end); |
| ~MethodOnFirst_Impl() = default; |
| MethodOnFirst_Impl(MethodOnFirst_Impl&& other) = default; |
| MethodOnFirst_Impl& operator=(MethodOnFirst_Impl&& other) = default; |
| using Super::error; |
| using Super::ok; |
| using Super::status; |
| }; |
| |
| public: |
| using MethodOnFirst = MethodOnFirst_Impl; |
| }; |
| |
| class SyncClient final { |
| public: |
| SyncClient() = default; |
| explicit SyncClient(::zx::channel channel) : channel_(std::move(channel)) {} |
| ~SyncClient() = default; |
| SyncClient(SyncClient&&) = default; |
| SyncClient& operator=(SyncClient&&) = default; |
| |
| const ::zx::channel& channel() const { return channel_; } |
| |
| ::zx::channel* mutable_channel() { return &channel_; } |
| |
| // Allocates 16 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| ResultOf::MethodOnFirst MethodOnFirst(); |
| |
| private: |
| ::zx::channel channel_; |
| }; |
| |
| // Methods to make a sync FIDL call directly on an unowned channel, avoiding |
| // setting up a client. |
| class Call final { |
| Call() = delete; |
| |
| public: |
| // Allocates 16 bytes of message buffer on the stack. No heap allocation |
| // necessary. |
| static ResultOf::MethodOnFirst MethodOnFirst( |
| ::zx::unowned_channel _client_end); |
| }; |
| |
| // Messages are encoded and decoded in-place when these methods are used. |
| // Additionally, requests must be already laid-out according to the FIDL |
| // wire-format. |
| class InPlace final { |
| InPlace() = delete; |
| |
| public: |
| static ::fidl::internal::StatusAndError MethodOnFirst( |
| ::zx::unowned_channel _client_end); |
| }; |
| |
| // Pure-virtual interface to be implemented by a server. |
| class Interface { |
| public: |
| Interface() = default; |
| virtual ~Interface() = default; |
| using _Outer = FirstProtocol; |
| using _Base = ::fidl::CompleterBase; |
| |
| using MethodOnFirstCompleter = ::fidl::Completer<>; |
| |
| virtual void MethodOnFirst(MethodOnFirstCompleter::Sync _completer) = 0; |
| }; |
| |
| // Attempts to dispatch the incoming message to a handler function in the |
| // server implementation. If there is no matching handler, it returns false, |
| // leaving the message and transaction intact. In all other cases, it consumes |
| // the message and returns true. It is possible to chain multiple TryDispatch |
| // functions in this manner. |
| static bool TryDispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Dispatches the incoming message to one of the handlers functions in the |
| // protocol. If there is no matching handler, it closes all the handles in |
| // |msg| and closes the channel with a |ZX_ERR_NOT_SUPPORTED| epitaph, before |
| // returning false. The message should then be discarded. |
| static bool Dispatch(Interface* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn); |
| |
| // Same as |Dispatch|, but takes a |void*| instead of |Interface*|. Only used |
| // with |fidl::Bind| to reduce template expansion. Do not call this method |
| // manually. Use |Dispatch| instead. |
| static bool TypeErasedDispatch(void* impl, fidl_msg_t* msg, |
| ::fidl::Transaction* txn) { |
| return Dispatch(static_cast<Interface*>(impl), msg, txn); |
| } |
| |
| // Helper functions to fill in the transaction header in a |
| // |DecodedMessage<TransactionalMessage>|. |
| class SetTransactionHeaderFor final { |
| SetTransactionHeaderFor() = delete; |
| |
| public: |
| static void MethodOnFirstRequest( |
| const ::fidl::DecodedMessage<FirstProtocol::MethodOnFirstRequest>& |
| _msg); |
| }; |
| }; |
| |
| class SingleMemberService final { |
| SingleMemberService() = default; |
| |
| public: |
| static constexpr char Name[] = "test.name.SingleMemberService"; |
| |
| // Client protocol for connecting to member protocols of a service instance. |
| class ServiceClient final { |
| ServiceClient() = delete; |
| |
| public: |
| ServiceClient(::zx::channel dir, |
| ::fidl::internal::ConnectMemberFunc connect_func) |
| : dir_(std::move(dir)), connect_func_(connect_func) {} |
| |
| // Connects to the member protocol "single_member". Returns a |
| // |fidl::ClientChannel| on success, which can be used with |
| // |fidl::BindSyncClient| to create a synchronous client. |
| // |
| // # Errors |
| // |
| // On failure, returns a fit::error with zx_status_t != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue |
| // making a |fuchsia.io.Directory::Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end |
| // will not result in a failure of this method. Any errors sent by the |
| // remote will appear on the |ClientChannel| returned from this method. |
| ::fidl::result<::fidl::ClientChannel<FirstProtocol>> |
| connect_single_member() { |
| ::zx::channel local, remote; |
| zx_status_t result = ::zx::channel::create(0, &local, &remote); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| result = |
| connect_func_(::zx::unowned_channel(dir_), |
| ::fidl::StringView("single_member"), std::move(remote)); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| return ::fit::ok(::fidl::ClientChannel<FirstProtocol>(std::move(local))); |
| } |
| |
| private: |
| ::zx::channel dir_; |
| ::fidl::internal::ConnectMemberFunc connect_func_; |
| }; |
| |
| // Facilitates member protocol registration for servers. |
| class Handler final { |
| public: |
| // Constructs a FIDL Service-typed handler. Does not take ownership of |
| // |service_handler|. |
| explicit Handler(::llcpp::fidl::ServiceHandlerInterface* service_handler) |
| : service_handler_(service_handler) {} |
| |
| // Adds member "single_member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_single_member( |
| ::llcpp::fidl::ServiceHandlerInterface::MemberHandler handler) { |
| return service_handler_->AddMember("single_member", std::move(handler)); |
| } |
| |
| private: |
| ::llcpp::fidl::ServiceHandlerInterface* service_handler_; // Not owned. |
| }; |
| }; |
| |
| class MultiHomogeneousMemberService final { |
| MultiHomogeneousMemberService() = default; |
| |
| public: |
| static constexpr char Name[] = "test.name.MultiHomogeneousMemberService"; |
| |
| // Client protocol for connecting to member protocols of a service instance. |
| class ServiceClient final { |
| ServiceClient() = delete; |
| |
| public: |
| ServiceClient(::zx::channel dir, |
| ::fidl::internal::ConnectMemberFunc connect_func) |
| : dir_(std::move(dir)), connect_func_(connect_func) {} |
| |
| // Connects to the member protocol "first_member". Returns a |
| // |fidl::ClientChannel| on success, which can be used with |
| // |fidl::BindSyncClient| to create a synchronous client. |
| // |
| // # Errors |
| // |
| // On failure, returns a fit::error with zx_status_t != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue |
| // making a |fuchsia.io.Directory::Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end |
| // will not result in a failure of this method. Any errors sent by the |
| // remote will appear on the |ClientChannel| returned from this method. |
| ::fidl::result<::fidl::ClientChannel<FirstProtocol>> |
| connect_first_member() { |
| ::zx::channel local, remote; |
| zx_status_t result = ::zx::channel::create(0, &local, &remote); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| result = |
| connect_func_(::zx::unowned_channel(dir_), |
| ::fidl::StringView("first_member"), std::move(remote)); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| return ::fit::ok(::fidl::ClientChannel<FirstProtocol>(std::move(local))); |
| } |
| |
| // Connects to the member protocol "second_member". Returns a |
| // |fidl::ClientChannel| on success, which can be used with |
| // |fidl::BindSyncClient| to create a synchronous client. |
| // |
| // # Errors |
| // |
| // On failure, returns a fit::error with zx_status_t != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue |
| // making a |fuchsia.io.Directory::Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end |
| // will not result in a failure of this method. Any errors sent by the |
| // remote will appear on the |ClientChannel| returned from this method. |
| ::fidl::result<::fidl::ClientChannel<FirstProtocol>> |
| connect_second_member() { |
| ::zx::channel local, remote; |
| zx_status_t result = ::zx::channel::create(0, &local, &remote); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| result = |
| connect_func_(::zx::unowned_channel(dir_), |
| ::fidl::StringView("second_member"), std::move(remote)); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| return ::fit::ok(::fidl::ClientChannel<FirstProtocol>(std::move(local))); |
| } |
| |
| private: |
| ::zx::channel dir_; |
| ::fidl::internal::ConnectMemberFunc connect_func_; |
| }; |
| |
| // Facilitates member protocol registration for servers. |
| class Handler final { |
| public: |
| // Constructs a FIDL Service-typed handler. Does not take ownership of |
| // |service_handler|. |
| explicit Handler(::llcpp::fidl::ServiceHandlerInterface* service_handler) |
| : service_handler_(service_handler) {} |
| |
| // Adds member "first_member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_first_member( |
| ::llcpp::fidl::ServiceHandlerInterface::MemberHandler handler) { |
| return service_handler_->AddMember("first_member", std::move(handler)); |
| } |
| |
| // Adds member "second_member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_second_member( |
| ::llcpp::fidl::ServiceHandlerInterface::MemberHandler handler) { |
| return service_handler_->AddMember("second_member", std::move(handler)); |
| } |
| |
| private: |
| ::llcpp::fidl::ServiceHandlerInterface* service_handler_; // Not owned. |
| }; |
| }; |
| |
| class MultiHeterogeneousMemberService final { |
| MultiHeterogeneousMemberService() = default; |
| |
| public: |
| static constexpr char Name[] = "test.name.MultiHeterogeneousMemberService"; |
| |
| // Client protocol for connecting to member protocols of a service instance. |
| class ServiceClient final { |
| ServiceClient() = delete; |
| |
| public: |
| ServiceClient(::zx::channel dir, |
| ::fidl::internal::ConnectMemberFunc connect_func) |
| : dir_(std::move(dir)), connect_func_(connect_func) {} |
| |
| // Connects to the member protocol "first_member". Returns a |
| // |fidl::ClientChannel| on success, which can be used with |
| // |fidl::BindSyncClient| to create a synchronous client. |
| // |
| // # Errors |
| // |
| // On failure, returns a fit::error with zx_status_t != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue |
| // making a |fuchsia.io.Directory::Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end |
| // will not result in a failure of this method. Any errors sent by the |
| // remote will appear on the |ClientChannel| returned from this method. |
| ::fidl::result<::fidl::ClientChannel<FirstProtocol>> |
| connect_first_member() { |
| ::zx::channel local, remote; |
| zx_status_t result = ::zx::channel::create(0, &local, &remote); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| result = |
| connect_func_(::zx::unowned_channel(dir_), |
| ::fidl::StringView("first_member"), std::move(remote)); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| return ::fit::ok(::fidl::ClientChannel<FirstProtocol>(std::move(local))); |
| } |
| |
| // Connects to the member protocol "second_member". Returns a |
| // |fidl::ClientChannel| on success, which can be used with |
| // |fidl::BindSyncClient| to create a synchronous client. |
| // |
| // # Errors |
| // |
| // On failure, returns a fit::error with zx_status_t != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue |
| // making a |fuchsia.io.Directory::Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end |
| // will not result in a failure of this method. Any errors sent by the |
| // remote will appear on the |ClientChannel| returned from this method. |
| ::fidl::result<::fidl::ClientChannel<SecondProtocol>> |
| connect_second_member() { |
| ::zx::channel local, remote; |
| zx_status_t result = ::zx::channel::create(0, &local, &remote); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| result = |
| connect_func_(::zx::unowned_channel(dir_), |
| ::fidl::StringView("second_member"), std::move(remote)); |
| if (result != ZX_OK) { |
| return ::fit::error(result); |
| } |
| return ::fit::ok(::fidl::ClientChannel<SecondProtocol>(std::move(local))); |
| } |
| |
| private: |
| ::zx::channel dir_; |
| ::fidl::internal::ConnectMemberFunc connect_func_; |
| }; |
| |
| // Facilitates member protocol registration for servers. |
| class Handler final { |
| public: |
| // Constructs a FIDL Service-typed handler. Does not take ownership of |
| // |service_handler|. |
| explicit Handler(::llcpp::fidl::ServiceHandlerInterface* service_handler) |
| : service_handler_(service_handler) {} |
| |
| // Adds member "first_member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_first_member( |
| ::llcpp::fidl::ServiceHandlerInterface::MemberHandler handler) { |
| return service_handler_->AddMember("first_member", std::move(handler)); |
| } |
| |
| // Adds member "second_member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| zx_status_t add_second_member( |
| ::llcpp::fidl::ServiceHandlerInterface::MemberHandler handler) { |
| return service_handler_->AddMember("second_member", std::move(handler)); |
| } |
| |
| private: |
| ::llcpp::fidl::ServiceHandlerInterface* service_handler_; // Not owned. |
| }; |
| }; |
| |
| } // namespace name |
| } // namespace test |
| } // namespace llcpp |
| |
| namespace fidl {} // namespace fidl |