blob: 36a44f965d22a291521948924cbcdf8b6b3f8f9c [file] [log] [blame] [edit]
// 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/buffer_then_heap_allocator.h>
#include <lib/fidl/llcpp/coding.h>
#include <lib/fidl/llcpp/envelope.h>
#include <lib/fidl/llcpp/errors.h>
#include <lib/fidl/llcpp/memory.h>
#include <lib/fidl/llcpp/message.h>
#include <lib/fidl/llcpp/message_storage.h>
#include <lib/fidl/llcpp/string_view.h>
#include <lib/fidl/llcpp/tracking_ptr.h>
#include <lib/fidl/llcpp/traits.h>
#include <lib/fidl/llcpp/vector_view.h>
#include <lib/fit/function.h>
#include <lib/fit/optional.h>
#include <variant>
#ifdef __Fuchsia__
#include <lib/fidl/llcpp/client.h>
#include <lib/fidl/llcpp/client_end.h>
#include <lib/fidl/llcpp/connect_service.h>
#include <lib/fidl/llcpp/result.h>
#include <lib/fidl/llcpp/server.h>
#include <lib/fidl/llcpp/server_end.h>
#include <lib/fidl/llcpp/service_handler_interface.h>
#include <lib/fidl/llcpp/sync_call.h>
#include <lib/fidl/llcpp/transaction.h>
#include <lib/fidl/txn_header.h>
#include <lib/zx/channel.h>
#endif // __Fuchsia__
#include <zircon/fidl.h>
namespace llcpp {
namespace fidl {
namespace test {
namespace service {
class SecondProtocol;
class FirstProtocol;
class SingleMemberService;
class MultiHomogeneousMemberService;
class MultiHeterogeneousMemberService;
class EmptyService;
extern "C" const fidl_type_t
fidl_test_service_SecondProtocolMethodOnSecondRequestTable;
extern "C" const fidl_type_t
fidl_test_service_SecondProtocolMethodOnSecondResponseTable;
class SecondProtocol final {
SecondProtocol() = delete;
public:
struct MethodOnSecondRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
explicit MethodOnSecondRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&::fidl::_llcpp_coding_AnyZeroArgMessageTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 16;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr uint32_t AltPrimarySize = 16;
static constexpr uint32_t AltMaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid)
: message_(_bytes, _byte_size, sizeof(MethodOnSecondRequest), nullptr,
0, 0) {
FIDL_ALIGNDECL MethodOnSecondRequest _request(_txid);
message_.LinearizeAndEncode<MethodOnSecondRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
MethodOnSecondRequest* request)
: message_(bytes, byte_size, sizeof(MethodOnSecondRequest), nullptr,
0, 0) {
message_.LinearizeAndEncode<MethodOnSecondRequest>(request);
}
UnownedEncodedMessage(const UnownedEncodedMessage&) = delete;
UnownedEncodedMessage(UnownedEncodedMessage&&) = delete;
UnownedEncodedMessage* operator=(const UnownedEncodedMessage&) = delete;
UnownedEncodedMessage* operator=(UnownedEncodedMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
#ifdef __Fuchsia__
const char* status_string() const { return message_.status_string(); }
#endif
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
template <typename ChannelLike>
void Write(ChannelLike&& client) {
message_.Write(std::forward<ChannelLike>(client));
}
private:
MethodOnSecondRequest& Message() {
return *reinterpret_cast<MethodOnSecondRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid)
: message_(bytes_, sizeof(bytes_), _txid) {}
explicit OwnedEncodedMessage(MethodOnSecondRequest* request)
: message_(bytes_, sizeof(bytes_), request) {}
OwnedEncodedMessage(const OwnedEncodedMessage&) = delete;
OwnedEncodedMessage(OwnedEncodedMessage&&) = delete;
OwnedEncodedMessage* operator=(const OwnedEncodedMessage&) = delete;
OwnedEncodedMessage* operator=(OwnedEncodedMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
#ifdef __Fuchsia__
const char* status_string() const { return message_.status_string(); }
#endif
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
template <typename ChannelLike>
void Write(ChannelLike&& client) {
message_.Write(std::forward<ChannelLike>(client));
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedEncodedMessage message_;
};
class DecodedMessage final : public ::fidl::internal::IncomingMessage {
public:
DecodedMessage(uint8_t* bytes, uint32_t byte_actual,
zx_handle_info_t* handles = nullptr,
uint32_t handle_actual = 0)
: ::fidl::internal::IncomingMessage(bytes, byte_actual, handles,
handle_actual) {
Decode<MethodOnSecondRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<MethodOnSecondRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
MethodOnSecondRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<MethodOnSecondRequest*>(bytes());
}
// Release the ownership of the decoded message. That means that the
// handles won't be closed When the object is destroyed. After calling
// this method, the DecodedMessage object should not be used anymore.
void ReleasePrimaryObject() { ResetBytes(); }
// These methods should only be used for testing purpose.
// They create an DecodedMessage using the bytes of an outgoing message
// and copying the handles.
static DecodedMessage FromOutgoingWithRawHandleCopy(
UnownedEncodedMessage* encoded_message) {
return DecodedMessage(encoded_message->GetOutgoingMessage());
}
static DecodedMessage FromOutgoingWithRawHandleCopy(
OwnedEncodedMessage* encoded_message) {
return DecodedMessage(encoded_message->GetOutgoingMessage());
}
private:
DecodedMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<MethodOnSecondRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
class EventHandlerInterface {
public:
EventHandlerInterface() = default;
virtual ~EventHandlerInterface() = default;
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
class MethodOnSecond final : public ::fidl::Result {
public:
explicit MethodOnSecond(
::fidl::UnownedClientEnd<::llcpp::fidl::test::service::SecondProtocol>
_client);
explicit MethodOnSecond(const ::fidl::Result& result)
: ::fidl::Result(result) {}
MethodOnSecond(MethodOnSecond&&) = delete;
MethodOnSecond(const MethodOnSecond&) = delete;
MethodOnSecond* operator=(MethodOnSecond&&) = delete;
MethodOnSecond* operator=(const MethodOnSecond&) = delete;
~MethodOnSecond() = default;
private:
};
};
// 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;
public:
class MethodOnSecond final : public ::fidl::Result {
public:
explicit MethodOnSecond(
::fidl::UnownedClientEnd<::llcpp::fidl::test::service::SecondProtocol>
_client);
explicit MethodOnSecond(const ::fidl::Result& result)
: ::fidl::Result(result) {}
MethodOnSecond(MethodOnSecond&&) = delete;
MethodOnSecond(const MethodOnSecond&) = delete;
MethodOnSecond* operator=(MethodOnSecond&&) = delete;
MethodOnSecond* operator=(const MethodOnSecond&) = delete;
~MethodOnSecond() = default;
};
};
// Methods to make a sync FIDL call directly on an unowned channel or a
// const reference to a
// |fidl::ClientEnd<::llcpp::fidl::test::service::SecondProtocol>|, 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(
::fidl::UnownedClientEnd<SecondProtocol> _client_end) {
return ResultOf::MethodOnSecond(_client_end);
}
};
class SyncClient final {
public:
SyncClient() = default;
explicit SyncClient(::fidl::ClientEnd<SecondProtocol> client_end)
: client_end_(std::move(client_end)) {}
~SyncClient() = default;
SyncClient(SyncClient&&) = default;
SyncClient& operator=(SyncClient&&) = default;
const ::fidl::ClientEnd<SecondProtocol>& client_end() const {
return client_end_;
}
::fidl::ClientEnd<SecondProtocol>& client_end() { return client_end_; }
const ::zx::channel& channel() const { return client_end_.channel(); }
::zx::channel* mutable_channel() { return &client_end_.channel(); }
// Allocates 16 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::MethodOnSecond MethodOnSecond() {
return ResultOf::MethodOnSecond(this->client_end());
}
private:
::fidl::ClientEnd<SecondProtocol> client_end_;
};
class AsyncEventHandler;
class ClientImpl;
// Pure-virtual interface to be implemented by a server.
// This interface uses typed channels (i.e. |fidl::ClientEnd<SomeProtocol>|
// and |fidl::ServerEnd<SomeProtocol>|).
// TODO(fxbug.dev/65212): Rename this to |Interface| after all users have
// migrated to the typed channels API.
class TypedChannelInterface
: public ::fidl::internal::IncomingMessageDispatcher {
public:
TypedChannelInterface() = default;
virtual ~TypedChannelInterface() = default;
// The marker protocol type within which this |TypedChannelInterface| class
// is defined.
using _EnclosingProtocol = SecondProtocol;
using MethodOnSecondCompleter = ::fidl::Completer<>;
virtual void MethodOnSecond(MethodOnSecondCompleter::Sync& _completer) = 0;
private:
::fidl::DispatchResult dispatch_message(fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) final;
};
// Pure-virtual interface to be implemented by a server.
class Interface : public TypedChannelInterface {
public:
Interface() = default;
virtual ~Interface() = default;
// The marker protocol type within which this |Interface| class is defined.
using TypedChannelInterface::_EnclosingProtocol;
using TypedChannelInterface::MethodOnSecondCompleter;
};
// 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 ::fidl::DispatchResult TryDispatch(TypedChannelInterface* impl,
fidl_incoming_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 ::fidl::DispatchResult Dispatch(TypedChannelInterface* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn);
// Same as |Dispatch|, but takes a |void*| instead of
// |TypedChannelInterface*|. Only used with |fidl::BindServer| to reduce
// template expansion. Do not call this method manually. Use |Dispatch|
// instead.
static ::fidl::DispatchResult TypeErasedDispatch(void* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) {
return Dispatch(static_cast<TypedChannelInterface*>(impl), msg, txn);
}
class EventSender;
class WeakEventSender;
};
extern "C" const fidl_type_t
fidl_test_service_FirstProtocolMethodOnFirstRequestTable;
extern "C" const fidl_type_t
fidl_test_service_FirstProtocolMethodOnFirstResponseTable;
class FirstProtocol final {
FirstProtocol() = delete;
public:
struct MethodOnFirstRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
explicit MethodOnFirstRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&::fidl::_llcpp_coding_AnyZeroArgMessageTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 16;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr uint32_t AltPrimarySize = 16;
static constexpr uint32_t AltMaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid)
: message_(_bytes, _byte_size, sizeof(MethodOnFirstRequest), nullptr,
0, 0) {
FIDL_ALIGNDECL MethodOnFirstRequest _request(_txid);
message_.LinearizeAndEncode<MethodOnFirstRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
MethodOnFirstRequest* request)
: message_(bytes, byte_size, sizeof(MethodOnFirstRequest), nullptr, 0,
0) {
message_.LinearizeAndEncode<MethodOnFirstRequest>(request);
}
UnownedEncodedMessage(const UnownedEncodedMessage&) = delete;
UnownedEncodedMessage(UnownedEncodedMessage&&) = delete;
UnownedEncodedMessage* operator=(const UnownedEncodedMessage&) = delete;
UnownedEncodedMessage* operator=(UnownedEncodedMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
#ifdef __Fuchsia__
const char* status_string() const { return message_.status_string(); }
#endif
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
template <typename ChannelLike>
void Write(ChannelLike&& client) {
message_.Write(std::forward<ChannelLike>(client));
}
private:
MethodOnFirstRequest& Message() {
return *reinterpret_cast<MethodOnFirstRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid)
: message_(bytes_, sizeof(bytes_), _txid) {}
explicit OwnedEncodedMessage(MethodOnFirstRequest* request)
: message_(bytes_, sizeof(bytes_), request) {}
OwnedEncodedMessage(const OwnedEncodedMessage&) = delete;
OwnedEncodedMessage(OwnedEncodedMessage&&) = delete;
OwnedEncodedMessage* operator=(const OwnedEncodedMessage&) = delete;
OwnedEncodedMessage* operator=(OwnedEncodedMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
#ifdef __Fuchsia__
const char* status_string() const { return message_.status_string(); }
#endif
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
template <typename ChannelLike>
void Write(ChannelLike&& client) {
message_.Write(std::forward<ChannelLike>(client));
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedEncodedMessage message_;
};
class DecodedMessage final : public ::fidl::internal::IncomingMessage {
public:
DecodedMessage(uint8_t* bytes, uint32_t byte_actual,
zx_handle_info_t* handles = nullptr,
uint32_t handle_actual = 0)
: ::fidl::internal::IncomingMessage(bytes, byte_actual, handles,
handle_actual) {
Decode<MethodOnFirstRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<MethodOnFirstRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
MethodOnFirstRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<MethodOnFirstRequest*>(bytes());
}
// Release the ownership of the decoded message. That means that the
// handles won't be closed When the object is destroyed. After calling
// this method, the DecodedMessage object should not be used anymore.
void ReleasePrimaryObject() { ResetBytes(); }
// These methods should only be used for testing purpose.
// They create an DecodedMessage using the bytes of an outgoing message
// and copying the handles.
static DecodedMessage FromOutgoingWithRawHandleCopy(
UnownedEncodedMessage* encoded_message) {
return DecodedMessage(encoded_message->GetOutgoingMessage());
}
static DecodedMessage FromOutgoingWithRawHandleCopy(
OwnedEncodedMessage* encoded_message) {
return DecodedMessage(encoded_message->GetOutgoingMessage());
}
private:
DecodedMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<MethodOnFirstRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
class EventHandlerInterface {
public:
EventHandlerInterface() = default;
virtual ~EventHandlerInterface() = default;
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
class MethodOnFirst final : public ::fidl::Result {
public:
explicit MethodOnFirst(
::fidl::UnownedClientEnd<::llcpp::fidl::test::service::FirstProtocol>
_client);
explicit MethodOnFirst(const ::fidl::Result& result)
: ::fidl::Result(result) {}
MethodOnFirst(MethodOnFirst&&) = delete;
MethodOnFirst(const MethodOnFirst&) = delete;
MethodOnFirst* operator=(MethodOnFirst&&) = delete;
MethodOnFirst* operator=(const MethodOnFirst&) = delete;
~MethodOnFirst() = default;
private:
};
};
// 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;
public:
class MethodOnFirst final : public ::fidl::Result {
public:
explicit MethodOnFirst(
::fidl::UnownedClientEnd<::llcpp::fidl::test::service::FirstProtocol>
_client);
explicit MethodOnFirst(const ::fidl::Result& result)
: ::fidl::Result(result) {}
MethodOnFirst(MethodOnFirst&&) = delete;
MethodOnFirst(const MethodOnFirst&) = delete;
MethodOnFirst* operator=(MethodOnFirst&&) = delete;
MethodOnFirst* operator=(const MethodOnFirst&) = delete;
~MethodOnFirst() = default;
};
};
// Methods to make a sync FIDL call directly on an unowned channel or a
// const reference to a
// |fidl::ClientEnd<::llcpp::fidl::test::service::FirstProtocol>|, 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(
::fidl::UnownedClientEnd<FirstProtocol> _client_end) {
return ResultOf::MethodOnFirst(_client_end);
}
};
class SyncClient final {
public:
SyncClient() = default;
explicit SyncClient(::fidl::ClientEnd<FirstProtocol> client_end)
: client_end_(std::move(client_end)) {}
~SyncClient() = default;
SyncClient(SyncClient&&) = default;
SyncClient& operator=(SyncClient&&) = default;
const ::fidl::ClientEnd<FirstProtocol>& client_end() const {
return client_end_;
}
::fidl::ClientEnd<FirstProtocol>& client_end() { return client_end_; }
const ::zx::channel& channel() const { return client_end_.channel(); }
::zx::channel* mutable_channel() { return &client_end_.channel(); }
// Allocates 16 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::MethodOnFirst MethodOnFirst() {
return ResultOf::MethodOnFirst(this->client_end());
}
private:
::fidl::ClientEnd<FirstProtocol> client_end_;
};
class AsyncEventHandler;
class ClientImpl;
// Pure-virtual interface to be implemented by a server.
// This interface uses typed channels (i.e. |fidl::ClientEnd<SomeProtocol>|
// and |fidl::ServerEnd<SomeProtocol>|).
// TODO(fxbug.dev/65212): Rename this to |Interface| after all users have
// migrated to the typed channels API.
class TypedChannelInterface
: public ::fidl::internal::IncomingMessageDispatcher {
public:
TypedChannelInterface() = default;
virtual ~TypedChannelInterface() = default;
// The marker protocol type within which this |TypedChannelInterface| class
// is defined.
using _EnclosingProtocol = FirstProtocol;
using MethodOnFirstCompleter = ::fidl::Completer<>;
virtual void MethodOnFirst(MethodOnFirstCompleter::Sync& _completer) = 0;
private:
::fidl::DispatchResult dispatch_message(fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) final;
};
// Pure-virtual interface to be implemented by a server.
class Interface : public TypedChannelInterface {
public:
Interface() = default;
virtual ~Interface() = default;
// The marker protocol type within which this |Interface| class is defined.
using TypedChannelInterface::_EnclosingProtocol;
using TypedChannelInterface::MethodOnFirstCompleter;
};
// 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 ::fidl::DispatchResult TryDispatch(TypedChannelInterface* impl,
fidl_incoming_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 ::fidl::DispatchResult Dispatch(TypedChannelInterface* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn);
// Same as |Dispatch|, but takes a |void*| instead of
// |TypedChannelInterface*|. Only used with |fidl::BindServer| to reduce
// template expansion. Do not call this method manually. Use |Dispatch|
// instead.
static ::fidl::DispatchResult TypeErasedDispatch(void* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) {
return Dispatch(static_cast<TypedChannelInterface*>(impl), msg, txn);
}
class EventSender;
class WeakEventSender;
};
class SingleMemberService final {
SingleMemberService() = default;
public:
static constexpr char Name[] = "fidl.test.service.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::ClientEnd<FirstProtocol>| on success,
// which can be used with |fidl::BindSyncClient| to create a synchronous
// client, or |fidl::Client| to create a client that supports both
// asynchronous and synchronous operations.
//
// # Errors
//
// On failure, returns a |zx::error| with status != 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 |ClientEnd| returned from this method.
::zx::status<::fidl::ClientEnd<FirstProtocol>> connect_single_member() {
auto endpoints = ::fidl::CreateEndpoints<FirstProtocol>();
if (endpoints.is_error()) {
return endpoints.take_error();
}
auto connection = connect_func_(::zx::unowned_channel(dir_),
::fidl::StringView("single_member"),
endpoints->server.TakeChannel());
if (connection.is_error()) {
return connection.take_error();
}
return ::zx::ok(std::move(endpoints->client));
}
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(::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<> add_single_member(
::fidl::ServiceHandlerInterface::MemberHandler<FirstProtocol> handler) {
return service_handler_->AddMember("single_member", std::move(handler));
}
private:
::fidl::ServiceHandlerInterface* service_handler_; // Not owned.
};
};
class MultiHomogeneousMemberService final {
MultiHomogeneousMemberService() = default;
public:
static constexpr char Name[] =
"fidl.test.service.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::ClientEnd<FirstProtocol>| on success,
// which can be used with |fidl::BindSyncClient| to create a synchronous
// client, or |fidl::Client| to create a client that supports both
// asynchronous and synchronous operations.
//
// # Errors
//
// On failure, returns a |zx::error| with status != 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 |ClientEnd| returned from this method.
::zx::status<::fidl::ClientEnd<FirstProtocol>> connect_first_member() {
auto endpoints = ::fidl::CreateEndpoints<FirstProtocol>();
if (endpoints.is_error()) {
return endpoints.take_error();
}
auto connection = connect_func_(::zx::unowned_channel(dir_),
::fidl::StringView("first_member"),
endpoints->server.TakeChannel());
if (connection.is_error()) {
return connection.take_error();
}
return ::zx::ok(std::move(endpoints->client));
}
// Connects to the member protocol "second_member".
// Returns a |fidl::ClientEnd<FirstProtocol>| on success,
// which can be used with |fidl::BindSyncClient| to create a synchronous
// client, or |fidl::Client| to create a client that supports both
// asynchronous and synchronous operations.
//
// # Errors
//
// On failure, returns a |zx::error| with status != 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 |ClientEnd| returned from this method.
::zx::status<::fidl::ClientEnd<FirstProtocol>> connect_second_member() {
auto endpoints = ::fidl::CreateEndpoints<FirstProtocol>();
if (endpoints.is_error()) {
return endpoints.take_error();
}
auto connection = connect_func_(::zx::unowned_channel(dir_),
::fidl::StringView("second_member"),
endpoints->server.TakeChannel());
if (connection.is_error()) {
return connection.take_error();
}
return ::zx::ok(std::move(endpoints->client));
}
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(::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<> add_first_member(
::fidl::ServiceHandlerInterface::MemberHandler<FirstProtocol> 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<> add_second_member(
::fidl::ServiceHandlerInterface::MemberHandler<FirstProtocol> handler) {
return service_handler_->AddMember("second_member", std::move(handler));
}
private:
::fidl::ServiceHandlerInterface* service_handler_; // Not owned.
};
};
class MultiHeterogeneousMemberService final {
MultiHeterogeneousMemberService() = default;
public:
static constexpr char Name[] =
"fidl.test.service.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::ClientEnd<FirstProtocol>| on success,
// which can be used with |fidl::BindSyncClient| to create a synchronous
// client, or |fidl::Client| to create a client that supports both
// asynchronous and synchronous operations.
//
// # Errors
//
// On failure, returns a |zx::error| with status != 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 |ClientEnd| returned from this method.
::zx::status<::fidl::ClientEnd<FirstProtocol>> connect_first_member() {
auto endpoints = ::fidl::CreateEndpoints<FirstProtocol>();
if (endpoints.is_error()) {
return endpoints.take_error();
}
auto connection = connect_func_(::zx::unowned_channel(dir_),
::fidl::StringView("first_member"),
endpoints->server.TakeChannel());
if (connection.is_error()) {
return connection.take_error();
}
return ::zx::ok(std::move(endpoints->client));
}
// Connects to the member protocol "second_member".
// Returns a |fidl::ClientEnd<SecondProtocol>| on success,
// which can be used with |fidl::BindSyncClient| to create a synchronous
// client, or |fidl::Client| to create a client that supports both
// asynchronous and synchronous operations.
//
// # Errors
//
// On failure, returns a |zx::error| with status != 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 |ClientEnd| returned from this method.
::zx::status<::fidl::ClientEnd<SecondProtocol>> connect_second_member() {
auto endpoints = ::fidl::CreateEndpoints<SecondProtocol>();
if (endpoints.is_error()) {
return endpoints.take_error();
}
auto connection = connect_func_(::zx::unowned_channel(dir_),
::fidl::StringView("second_member"),
endpoints->server.TakeChannel());
if (connection.is_error()) {
return connection.take_error();
}
return ::zx::ok(std::move(endpoints->client));
}
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(::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<> add_first_member(
::fidl::ServiceHandlerInterface::MemberHandler<FirstProtocol> 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<> add_second_member(
::fidl::ServiceHandlerInterface::MemberHandler<SecondProtocol>
handler) {
return service_handler_->AddMember("second_member", std::move(handler));
}
private:
::fidl::ServiceHandlerInterface* service_handler_; // Not owned.
};
};
class EmptyService final {
EmptyService() = default;
public:
static constexpr char Name[] = "fidl.test.service.EmptyService";
// 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) {
(void)dir;
(void)connect_func;
}
private:
};
// 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(::fidl::ServiceHandlerInterface* service_handler) {
(void)service_handler;
}
private:
};
};
} // namespace service
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<
::llcpp::fidl::test::service::SecondProtocol::MethodOnSecondRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::service::SecondProtocol::MethodOnSecondRequest>
: public std::true_type {};
static_assert(
sizeof(
::llcpp::fidl::test::service::SecondProtocol::MethodOnSecondRequest) ==
::llcpp::fidl::test::service::SecondProtocol::MethodOnSecondRequest::
PrimarySize);
template <>
struct IsFidlType<
::llcpp::fidl::test::service::FirstProtocol::MethodOnFirstRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::service::FirstProtocol::MethodOnFirstRequest>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::service::FirstProtocol::MethodOnFirstRequest) ==
::llcpp::fidl::test::service::FirstProtocol::MethodOnFirstRequest::
PrimarySize);
} // namespace fidl
namespace llcpp {
namespace fidl {
namespace test {
namespace service {
class SecondProtocol::AsyncEventHandler
: public SecondProtocol::EventHandlerInterface {
public:
AsyncEventHandler() = default;
virtual void Unbound(::fidl::UnbindInfo info) {}
};
class SecondProtocol::ClientImpl final : private ::fidl::internal::ClientBase {
public:
// Allocates 16 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result MethodOnSecond();
AsyncEventHandler* event_handler() const { return event_handler_.get(); }
private:
friend class ::fidl::Client<SecondProtocol>;
explicit ClientImpl(std::shared_ptr<AsyncEventHandler> event_handler)
: event_handler_(std::move(event_handler)) {}
std::optional<::fidl::UnbindInfo> DispatchEvent(
fidl_incoming_msg_t* msg) override;
std::shared_ptr<AsyncEventHandler> event_handler_;
};
// |EventSender| owns a server endpoint of a channel speaking
// the SecondProtocol protocol, and can send events in that protocol.
class SecondProtocol::EventSender {
public:
// Constructs an event sender with an invalid channel.
EventSender() = default;
explicit EventSender(
::fidl::ServerEnd<::llcpp::fidl::test::service::SecondProtocol>
server_end)
: server_end_(std::move(server_end)) {}
// The underlying server channel endpoint, which may be replaced at run-time.
const ::fidl::ServerEnd<SecondProtocol>& server_end() const {
return server_end_;
}
::fidl::ServerEnd<SecondProtocol>& server_end() { return server_end_; }
const ::zx::channel& channel() const { return server_end_.channel(); }
::zx::channel& channel() { return server_end_.channel(); }
// Whether the underlying channel is valid.
bool is_valid() const { return server_end_.is_valid(); }
private:
::fidl::ServerEnd<SecondProtocol> server_end_;
};
class SecondProtocol::WeakEventSender {
public:
private:
friend class ::fidl::ServerBindingRef<SecondProtocol>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<SecondProtocol>>
binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<SecondProtocol>> binding_;
};
class FirstProtocol::AsyncEventHandler
: public FirstProtocol::EventHandlerInterface {
public:
AsyncEventHandler() = default;
virtual void Unbound(::fidl::UnbindInfo info) {}
};
class FirstProtocol::ClientImpl final : private ::fidl::internal::ClientBase {
public:
// Allocates 16 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result MethodOnFirst();
AsyncEventHandler* event_handler() const { return event_handler_.get(); }
private:
friend class ::fidl::Client<FirstProtocol>;
explicit ClientImpl(std::shared_ptr<AsyncEventHandler> event_handler)
: event_handler_(std::move(event_handler)) {}
std::optional<::fidl::UnbindInfo> DispatchEvent(
fidl_incoming_msg_t* msg) override;
std::shared_ptr<AsyncEventHandler> event_handler_;
};
// |EventSender| owns a server endpoint of a channel speaking
// the FirstProtocol protocol, and can send events in that protocol.
class FirstProtocol::EventSender {
public:
// Constructs an event sender with an invalid channel.
EventSender() = default;
explicit EventSender(
::fidl::ServerEnd<::llcpp::fidl::test::service::FirstProtocol> server_end)
: server_end_(std::move(server_end)) {}
// The underlying server channel endpoint, which may be replaced at run-time.
const ::fidl::ServerEnd<FirstProtocol>& server_end() const {
return server_end_;
}
::fidl::ServerEnd<FirstProtocol>& server_end() { return server_end_; }
const ::zx::channel& channel() const { return server_end_.channel(); }
::zx::channel& channel() { return server_end_.channel(); }
// Whether the underlying channel is valid.
bool is_valid() const { return server_end_.is_valid(); }
private:
::fidl::ServerEnd<FirstProtocol> server_end_;
};
class FirstProtocol::WeakEventSender {
public:
private:
friend class ::fidl::ServerBindingRef<FirstProtocol>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<FirstProtocol>>
binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<FirstProtocol>> binding_;
};
} // namespace service
} // namespace test
} // namespace fidl
} // namespace llcpp