template <typename Interface>

class InterfaceHandle

Defined at line 40 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

The client endpoint of a FIDL channel.

The remote end of the channel expects this end of the channel to speak the

protocol associated with |Interface|. This type is the dual of

|InterfaceRequest|.

Unlike an |InterfacePtr|, an |InterfaceHandle| does not have thread affinity

and can therefore be transferred to another thread or another process. To

create an |InterfacePtr| to send messages on this channel, call the |Bind()|

method, either on the |InterfaceHandle| or the |InterfacePtr| object.

See also:

* |InterfaceRequest|, which is the server analog of an |InterfaceHandle|.

Public Methods

void InterfaceHandle<Interface> ()

Creates an |InterfaceHandle| whose underlying channel is invalid.

Defined at line 43 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void InterfaceHandle<Interface> (zx::channel channel)

Creates an |InterfaceHandle| that wraps the given |channel|.

Defined at line 46 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void InterfaceHandle<Interface> (const InterfaceHandle<Interface> & other)

Defined at line 48 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

InterfaceHandle<Interface> & operator= (const InterfaceHandle<Interface> & other)

Defined at line 49 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void InterfaceHandle<Interface> (InterfaceHandle<Interface> && other)

Defined at line 51 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

InterfaceHandle<Interface> & operator= (InterfaceHandle<Interface> && other)

Defined at line 53 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void InterfaceHandle<Interface> (std::nullptr_t )

Implicit conversion from nullptr to an |InterfaceHandle| without a valid

|channel|.

Defined at line 60 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

template <typename InterfacePtrType = InterfacePtr<Interface>, typename std::enable_if_t<
                                    std::is_same<InterfacePtr<Interface>,
                                                 typename std::remove_reference<InterfacePtrType>::type>::value ||
                                        std::is_same<SynchronousInterfacePtr<Interface>,
                                                     typename std::remove_reference<InterfacePtrType>::type>::value,
                                    int>
                                    zero_not_used = 0>
void InterfaceHandle<Interface> (InterfacePtrType && ptr)

Implicit conversion from |InterfacePtr| unbinds the channel from the

|InterfacePtr|.

This requires the caller to provide an rvalue reference, as the caller's

InterfacePtr is effectively moved out of.

Making this constructor templated ensures that it is not type-instantiated

unless it is used, making the InterfacePtr

<

->InterfaceHandle codependency

less fragile.

The std::enable_if_t avoids creation of unintended implicit type

conversions (especially from anything else that has an "Unbind()"),

presumably due to InterfacePtrType being inferred to be something other

than InterfacePtr

<Interface

>. However, if a caller is trying to use a type

that's only incorrect due to not being an rvalue reference, we do permit

this constructor to be selected, but then static_assert() with a message

suggesting std::move().

Defined at line 87 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

InterfaceRequest<Interface> NewRequest ()

Creates a new channel, retains one endpoint in this |InterfaceHandle| and

returns the other as an |InterfaceRequest|.

Typically, the returned |InterfaceRequest| is passed to another process,

which will implement the server endpoint for the |Interface| protocol.

If |NewRequest| fails to create the underlying channel, the returned

|InterfaceRequest| will return false from |is_valid()|.

Defined at line 107 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

template <typename InterfacePtr = InterfacePtr<Interface>>
InterfacePtr Bind ()

Creates an |InterfacePtr| bound to the channel in this |InterfaceHandle|.

This function transfers ownership of the underlying channel to the

returned |InterfacePtr|, which means the |is_valid()| method will return

false after this method returns.

Requires the current thread to have a default async_dispatcher_t (e.g., a

message loop) in order to read messages from the channel and to monitor the

channel for |ZX_CHANNEL_PEER_CLOSED|.

Making this method templated ensures that it is not type-instantiated

unless it is used, making the InterfacePtr

<

->InterfaceHandle codependency

less fragile.

Defined at line 129 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

template <typename SyncInterfacePtr = SynchronousInterfacePtr<Interface>>
SyncInterfacePtr BindSync ()

Defined at line 136 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

bool is_valid ()

Whether the underlying channel is valid.

Defined at line 143 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

bool operator bool ()

Defined at line 144 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

zx::channel TakeChannel ()

Transfers ownership of the underlying channel to the caller.

Defined at line 147 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

const zx::channel & channel ()

The underlying channel.

Defined at line 150 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void set_channel (zx::channel channel)

Defined at line 151 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void Encode (Encoder * encoder, size_t offset, std::optional<HandleInformation> maybe_handle_info)

Defined at line 153 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h

void Decode (Decoder * decoder, InterfaceHandle<Interface> * value, size_t offset)

Defined at line 160 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/interface_handle.h