template <typename FidlProtocol>

class WireSyncClient

Defined at line 593 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

|fidl::WireSyncClient| owns a client endpoint and exposes synchronous FIDL

calls. Prefer using this owning class over |fidl::WireCall| unless one has to

interface with very low-level functionality (such as making a call over a raw

zx_handle_t).

Generated FIDL APIs are accessed by 'dereferencing' the client value:

// Creates a sync client that speaks over |client_end|.

fidl::WireSyncClient client(std::move(client_end));

// Call the |Foo| method synchronously, obtaining the results from the

// return value.

fidl::WireResult result = client->Foo(args);

|fidl::WireSyncClient| is suitable for code without access to an async

dispatcher.

## Thread safety

|WireSyncClient| is generally thread-safe with a few caveats:

- Client objects can be safely sent between threads.

- One may invoke many FIDL methods in parallel on the same client. However,

FIDL method calls must be synchronized with operations that consume or

mutate the client object itself:

- Calling `Bind` or `TakeClientEnd`.

- Assigning a new value to the |WireSyncClient| variable.

- Moving the |WireSyncClient| to a different location.

- Destroying the |WireSyncClient|.

- There can be at most one `HandleOneEvent` call going on at the same time.

Public Methods

void WireSyncClient<FidlProtocol> ()

Creates an uninitialized client that is not bound to a client endpoint.

Prefer using the constructor overload that initializes the client

atomically during construction. Use this default constructor only when the

client must be constructed first before an endpoint could be obtained (for

example, if the client is an instance variable).

The client may be initialized later via |Bind|.

Defined at line 603 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

void WireSyncClient<FidlProtocol> (::fidl::ClientEnd<FidlProtocol> client_end)

Creates an initialized client. FIDL calls will be made on |client_end|.

Similar to |fidl::WireClient|, the client endpoint must be valid.

To just make a FIDL call uniformly on a client endpoint that may or may not

be valid, use the |fidl::WireCall(client_end)| helper. We may extend

|fidl::WireSyncClient

<P

>| with richer features hinging on having a valid

endpoint in the future.

Defined at line 613 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

void ~WireSyncClient<FidlProtocol> ()

Defined at line 618 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

void WireSyncClient<FidlProtocol> (WireSyncClient<FidlProtocol> && )

Defined at line 619 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

WireSyncClient<FidlProtocol> & operator= (WireSyncClient<FidlProtocol> && )

Defined at line 620 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

bool is_valid ()

Whether the client is initialized.

Defined at line 623 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

bool operator bool ()

Defined at line 624 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

const ::fidl::ClientEnd<FidlProtocol> & client_end ()

Borrows the underlying client endpoint. The client must have been

initialized.

Defined at line 628 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

void Bind (::fidl::ClientEnd<FidlProtocol> client_end)

Initializes the client with a |client_end|. FIDL calls will be made on this

endpoint.

It is not allowed to call |Bind| on an initialized client. To rebind a

|WireSyncClient| to a different endpoint, simply replace the

|WireSyncClient| variable with a new instance.

Defined at line 639 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

::fidl::ClientEnd<FidlProtocol> TakeClientEnd ()

Extracts the underlying endpoint from the client. After this operation, the

client goes back to an uninitialized state.

It is not safe to invoke this method while there are ongoing FIDL calls.

Defined at line 649 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

internal::SyncEndpointManagedVeneer<internal::WireSyncClientImpl<FidlProtocol>> operator-> ()

Returns an interface for making FIDL calls with managed memory.

Defined at line 655 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

template <typename MemoryResource>
auto buffer (MemoryResource && resource)

Returns an interface which exposes the caller-allocating API, using

the provided |resource| to allocate buffers necessary for each call.

See documentation on |SyncEndpointVeneer::buffer| for detailed behavior.

Defined at line 666 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h

::fidl::Status HandleOneEvent (fidl::WireSyncEventHandler<FidlProtocol> & event_handler)

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 |event_handler|. If the message was unknown or malformed, returns an

error without calling any virtual method.

Defined at line 678 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/channel.h