blob: c3d1e19f8f20b52a9176210d1f627c5658267f2a [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/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/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 emptystruct {
struct Empty;
class EmptyProtocol;
extern "C" const fidl_type_t fidl_test_emptystruct_EmptyTable;
struct Empty {
static constexpr const fidl_type_t* Type = &fidl_test_emptystruct_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 = {};
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size, Empty* value)
: message_(bytes, byte_size, sizeof(Empty), nullptr, 0, 0) {
message_.LinearizeAndEncode<Empty>(value);
}
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_; }
private:
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(Empty* value)
: message_(bytes_, sizeof(bytes_), value) {}
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();
}
private:
FIDL_ALIGNDECL
uint8_t bytes_[FIDL_ALIGN(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<struct Empty>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<struct Empty>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
struct Empty* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<struct Empty*>(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<struct Empty>();
}
}
};
};
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendRequestTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendResponseTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolReceiveRequestTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolReceiveEventTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendAndReceiveRequestTable;
extern "C" const fidl_type_t
fidl_test_emptystruct_EmptyProtocolSendAndReceiveResponseTable;
class EmptyProtocol final {
EmptyProtocol() = delete;
public:
struct SendRequest final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::emptystruct::Empty e;
explicit SendRequest(zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::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_emptystruct_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 ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendRequest), nullptr, 0, 0) {
FIDL_ALIGNDECL SendRequest _request(_txid, e);
message_.LinearizeAndEncode<SendRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
SendRequest* request)
: message_(bytes, byte_size, sizeof(SendRequest), nullptr, 0, 0) {
message_.LinearizeAndEncode<SendRequest>(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_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendRequest& Message() {
return *reinterpret_cast<SendRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(bytes_, sizeof(bytes_), _txid, e) {}
explicit OwnedEncodedMessage(SendRequest* 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();
}
void Write(zx_handle_t client) { message_.Write(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<SendRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<SendRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
SendRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendRequest*>(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<SendRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
struct ReceiveResponse final {
FIDL_ALIGNDECL
fidl_message_header_t _hdr;
::llcpp::fidl::test::emptystruct::Empty e;
explicit ReceiveResponse(::llcpp::fidl::test::emptystruct::Empty& e)
: e(std::move(e)) {
_InitHeader();
}
ReceiveResponse() { _InitHeader(); }
static constexpr const fidl_type_t* Type =
&fidl_test_emptystruct_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 ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(_bytes, _byte_size, sizeof(ReceiveResponse), nullptr, 0,
0) {
FIDL_ALIGNDECL ReceiveResponse _response{e};
message_.LinearizeAndEncode<ReceiveResponse>(&_response);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
ReceiveResponse* response)
: message_(bytes, byte_size, sizeof(ReceiveResponse), nullptr, 0, 0) {
message_.LinearizeAndEncode<ReceiveResponse>(response);
}
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_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
ReceiveResponse& Message() {
return *reinterpret_cast<ReceiveResponse*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(::llcpp::fidl::test::emptystruct::Empty& e)
: message_(bytes_, sizeof(bytes_), e) {}
explicit OwnedEncodedMessage(ReceiveResponse* response)
: message_(bytes_, sizeof(bytes_), response) {}
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();
}
void Write(zx_handle_t client) { message_.Write(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<ReceiveResponse>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<ReceiveResponse>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
ReceiveResponse* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<ReceiveResponse*>(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* outgoing_message) {
return DecodedMessage(outgoing_message->GetOutgoingMessage());
}
static DecodedMessage FromOutgoingWithRawHandleCopy(
OwnedEncodedMessage* outgoing_message) {
return DecodedMessage(outgoing_message->GetOutgoingMessage());
}
private:
DecodedMessage(::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::emptystruct::Empty e;
explicit SendAndReceiveResponse(::llcpp::fidl::test::emptystruct::Empty& e)
: e(std::move(e)) {
_InitHeader();
}
SendAndReceiveResponse() { _InitHeader(); }
static constexpr const fidl_type_t* Type =
&fidl_test_emptystruct_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 ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kResponse;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendAndReceiveResponse),
nullptr, 0, 0) {
FIDL_ALIGNDECL SendAndReceiveResponse _response{e};
message_.LinearizeAndEncode<SendAndReceiveResponse>(&_response);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
SendAndReceiveResponse* response)
: message_(bytes, byte_size, sizeof(SendAndReceiveResponse), nullptr,
0, 0) {
message_.LinearizeAndEncode<SendAndReceiveResponse>(response);
}
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_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendAndReceiveResponse& Message() {
return *reinterpret_cast<SendAndReceiveResponse*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(::llcpp::fidl::test::emptystruct::Empty& e)
: message_(bytes_, sizeof(bytes_), e) {}
explicit OwnedEncodedMessage(SendAndReceiveResponse* response)
: message_(bytes_, sizeof(bytes_), response) {}
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();
}
void Write(zx_handle_t client) { message_.Write(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<SendAndReceiveResponse>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<SendAndReceiveResponse>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
SendAndReceiveResponse* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveResponse*>(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* outgoing_message) {
return DecodedMessage(outgoing_message->GetOutgoingMessage());
}
static DecodedMessage FromOutgoingWithRawHandleCopy(
OwnedEncodedMessage* outgoing_message) {
return DecodedMessage(outgoing_message->GetOutgoingMessage());
}
private:
DecodedMessage(::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::emptystruct::Empty e;
explicit SendAndReceiveRequest(zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::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_emptystruct_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 ::fidl::internal::TransactionalMessageKind MessageKind =
::fidl::internal::TransactionalMessageKind::kRequest;
using ResponseType = SendAndReceiveResponse;
class UnownedEncodedMessage final {
public:
UnownedEncodedMessage(uint8_t* _bytes, uint32_t _byte_size,
zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(_bytes, _byte_size, sizeof(SendAndReceiveRequest), nullptr,
0, 0) {
FIDL_ALIGNDECL SendAndReceiveRequest _request(_txid, e);
message_.LinearizeAndEncode<SendAndReceiveRequest>(&_request);
}
UnownedEncodedMessage(uint8_t* bytes, uint32_t byte_size,
SendAndReceiveRequest* request)
: message_(bytes, byte_size, sizeof(SendAndReceiveRequest), nullptr,
0, 0) {
message_.LinearizeAndEncode<SendAndReceiveRequest>(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_; }
void Write(zx_handle_t client) { message_.Write(client); }
private:
SendAndReceiveRequest& Message() {
return *reinterpret_cast<SendAndReceiveRequest*>(message_.bytes());
}
::fidl::OutgoingMessage message_;
};
class OwnedEncodedMessage final {
public:
explicit OwnedEncodedMessage(zx_txid_t _txid,
::llcpp::fidl::test::emptystruct::Empty& e)
: message_(bytes_, sizeof(bytes_), _txid, e) {}
explicit OwnedEncodedMessage(SendAndReceiveRequest* 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();
}
void Write(zx_handle_t client) { message_.Write(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<SendAndReceiveRequest>();
}
DecodedMessage(fidl_incoming_msg_t* msg)
: ::fidl::internal::IncomingMessage(msg) {
Decode<SendAndReceiveRequest>();
}
DecodedMessage(const DecodedMessage&) = delete;
DecodedMessage(DecodedMessage&&) = delete;
DecodedMessage* operator=(const DecodedMessage&) = delete;
DecodedMessage* operator=(DecodedMessage&&) = delete;
SendAndReceiveRequest* PrimaryObject() {
ZX_DEBUG_ASSERT(ok());
return reinterpret_cast<SendAndReceiveRequest*>(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<SendAndReceiveRequest>();
}
}
};
private:
void _InitHeader(zx_txid_t _txid);
};
class EventHandler {
public:
EventHandler() = default;
virtual ~EventHandler() = default;
virtual void Receive(ReceiveResponse* event) = 0;
// Method called when an unknown event is found. This methods gives the
// status which, in this case, is returned by HandleOneEvent.
virtual zx_status_t Unknown() = 0;
// Handle all possible events defined in this protocol.
// Blocks to consume exactly one message from the channel, then call the
// corresponding virtual method.
::fidl::Result HandleOneEvent(::zx::unowned_channel client_end);
};
// 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::emptystruct::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::emptystruct::Empty& e);
SendAndReceive(zx_handle_t _client,
::llcpp::fidl::test::emptystruct::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::emptystruct::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::emptystruct::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::emptystruct::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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::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::emptystruct::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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::Empty e,
::fidl::BufferSpan _response_buffer) {
return UnownedResultOf::SendAndReceive(
_client_end->get(), _request_buffer.data, _request_buffer.capacity, e,
_response_buffer.data, _response_buffer.capacity);
}
};
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::emptystruct::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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::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::emptystruct::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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::Empty e,
::fidl::BufferSpan _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 virtual method defined in |EventHandler|. The return status
// of the handler function is folded with any transport-level errors and
// returned.
::fidl::Result HandleOneEvent(EventHandler& event_handler) {
return event_handler.HandleOneEvent(::zx::unowned_channel(channel_));
}
private:
::zx::channel channel_;
};
struct AsyncEventHandlers;
class SendAndReceiveResponseContext;
class ClientImpl;
// Pure-virtual interface to be implemented by a server.
class Interface : public ::fidl::internal::IncomingMessageDispatcher {
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::emptystruct::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::emptystruct::Empty e);
::fidl::Result Reply(::fidl::BufferSpan _buffer,
::llcpp::fidl::test::emptystruct::Empty e);
protected:
using ::fidl::CompleterBase::CompleterBase;
};
using SendAndReceiveCompleter =
::fidl::Completer<SendAndReceiveCompleterBase>;
virtual void SendAndReceive(::llcpp::fidl::test::emptystruct::Empty e,
SendAndReceiveCompleter::Sync& _completer) = 0;
private:
::fidl::DispatchResult dispatch_message(fidl_incoming_msg_t* msg,
::fidl::Transaction* txn) final;
};
// 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);
}
class EventSender;
class WeakEventSender;
};
} // namespace emptystruct
} // namespace test
} // namespace fidl
} // namespace llcpp
namespace fidl {
template <>
struct IsFidlType<::llcpp::fidl::test::emptystruct::Empty>
: public std::true_type {};
template <>
struct IsStruct<::llcpp::fidl::test::emptystruct::Empty>
: public std::true_type {};
static_assert(
std::is_standard_layout_v<::llcpp::fidl::test::emptystruct::Empty>);
static_assert(offsetof(::llcpp::fidl::test::emptystruct::Empty, __reserved) ==
0);
static_assert(sizeof(::llcpp::fidl::test::emptystruct::Empty) ==
::llcpp::fidl::test::emptystruct::Empty::PrimarySize);
template <>
struct IsFidlType<::llcpp::fidl::test::emptystruct::EmptyProtocol::SendRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendRequest>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::emptystruct::EmptyProtocol::SendRequest) ==
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendRequest::PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::emptystruct::EmptyProtocol::SendRequest, e) ==
16);
template <>
struct IsFidlType<
::llcpp::fidl::test::emptystruct::EmptyProtocol::ReceiveResponse>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::emptystruct::EmptyProtocol::ReceiveResponse>
: public std::true_type {};
static_assert(
sizeof(::llcpp::fidl::test::emptystruct::EmptyProtocol::ReceiveResponse) ==
::llcpp::fidl::test::emptystruct::EmptyProtocol::ReceiveResponse::
PrimarySize);
static_assert(
offsetof(::llcpp::fidl::test::emptystruct::EmptyProtocol::ReceiveResponse,
e) == 16);
template <>
struct IsFidlType<
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveRequest>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveRequest>
: public std::true_type {};
static_assert(sizeof(::llcpp::fidl::test::emptystruct::EmptyProtocol::
SendAndReceiveRequest) ==
::llcpp::fidl::test::emptystruct::EmptyProtocol::
SendAndReceiveRequest::PrimarySize);
static_assert(
offsetof(
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveRequest,
e) == 16);
template <>
struct IsFidlType<
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveResponse>
: public std::true_type {};
template <>
struct IsFidlMessage<
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveResponse>
: public std::true_type {};
static_assert(sizeof(::llcpp::fidl::test::emptystruct::EmptyProtocol::
SendAndReceiveResponse) ==
::llcpp::fidl::test::emptystruct::EmptyProtocol::
SendAndReceiveResponse::PrimarySize);
static_assert(
offsetof(
::llcpp::fidl::test::emptystruct::EmptyProtocol::SendAndReceiveResponse,
e) == 16);
} // namespace fidl
namespace llcpp {
namespace fidl {
namespace test {
namespace emptystruct {
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::emptystruct::Empty e);
// Caller provides the backing storage for FIDL message via request and
// response buffers.
::fidl::Result Send(::fidl::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::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::emptystruct::Empty e,
::fit::callback<void(SendAndReceiveResponse* response)> _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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::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::emptystruct::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::BufferSpan _request_buffer,
::llcpp::fidl::test::emptystruct::Empty e,
::fidl::BufferSpan _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_;
};
// |EventSender| owns a server endpoint of a channel speaking
// the EmptyProtocol protocol, and can send events in that protocol.
class EmptyProtocol::EventSender {
public:
// Constructs an event sender with an invalid channel.
EventSender() = default;
// TODO(fxbug.dev/65212): EventSender should take a ::fidl::ServerEnd.
explicit EventSender(::zx::channel server_end)
: server_end_(std::move(server_end)) {}
// The underlying server channel endpoint, which may be replaced at run-time.
const ::zx::channel& channel() const { return server_end_; }
::zx::channel& channel() { return server_end_; }
// Whether the underlying channel is valid.
bool is_valid() const { return server_end_.is_valid(); }
zx_status_t Receive(::llcpp::fidl::test::emptystruct::Empty e) const;
// Caller provides the backing storage for FIDL message via response buffers.
zx_status_t Receive(::fidl::BufferSpan _buffer,
::llcpp::fidl::test::emptystruct::Empty e) const;
private:
::zx::channel server_end_;
};
class EmptyProtocol::WeakEventSender {
public:
zx_status_t Receive(::llcpp::fidl::test::emptystruct::Empty e) const {
if (auto _binding = binding_.lock()) {
return _binding->event_sender().Receive(std::move(e));
}
return ZX_ERR_CANCELED;
}
// Caller provides the backing storage for FIDL message via response buffers.
zx_status_t Receive(::fidl::BufferSpan _buffer,
::llcpp::fidl::test::emptystruct::Empty e) const {
if (auto _binding = binding_.lock()) {
return _binding->event_sender().Receive(std::move(_buffer), std::move(e));
}
return ZX_ERR_CANCELED;
}
private:
friend class ::fidl::ServerBindingRef<EmptyProtocol>;
explicit WeakEventSender(
std::weak_ptr<::fidl::internal::AsyncServerBinding<EmptyProtocol>>
binding)
: binding_(std::move(binding)) {}
std::weak_ptr<::fidl::internal::AsyncServerBinding<EmptyProtocol>> binding_;
};
} // namespace emptystruct
} // namespace test
} // namespace fidl
} // namespace llcpp