class IncomingHeaderAndMessage

Defined at line 185 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

|IncomingHeaderAndMessage| represents a FIDL transactional message on the

read path. Transactional messages are a message header followed by a a

regular message. See

https://fuchsia.dev/fuchsia-src/reference/fidl/language/wire-format?hl=en#transactional-messages

Each instantiation of the class should only be used for one message.

|IncomingHeaderAndMessage|s are created with the results from reading

from a channel. It automatically performs necessary validation on the message

header.

|IncomingHeaderAndMessage| relinquishes the ownership of the handles

after decoding. Instead, callers must adopt the decoded content into another

RAII class, such as |fidl::DecodedValue

<FidlType

>|.

Functions that take |IncomingHeaderAndMessage

&

| conditionally take

ownership of the message. For functions in the public API, they must then

indicate through their return value if they took ownership. For functions in

the binding internals, it is sufficient to only document the conditions where

minimum overhead is desired.

Functions that take |IncomingHeaderAndMessage

&

&

| always take ownership of

the message. In practice, this means that they must either decode the

message, or close the handles, or move the message into a deeper function

that takes |IncomingHeaderAndMessage

&

&

|.

For efficiency, errors are stored inside this object. Callers must check for

errors after construction, and after performing each operation on the object.

An |IncomingHeaderAndMessage| may be created from |fidl::MessageRead|:

// Read a transactional message from a Zircon channel.

fidl::IncomingHeaderAndMessage message = fidl::MessageRead(

zx::unowned_channel(...),

fidl::ChannelMessageStorageView{...});

if (!msg.ok()) { /* ... error handling ... */ }

Public Methods

IncomingHeaderAndMessage FromEncodedCMessage (const fidl_incoming_msg_t & c_msg)

Creates an |IncomingHeaderAndMessage| from a C |fidl_incoming_msg_t| already in

encoded form. This should only be used when interfacing with C APIs.

The handles in |c_msg| are owned by the returned |IncomingHeaderAndMessage| object.

The bytes must represent a transactional message.

Defined at line 69 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

void ~IncomingHeaderAndMessage ()

Defined at line 78 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

fidl_epitaph_t * maybe_epitaph ()

If the message is an epitaph, returns a pointer to the epitaph structure.

Otherwise, returns null.

Defined at line 80 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

fidl_incoming_msg_t ReleaseToEncodedCMessage ()

Convert the incoming message to its C API counterpart, releasing the

ownership of handles to the caller in the process. This consumes the

|IncomingHeaderAndMessage|.

This should only be called while the message is in its encoded form.

Defined at line 88 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

void CloseHandles ()

Closes the handles managed by this message. This may be used when the

code would like to consume a |IncomingHeaderAndMessage

&

&

| and close its handles,

but does not want to incur the overhead of moving it into a regular

|IncomingHeaderAndMessage| object, and running the destructor.

This consumes the |IncomingHeaderAndMessage|.

Defined at line 104 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

EncodedMessage SkipTransactionHeader ()

Consumes self and returns an |EncodedMessage| with the transaction

header bytes skipped.

Defined at line 106 of file ../../sdk/lib/fidl/cpp/wire/incoming_message.cc

template <typename HandleMetadata>
IncomingHeaderAndMessage Create (uint8_t * bytes, uint32_t byte_actual, fidl_handle_t * handles, HandleMetadata * handle_metadata, uint32_t handle_actual)

Creates an object which can manage a FIDL message. Allocated memory is not

owned by the |IncomingHeaderAndMessage|, but handles are owned by it and

cleaned up when the |IncomingHeaderAndMessage| is destructed.

The bytes must represent a transactional message. See

https://fuchsia.dev/fuchsia-src/reference/fidl/language/wire-format?hl=en#transactional-messages

Defined at line 194 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

template <typename Transport>
IncomingHeaderAndMessage Create (uint8_t * bytes, uint32_t byte_actual, fidl_handle_t * handles, typename Transport::HandleMetadata * handle_metadata, uint32_t handle_actual)

Creates an object which can manage a FIDL message. Allocated memory is not

owned by the |IncomingHeaderAndMessage|, but handles are owned by it and

cleaned up when the |IncomingHeaderAndMessage| is destructed.

The bytes must represent a transactional message. See

https://fuchsia.dev/fuchsia-src/reference/fidl/language/wire-format?hl=en#transactional-messages

Defined at line 208 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

IncomingHeaderAndMessage Create (const ::fidl::Status & failure)

Creates an empty incoming message representing an error (e.g. failed to read from

a channel).

|failure| must contain an error result.

Defined at line 228 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

void IncomingHeaderAndMessage (const IncomingHeaderAndMessage & )

Defined at line 232 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

IncomingHeaderAndMessage & operator= (const IncomingHeaderAndMessage & )

Defined at line 233 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

void IncomingHeaderAndMessage (IncomingHeaderAndMessage && other)

Defined at line 235 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

IncomingHeaderAndMessage & operator= (IncomingHeaderAndMessage && other)

Defined at line 239 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

fidl_message_header_t * header ()

Defined at line 249 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

uint8_t * bytes ()

Defined at line 258 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

uint32_t byte_actual ()

Defined at line 259 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

fidl_handle_t * handles ()

Defined at line 261 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

uint32_t handle_actual ()

Defined at line 262 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

fidl_handle_metadata_t * raw_handle_metadata ()

Defined at line 263 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

template <typename Transport>
typename Transport::HandleMetadata * handle_metadata ()

Defined at line 266 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/incoming_message.h

Friends

template <typename TransportObject>
IncomingHeaderAndMessage IncomingHeaderAndMessage (TransportObject && transport, typename internal::AssociatedTransport<TransportObject>::MessageStorageView storage, const ReadOptions & options)
class OutgoingMessage