blob: 99a2cdbe38a080c8d40f9dddd635729a1e60ef6b [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/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/linearized_and_encoded.h>
#include <lib/fidl/llcpp/memory.h>
#include <lib/fidl/llcpp/message.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/connect_service.h>
#include <lib/fidl/llcpp/result.h>
#include <lib/fidl/llcpp/server.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 json {
struct Empty;
class EmptyProtocol;
extern "C" const fidl_type_t fidl_test_json_EmptyTable;
struct Empty {
static constexpr const fidl_type_t* Type = &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;
static constexpr bool IsResource = false;
uint8_t __reserved = {};
void _CloseHandles();
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size, Empty* value)
: message_(bytes, byte_size, sizeof(Empty), nullptr, 0, 0) {
message_.LinearizeAndEncode<Empty>(value);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
private:
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(Empty* value)
: message_(bytes_, sizeof(bytes_), value) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
struct Empty* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<struct Empty*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message and
// copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<struct Empty>();
}
}
};
};
extern "C" const fidl_type_t fidl_test_json_EmptyProtocolSendRequestTable;
extern "C" const fidl_type_t fidl_test_json_EmptyProtocolSendResponseTable;
extern "C" const fidl_type_t fidl_test_json_EmptyProtocolReceiveRequestTable;
extern "C" const fidl_type_t fidl_test_json_EmptyProtocolReceiveEventTable;
extern "C" const fidl_type_t
fidl_test_json_EmptyProtocolSendAndReceiveRequestTable;
extern "C" const fidl_type_t
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;
explicit SendRequest(zx_txid_t _txid, ::llcpp::fidl::test::json::Empty& e)
: e(std::move(e)) {
_InitHeader(_txid);
}
explicit SendRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&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 IsResource = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid,
::llcpp::fidl::test::json::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendRequest), nullptr, 0, 0) {
// Destructors can't be called because it will lead to handle double
// close (here and in fidl::Encode).
FIDL_ALIGNDECL uint8_t _request_buffer[sizeof(SendRequest)];
auto& _request = *new (_request_buffer) SendRequest(_txid, e);
message_.LinearizeAndEncode<SendRequest>(&_request);
}
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size,
SendRequest* request)
: message_(bytes, byte_size, sizeof(SendRequest), nullptr, 0, 0) {
message_.LinearizeAndEncode<SendRequest>(request);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendRequest& Message() {
return *reinterpret_cast<SendRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(zx_txid_t _txid,
::llcpp::fidl::test::json::Empty& e)
: message_(bytes_, sizeof(bytes_), _txid, e) {}
explicit OwnedOutgoingMessage(SendRequest* request)
: message_(bytes_, sizeof(bytes_), request) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
void Write(zx_handle_t client) { message_.Write(client); }
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
SendRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendRequest*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message
// and copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<SendRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
struct ReceiveResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
explicit ReceiveResponse(::llcpp::fidl::test::json::Empty& e)
: e(std::move(e)) {
_InitHeader();
}
ReceiveResponse() { _InitHeader(); }
static constexpr const fidl_type_t* Type =
&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 IsResource = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size,
::llcpp::fidl::test::json::Empty& e)
: message_(_bytes, _byte_size, sizeof(ReceiveResponse), nullptr, 0,
0) {
// Destructors can't be called because it will lead to handle double
// close (here and in fidl::Encode).
FIDL_ALIGNDECL uint8_t _response_buffer[sizeof(ReceiveResponse)];
auto& _response = *new (_response_buffer) ReceiveResponse(e);
message_.LinearizeAndEncode<ReceiveResponse>(&_response);
}
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size,
ReceiveResponse* response)
: message_(bytes, byte_size, sizeof(ReceiveResponse), nullptr, 0, 0) {
message_.LinearizeAndEncode<ReceiveResponse>(response);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
ReceiveResponse& Message() {
return *reinterpret_cast<ReceiveResponse*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(::llcpp::fidl::test::json::Empty& e)
: message_(bytes_, sizeof(bytes_), e) {}
explicit OwnedOutgoingMessage(ReceiveResponse* response)
: message_(bytes_, sizeof(bytes_), response) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
void Write(zx_handle_t client) { message_.Write(client); }
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
ReceiveResponse* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<ReceiveResponse*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message
// and copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<ReceiveResponse>();
}
}
};
private:
void _InitHeader();
};
struct SendAndReceiveResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
explicit SendAndReceiveResponse(::llcpp::fidl::test::json::Empty& e)
: e(std::move(e)) {
_InitHeader();
}
SendAndReceiveResponse() { _InitHeader(); }
static constexpr const fidl_type_t* Type =
&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 IsResource = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size,
::llcpp::fidl::test::json::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendAndReceiveResponse),
nullptr, 0, 0) {
// Destructors can't be called because it will lead to handle double
// close (here and in fidl::Encode).
FIDL_ALIGNDECL uint8_t _response_buffer[sizeof(SendAndReceiveResponse)];
auto& _response = *new (_response_buffer) SendAndReceiveResponse(e);
message_.LinearizeAndEncode<SendAndReceiveResponse>(&_response);
}
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size,
SendAndReceiveResponse* response)
: message_(bytes, byte_size, sizeof(SendAndReceiveResponse), nullptr,
0, 0) {
message_.LinearizeAndEncode<SendAndReceiveResponse>(response);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendAndReceiveResponse& Message() {
return *reinterpret_cast<SendAndReceiveResponse*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(::llcpp::fidl::test::json::Empty& e)
: message_(bytes_, sizeof(bytes_), e) {}
explicit OwnedOutgoingMessage(SendAndReceiveResponse* response)
: message_(bytes_, sizeof(bytes_), response) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
void Write(zx_handle_t client) { message_.Write(client); }
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
SendAndReceiveResponse* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveResponse*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message
// and copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<SendAndReceiveResponse>();
}
}
};
private:
void _InitHeader();
};
struct SendAndReceiveRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::json::Empty e;
explicit SendAndReceiveRequest(zx_txid_t _txid,
::llcpp::fidl::test::json::Empty& e)
: e(std::move(e)) {
_InitHeader(_txid);
}
explicit SendAndReceiveRequest(zx_txid_t _txid) { _InitHeader(_txid); }
static constexpr const fidl_type_t* Type =
&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 IsResource = false;
static constexpr ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
using ResponseType = SendAndReceiveResponse;
class UnownedOutgoingMessage final {
public:
UnownedOutgoingMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid,
::llcpp::fidl::test::json::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendAndReceiveRequest), nullptr,
0, 0) {
// Destructors can't be called because it will lead to handle double
// close (here and in fidl::Encode).
FIDL_ALIGNDECL uint8_t _request_buffer[sizeof(SendAndReceiveRequest)];
auto& _request = *new (_request_buffer) SendAndReceiveRequest(_txid, e);
message_.LinearizeAndEncode<SendAndReceiveRequest>(&_request);
}
UnownedOutgoingMessage(uint8_t* bytes, uint32_t byte_size,
SendAndReceiveRequest* request)
: message_(bytes, byte_size, sizeof(SendAndReceiveRequest), nullptr,
0, 0) {
message_.LinearizeAndEncode<SendAndReceiveRequest>(request);
}
UnownedOutgoingMessage(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage(UnownedOutgoingMessage&&) = delete;
UnownedOutgoingMessage* operator=(const UnownedOutgoingMessage&) = delete;
UnownedOutgoingMessage* operator=(UnownedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.status() == ZX_OK; }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() { return message_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendAndReceiveRequest& Message() {
return *reinterpret_cast<SendAndReceiveRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedOutgoingMessage final {
public:
explicit OwnedOutgoingMessage(zx_txid_t _txid,
::llcpp::fidl::test::json::Empty& e)
: message_(bytes_, sizeof(bytes_), _txid, e) {}
explicit OwnedOutgoingMessage(SendAndReceiveRequest* request)
: message_(bytes_, sizeof(bytes_), request) {}
OwnedOutgoingMessage(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage(OwnedOutgoingMessage&&) = delete;
OwnedOutgoingMessage* operator=(const OwnedOutgoingMessage&) = delete;
OwnedOutgoingMessage* operator=(OwnedOutgoingMessage&&) = delete;
zx_status_t status() const { return message_.status(); }
bool ok() const { return message_.ok(); }
const char* error() const { return message_.error(); }
::fidl::OutgoingMessage& GetOutgoingMessage() {
return message_.GetOutgoingMessage();
}
void Write(zx_handle_t client) { message_.Write(client); }
private:
FIDL_ALIGNDECL
uint8_t bytes_[PrimarySize + MaxOutOfLine];
UnownedOutgoingMessage message_;
};
class IncomingMessage final : public ::fidl::internal::IncomingMessage {
public:
IncomingMessage(const IncomingMessage&) = delete;
IncomingMessage(IncomingMessage&&) = delete;
IncomingMessage* operator=(const IncomingMessage&) = delete;
IncomingMessage* operator=(IncomingMessage&&) = delete;
SendAndReceiveRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveRequest*>(bytes());
}
// These methods should only be used for testing purpose.
// They create an IncomingMessage using the bytes of an outgoing message
// and copying the handles.
static IncomingMessage FromOutgoingWithRawHandleCopy(
UnownedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
static IncomingMessage FromOutgoingWithRawHandleCopy(
OwnedOutgoingMessage* outgoing_message) {
return IncomingMessage(outgoing_message->GetOutgoingMessage());
}
private:
IncomingMessage(::fidl::OutgoingMessage& outgoing_message) {
Init(outgoing_message, nullptr, 0);
if (ok()) {
Decode<SendAndReceiveRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
struct EventHandlers {
fit::function<zx_status_t(ReceiveResponse* message)> receive;
// Fallback handler when an unknown ordinal is received.
// Caller may put custom error handling logic here.
fit::function<zx_status_t()> unknown;
};
// Collection of return types of FIDL calls in this protocol.
class ResultOf final {
ResultOf() = delete;
public:
class Send final : public ::fidl::Result {
public:
explicit Send(zx_handle_t _client, ::llcpp::fidl::test::json::Empty& e);
explicit Send(const ::fidl::Result& result) : ::fidl::Result(result) {}
Send(Send&&) = delete;
Send(const Send&) = delete;
Send* operator=(Send&&) = delete;
Send* operator=(const Send&) = delete;
~Send() = default;
private:
};
class SendAndReceive final : public ::fidl::Result {
public:
explicit SendAndReceive(zx_handle_t _client,
::llcpp::fidl::test::json::Empty& e);
SendAndReceive(zx_handle_t _client, ::llcpp::fidl::test::json::Empty& e,
zx_time_t _deadline);
explicit SendAndReceive(const ::fidl::Result& result)
: ::fidl::Result(result) {}
SendAndReceive(SendAndReceive&&) = delete;
SendAndReceive(const SendAndReceive&) = delete;
SendAndReceive* operator=(SendAndReceive&&) = delete;
SendAndReceive* operator=(const SendAndReceive&) = delete;
~SendAndReceive() = default;
SendAndReceiveResponse* Unwrap() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveResponse*>(bytes_);
}
const SendAndReceiveResponse* Unwrap() const {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<const SendAndReceiveResponse*>(bytes_);
}
SendAndReceiveResponse& value() { return *Unwrap(); }
const SendAndReceiveResponse& value() const { return *Unwrap(); }
SendAndReceiveResponse* operator->() { return &value(); }
const SendAndReceiveResponse* operator->() const { return &value(); }
SendAndReceiveResponse& operator*() { return value(); }
const SendAndReceiveResponse& operator*() const { return value(); }
private:
FIDL_ALIGNDECL
uint8_t bytes_[SendAndReceiveResponse::PrimarySize +
SendAndReceiveResponse::MaxOutOfLine];
};
};
// 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 Send final : public ::fidl::Result {
public:
explicit Send(zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity,
::llcpp::fidl::test::json::Empty& e);
explicit Send(const ::fidl::Result& result) : ::fidl::Result(result) {}
Send(Send&&) = delete;
Send(const Send&) = delete;
Send* operator=(Send&&) = delete;
Send* operator=(const Send&) = delete;
~Send() = default;
};
class SendAndReceive final : public ::fidl::Result {
public:
explicit SendAndReceive(zx_handle_t _client, uint8_t* _request_bytes,
uint32_t _request_byte_capacity,
::llcpp::fidl::test::json::Empty& e,
uint8_t* _response_bytes,
uint32_t _response_byte_capacity);
explicit SendAndReceive(const ::fidl::Result& result)
: ::fidl::Result(result) {}
SendAndReceive(SendAndReceive&&) = delete;
SendAndReceive(const SendAndReceive&) = delete;
SendAndReceive* operator=(SendAndReceive&&) = delete;
SendAndReceive* operator=(const SendAndReceive&) = delete;
~SendAndReceive() = default;
SendAndReceiveResponse* Unwrap() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveResponse*>(bytes_);
}
const SendAndReceiveResponse* Unwrap() const {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<const SendAndReceiveResponse*>(bytes_);
}
SendAndReceiveResponse& value() { return *Unwrap(); }
const SendAndReceiveResponse& value() const { return *Unwrap(); }
SendAndReceiveResponse* operator->() { return &value(); }
const SendAndReceiveResponse* operator->() const { return &value(); }
SendAndReceiveResponse& operator*() { return value(); }
const SendAndReceiveResponse& operator*() const { return value(); }
private:
uint8_t* bytes_;
};
};
// 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) {
return ResultOf::Send(_client_end->get(), 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) {
return UnownedResultOf::Send(_client_end->get(), _request_buffer.data(),
_request_buffer.capacity(), 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) {
return ResultOf::SendAndReceive(_client_end->get(), 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) {
return UnownedResultOf::SendAndReceive(
_client_end->get(), _request_buffer.data(),
_request_buffer.capacity(), e, _response_buffer.data(),
_response_buffer.capacity());
}
// 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 ::fidl::Result HandleEvents(::zx::unowned_channel client_end,
EventHandlers& handlers);
};
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) {
return ResultOf::Send(this->channel().get(), 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) {
return UnownedResultOf::Send(this->channel().get(),
_request_buffer.data(),
_request_buffer.capacity(), e);
}
// Allocates 48 bytes of message buffer on the stack. No heap allocation
// necessary.
ResultOf::SendAndReceive SendAndReceive(
::llcpp::fidl::test::json::Empty e) {
return ResultOf::SendAndReceive(this->channel().get(), 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) {
return UnownedResultOf::SendAndReceive(
this->channel().get(), _request_buffer.data(),
_request_buffer.capacity(), e, _response_buffer.data(),
_response_buffer.capacity());
}
// 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.
::fidl::Result HandleEvents(EventHandlers& handlers) {
return Call::HandleEvents(::zx::unowned_channel(channel_), handlers);
}
private:
::zx::channel channel_;
};
struct AsyncEventHandlers;
class SendAndReceiveResponseContext;
class ClientImpl;
// Pure-virtual interface to be implemented by a server.
class Interface {
public:
Interface() = default;
virtual ~Interface() = default;
// The marker protocol type within which this |Interface| class is defined.
using _EnclosingProtocol = EmptyProtocol;
using SendCompleter = ::fidl::Completer<>;
virtual void Send(::llcpp::fidl::test::json::Empty e,
SendCompleter::Sync& _completer) = 0;
class SendAndReceiveCompleterBase : public ::fidl::CompleterBase {
public:
// In the following methods, the return value indicates internal errors
// during the reply, such as encoding or writing to the transport. Note
// that any error will automatically lead to the destruction of the
// binding, after which the |on_unbound| callback will be triggered with a
// detailed reason.
//
// See //zircon/system/ulib/fidl/include/lib/fidl/llcpp/server.h.
//
// Because the reply status is identical to the unbinding status, it can
// be safely ignored.
::fidl::Result Reply(::llcpp::fidl::test::json::Empty e);
::fidl::Result Reply(::fidl::BytePart _buffer,
::llcpp::fidl::test::json::Empty e);
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 ::fidl::DispatchResult TryDispatch(Interface* 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(Interface* impl,
fidl_incoming_msg_t* msg,
::fidl::Transaction* txn);
// Same as |Dispatch|, but takes a |void*| instead of |Interface*|.
// 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<Interface*>(impl), msg, txn);
}
static zx_status_t SendReceiveEvent(::zx::unowned_channel _channel,
::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 _channel,
::fidl::BytePart _buffer,
::llcpp::fidl::test::json::Empty e);
class EventSender;
};
} // namespace json
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::json::Empty> : public std::true_type {};
template <>
struct IsStruct<::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
namespace llcpp {
namespace fidl {
namespace test {
namespace json {
struct EmptyProtocol::AsyncEventHandlers {
::fit::function<void(ReceiveResponse* msg)> receive;
};
class EmptyProtocol::SendAndReceiveResponseContext
: public ::fidl::internal::ResponseContext {
public:
SendAndReceiveResponseContext();
virtual void OnReply(EmptyProtocol::SendAndReceiveResponse* message) = 0;
private:
void OnReply(uint8_t* reply) override;
};
class EmptyProtocol::ClientImpl final : private ::fidl::internal::ClientBase {
public:
// Allocates 24 bytes of message buffer on the stack. No heap allocation
// necessary.
::fidl::Result Send(::llcpp::fidl::test::json::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
::fidl::Result Send(::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e);
// Asynchronous variant of |EmptyProtocol.SendAndReceive()|. Allocates 24
// bytes of request buffer on the stack. The callback is stored on the heap.
::fidl::Result SendAndReceive(
::llcpp::fidl::test::json::Empty e,
::fit::callback<void(::llcpp::fidl::test::json::Empty e)> _cb);
// Asynchronous variant of |EmptyProtocol.SendAndReceive()|. Caller provides
// the backing storage for FIDL message via request buffer. Ownership of
// _context is given unsafely to the binding until OnError() or OnReply() are
// called on it.
::fidl::Result SendAndReceive(::fidl::BytePart _request_buffer,
::llcpp::fidl::test::json::Empty e,
SendAndReceiveResponseContext* _context);
// Synchronous variant of |EmptyProtocol.SendAndReceive()|. Allocates 48 bytes
// of message buffer on the stack. No heap allocation necessary.
ResultOf::SendAndReceive SendAndReceive_Sync(
::llcpp::fidl::test::json::Empty e);
// Synchronous variant of |EmptyProtocol.SendAndReceive()|. Caller provides
// the backing storage for FIDL message via request and response buffers.
UnownedResultOf::SendAndReceive SendAndReceive_Sync(
::fidl::BytePart _request_buffer, ::llcpp::fidl::test::json::Empty e,
::fidl::BytePart _response_buffer);
private:
friend class ::fidl::Client<EmptyProtocol>;
explicit ClientImpl(AsyncEventHandlers handlers)
: handlers_(std::move(handlers)) {}
std::optional<::fidl::UnbindInfo> DispatchEvent(
fidl_incoming_msg_t* msg) override;
AsyncEventHandlers handlers_;
};
class EmptyProtocol::EventSender {
public:
zx_status_t Receive(::llcpp::fidl::test::json::Empty e) const {
if (auto _binding = binding_.lock()) {
return SendReceiveEvent(_binding->channel(), std::move(e));
}
return ZX_ERR_CANCELED;
}
zx_status_t Receive(::fidl::BytePart _buffer,
::llcpp::fidl::test::json::Empty e) const {
if (auto _binding = binding_.lock()) {
return SendReceiveEvent(_binding->channel(), std::move(_buffer),
std::move(e));
}
return ZX_ERR_CANCELED;
}
private:
friend class ::fidl::ServerBindingRef<EmptyProtocol>;
explicit EventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding> binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding> binding_;
};
} // namespace json
} // namespace test
} // namespace fidl
} // namespace llcpp