blob: 7f874eab426bcc2ffb0d16813f2c6f87ef69939c [file] [log] [blame]
// 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 fidl {
namespace test {
namespace json {
struct Empty;
class EmptyProtocol;
extern "C" const fidl_type_t v1_fidl_test_json_EmptyTable;
struct Empty {
static constexpr const fidl_type_t* Type = &v1_fidl_test_json_EmptyTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 1;
[[maybe_unused]] static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasPointer = false;
uint8_t __reserved = {};
};
extern "C" const fidl_type_t v1_fidl_test_json_EmptyProtocolSendRequestTable;
extern "C" const fidl_type_t v1_fidl_test_json_EmptyProtocolSendResponseTable;
extern "C" const fidl_type_t v1_fidl_test_json_EmptyProtocolReceiveRequestTable;
extern "C" const fidl_type_t v1_fidl_test_json_EmptyProtocolReceiveEventTable;
extern "C" const fidl_type_t
v1_fidl_test_json_EmptyProtocolSendAndReceiveRequestTable;
extern "C" const fidl_type_t
v1_fidl_test_json_EmptyProtocolSendAndReceiveResponseTable;
class EmptyProtocol final {
EmptyProtocol() = delete;
public:
struct SendRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_json_EmptyProtocolSendRequestTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr uint32_t AltPrimarySize = 24;
static constexpr uint32_t AltMaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
};
struct ReceiveResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_json_EmptyProtocolReceiveEventTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
};
struct SendAndReceiveResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_json_EmptyProtocolSendAndReceiveResponseTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
};
struct SendAndReceiveRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
static constexpr const fidl_type_t* Type =
&v1_fidl_test_json_EmptyProtocolSendAndReceiveRequestTable;
static constexpr uint32_t MaxNumHandles = 0;
static constexpr uint32_t PrimarySize = 24;
static constexpr uint32_t MaxOutOfLine = 0;
static constexpr uint32_t AltPrimarySize = 24;
static constexpr uint32_t AltMaxOutOfLine = 0;
static constexpr bool HasFlexibleEnvelope = false;
static constexpr bool HasPointer = false;
static constexpr bool ContainsUnion = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
using ResponseType = SendAndReceiveResponse;
};
struct EventHandlers {
fit::callback<zx_status_t(::llcpp::fidl::test::json::Empty e)> receive;
// Fallback handler when an unknown ordinal is received.
// Caller may put custom error handling logic here.
fit::callback<zx_status_t()> unknown;
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
private:
class Send_Impl final : private ::fidl::internal::StatusAndError {
using Super = ::fidl::internal::StatusAndError;
public:
Send_Impl(::zx::unowned_channel _client_end,
::llcpp::fidl::test::json::Empty e);
~Send_Impl() = default;
Send_Impl(Send_Impl&& other) = default;
Send_Impl& operator=(Send_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
};
template <typename ResponseType>
class SendAndReceive_Impl final
: private ::fidl::internal::OwnedSyncCallBase<ResponseType> {
using Super = ::fidl::internal::OwnedSyncCallBase<ResponseType>;
public:
SendAndReceive_Impl(::zx::unowned_channel _client_end,
::llcpp::fidl::test::json::Empty e);
~SendAndReceive_Impl() = default;
SendAndReceive_Impl(SendAndReceive_Impl&& other) = default;
SendAndReceive_Impl& operator=(SendAndReceive_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
using Super::Unwrap;
using Super::value;
using Super::operator->;
using Super::operator*;
};
public:
using Send = Send_Impl;
using SendAndReceive = SendAndReceive_Impl<SendAndReceiveResponse>;
};
// 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 Send_Impl final : private ::fidl::internal::StatusAndError {
using Super = ::fidl::internal::StatusAndError;
public:
Send_Impl(::zx::unowned_channel _client_end,
::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e);
~Send_Impl() = default;
Send_Impl(Send_Impl&& other) = default;
Send_Impl& operator=(Send_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
};
template <typename ResponseType>
class SendAndReceive_Impl final
: private ::fidl::internal::UnownedSyncCallBase<ResponseType> {
using Super = ::fidl::internal::UnownedSyncCallBase<ResponseType>;
public:
SendAndReceive_Impl(::zx::unowned_channel _client_end,
::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e,
::fidl::BytePart _response_buffer);
~SendAndReceive_Impl() = default;
SendAndReceive_Impl(SendAndReceive_Impl&& other) = default;
SendAndReceive_Impl& operator=(SendAndReceive_Impl&& other) = default;
using Super::error;
using Super::ok;
using Super::status;
using Super::Unwrap;
using Super::value;
using Super::operator->;
using Super::operator*;
};
public:
using Send = Send_Impl;
using SendAndReceive = SendAndReceive_Impl<SendAndReceiveResponse>;
};
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 24 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::Send Send(::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::Send Send(::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e);
// Allocates 48 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::SendAndReceive SendAndReceive(::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
UnownedResultOf::SendAndReceive SendAndReceive(
::fidl::BytePart _request_buffer, ::llcpp::fidl::test::json::Empty e,
::fidl::BytePart _response_buffer);
// Handle all possible events defined in this protocol.
// Blocks to consume exactly one message from the channel, then call the
// corresponding handler defined in |EventHandlers|. The return status of
// the handler function is folded with any transport-level errors and
// returned.
zx_status_t HandleEvents(EventHandlers handlers);
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 24 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::Send Send(::zx::unowned_channel _client_end,
::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::Send Send(::zx::unowned_channel _client_end,
::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e);
// Allocates 48 bytes of message buffer on the stack. No heap allocation
// necessary.
static ResultOf::SendAndReceive SendAndReceive(
::zx::unowned_channel _client_end, ::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
static UnownedResultOf::SendAndReceive SendAndReceive(
::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e, ::fidl::BytePart _response_buffer);
// Handle all possible events defined in this protocol.
// Blocks to consume exactly one message from the channel, then call the
// corresponding handler defined in |EventHandlers|. The return status of
// the handler function is folded with any transport-level errors and
// returned.
static zx_status_t HandleEvents(::zx::unowned_channel client_end,
EventHandlers handlers);
};
// 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 Send(
::zx::unowned_channel _client_end,
::fidl::DecodedMessage<SendRequest> params);
static ::fidl::DecodeResult<SendAndReceiveResponse> SendAndReceive(
::zx::unowned_channel _client_end,
::fidl::DecodedMessage<SendAndReceiveRequest> params,
::fidl::BytePart response_buffer);
};
// Pure-virtual interface to be implemented by a server.
class Interface {
public:
Interface() = default;
virtual ~Interface() = default;
using _Outer = EmptyProtocol;
using _Base = ::fidl::CompleterBase;
using SendCompleter = ::fidl::Completer<>;
virtual void Send(::llcpp::fidl::test::json::Empty e,
SendCompleter::Sync _completer) = 0;
class SendAndReceiveCompleterBase : public _Base {
public:
void Reply(::llcpp::fidl::test::json::Empty e);
void Reply(::fidl::BytePart _buffer, ::llcpp::fidl::test::json::Empty e);
void Reply(::fidl::DecodedMessage<SendAndReceiveResponse> params);
protected:
using ::fidl::CompleterBase::CompleterBase;
};
using SendAndReceiveCompleter =
::fidl::Completer<SendAndReceiveCompleterBase>;
virtual void SendAndReceive(::llcpp::fidl::test::json::Empty e,
SendAndReceiveCompleter::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);
}
static zx_status_t SendReceiveEvent(::zx::unowned_channel _chan,
::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via response buffers.
static zx_status_t SendReceiveEvent(::zx::unowned_channel _chan,
::fidl::BytePart _buffer,
::llcpp::fidl::test::json::Empty e);
// Messages are encoded in-place.
static zx_status_t SendReceiveEvent(
::zx::unowned_channel _chan,
::fidl::DecodedMessage<ReceiveResponse> params);
// Helper functions to fill in the transaction header in a
// |DecodedMessage<TransactionalMessage>|.
class SetTransactionHeaderFor final {
SetTransactionHeaderFor() = delete;
public:
static void SendRequest(
const ::fidl::DecodedMessage<EmptyProtocol::SendRequest>& _msg);
static void ReceiveResponse(
const ::fidl::DecodedMessage<EmptyProtocol::ReceiveResponse>& _msg);
static void SendAndReceiveRequest(
const ::fidl::DecodedMessage<EmptyProtocol::SendAndReceiveRequest>&
_msg);
static void SendAndReceiveResponse(
const ::fidl::DecodedMessage<EmptyProtocol::SendAndReceiveResponse>&
_msg);
};
};
} // namespace json
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::json::Empty> : public std::true_type {};
static_assert(std::is_standard_layout_v<::llcpp::fidl::test::json::Empty>);
static_assert(offsetof(::llcpp::fidl::test::json::Empty, __reserved) == 0);
static_assert(sizeof(::llcpp::fidl::test::json::Empty) ==
::llcpp::fidl::test::json::Empty::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::json::EmptyProtocol::SendRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<::llcpp::fidl::test::json::EmptyProtocol::SendRequest>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::json::EmptyProtocol::SendRequest) ==
::llcpp::fidl::test::json::EmptyProtocol::SendRequest::PrimarySize);
static_assert(offsetof(::llcpp::fidl::test::json::EmptyProtocol::SendRequest,
e) == 16);
template <>
struct IsFidlType<::llcpp::fidl::test::json::EmptyProtocol::ReceiveResponse>
: public std::true_type {};
template <>
struct IsFidlMessage<::llcpp::fidl::test::json::EmptyProtocol::ReceiveResponse>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::json::EmptyProtocol::ReceiveResponse) ==
::llcpp::fidl::test::json::EmptyProtocol::ReceiveResponse::PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::json::EmptyProtocol::ReceiveResponse, e) ==
16);
template <>
struct IsFidlType<
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveRequest>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveRequest) ==
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveRequest::
PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveRequest,
e) == 16);
template <>
struct IsFidlType<
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveResponse>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveResponse>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveResponse) ==
::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveResponse::
PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::json::EmptyProtocol::SendAndReceiveResponse,
e) == 16);
} // namespace fidl