- Qt 6.9
- Qt GRPC
- C++ Classes
- QGrpcCallOptions
- Qt 6.9.2 Reference Documentation

# QGrpcCallOptions Class

The QGrpcCallOptions class offers various options for fine-tuning individual RPCs. More...

Header: | `#include <QGrpcCallOptions>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Grpc)` `target_link_libraries(mytarget PRIVATE Qt6::Grpc)`
Since: | Qt 6.6
In QML: | GrpcCallOptions

- List of all members, including inherited members

## Public Functions

| QGrpcCallOptions()
| QGrpcCallOptions(const QGrpcCallOptions &other)
| QGrpcCallOptions(QGrpcCallOptions &&other)
| ~QGrpcCallOptions()
std::optional<std::chrono::milliseconds> | deadlineTimeout() const
QHash<QByteArray, QByteArray> | metadata() &&
const QHash<QByteArray, QByteArray> & | metadata() const &
QGrpcCallOptions & | setDeadlineTimeout(std::chrono::milliseconds timeout)
QGrpcCallOptions & | setMetadata(QHash<QByteArray, QByteArray> &&metadata)
QGrpcCallOptions & | setMetadata(const QHash<QByteArray, QByteArray> &metadata)
`(since 6.8)` void | swap(QGrpcCallOptions &other)
`(since 6.8)` QVariant | operator QVariant() const
QGrpcCallOptions & | operator=(QGrpcCallOptions &&other)
QGrpcCallOptions & | operator=(const QGrpcCallOptions &other)

## Related Non-Members

`(since 6.8)` QDebug | operator<<(QDebug debug, const QGrpcCallOptions &callOpts)

## Detailed Description

QGrpcCallOptions lets you customize individual remote procedure calls (RPCs). The generated client interface provides access points to pass the QGrpcCallOptions. These options supersede the ones set via QGrpcChannelOptions.

To configure the default options shared by RPCs, use QGrpcChannelOptions.

## Member Function Documentation

### QGrpcCallOptions &QGrpcCallOptions::setMetadata(QHash<QByteArray, QByteArray> &&metadata)

### QGrpcCallOptions &QGrpcCallOptions::setMetadata(const QHash<QByteArray, QByteArray> &metadata)

Sets the client metadata for a specific RPC and returns a reference to the updated object.

QGrpcHttp2Channel converts the metadata into appropriate HTTP/2 headers which will be added to the HTTP/2 request.

Note: Setting this field overrides the value set by QGrpcChannelOptions::setMetadata() for a specific RPC.

### QHash<QByteArray, QByteArray> QGrpcCallOptions::metadata() &&

### `[noexcept]` const QHash<QByteArray, QByteArray> &QGrpcCallOptions::metadata() const &

Returns the client metadata for a specific RPC. If this field is unset, returns empty metadata.

### QGrpcCallOptions::QGrpcCallOptions()

Default-constructs an empty QGrpcCallOptions.

### QGrpcCallOptions::QGrpcCallOptions(const QGrpcCallOptions &other)

Copy-constructs a QGrpcCallOptions from other.

### `[noexcept]` QGrpcCallOptions::QGrpcCallOptions(QGrpcCallOptions &&other)

Move-constructs a new QGrpcCallOptions from other.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

### `[noexcept]` QGrpcCallOptions::~QGrpcCallOptions()

Destroys the QGrpcCallOptions.

### `[noexcept]` std::optional<std::chrono::milliseconds> QGrpcCallOptions::deadlineTimeout() const

Returns the timeout duration that is used to calculate the deadline for a specific RPC.

If this field is unset, returns an empty `std::optional`.

See also setDeadlineTimeout().

### QGrpcCallOptions &QGrpcCallOptions::setDeadlineTimeout(std::chrono::milliseconds timeout)

Sets the timeout for a specific RPC and returns a reference to the updated object.

A deadline sets the limit for how long a client is willing to wait for a response from a server. The actual deadline is computed by adding the timeout to the start time of the RPC.

The deadline applies to the entire lifetime of an RPC, which includes receiving the final QGrpcStatus for a previously started call and can thus be unwanted for (long-lived) streams.

Note: Setting this field overrides the value set by QGrpcChannelOptions::setDeadline() for a specific RPC.

See also deadlineTimeout().

### `[noexcept, since 6.8]` void QGrpcCallOptions::swap(QGrpcCallOptions &other)

Swaps other with this object. This operation is very fast and never fails.

This function was introduced in Qt 6.8.

### `[since 6.8]` QVariant QGrpcCallOptions::operator QVariant() const

Constructs a new QVariant from this object.

This function was introduced in Qt 6.8.

### `[noexcept]` QGrpcCallOptions &QGrpcCallOptions::operator=(QGrpcCallOptions &&other)

Move-assigns other to this QGrpcCallOptions and returns a reference to the updated object.

Note: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

### QGrpcCallOptions &QGrpcCallOptions::operator=(const QGrpcCallOptions &other)

Assigns other to this QGrpcCallOptions and returns a reference to the updated object.

## Related Non-Members

### `[since 6.8]` QDebug operator<<(QDebug debug, const QGrpcCallOptions &callOpts)

Writes callOpts to the specified stream debug.

This function was introduced in Qt 6.8.