QGrpcOperation Class | Qt GRPC 6.8.0
Description: The QGrpcOperation class implements common logic to handle the gRPC communication from the client side.

- Qt 6.8
- Qt GRPC
- C++ Classes
- QtGrpc (Technical Preview)
- QGrpcOperation
- Qt 6.8.0 Reference Documentation

# QGrpcOperation Class

The QGrpcOperation class implements common logic to handle the gRPC communication from the client side. More...

Header: | `#include <QGrpcOperation>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Grpc)` `target_link_libraries(mytarget PRIVATE Qt6::Grpc)`
Since: | Qt 6.5
Inherits: | QObject
Inherited By: | QGrpcBidiStream, QGrpcCallReply, QGrpcClientStream, and QGrpcServerStream
Status: | Technical Preview

- List of all members, including inherited members

## Public Functions

`(since 6.8)` QAbstractProtobufSerializer::DeserializationError | deserializationError() const
`(since 6.8)` QString | deserializationErrorString() const
bool | isFinished() const
const QHash<QByteArray, QByteArray> & | metadata() const &
QLatin1StringView | method() const
std::optional<T> | read() const
`(since 6.8)` bool | read(QProtobufMessage *message) const

## Public Slots

void | cancel()

## Signals

void | finished(const QGrpcStatus &status)

## Detailed Description

## Member Function Documentation

### `[slot]` void QGrpcOperation::cancel()

T.B.A

### `[since 6.8]` QAbstractProtobufSerializer::DeserializationError QGrpcOperation::deserializationError() const

Returns the last deserialization error.

This function was introduced in Qt 6.8.

See also QAbstractProtobufSerializer::deserializationError.

### `[since 6.8]` QString QGrpcOperation::deserializationErrorString() const

Returns the last deserialization error string.

This function was introduced in Qt 6.8.

See also QAbstractProtobufSerializer::deserializationErrorString.

### `[signal]` void QGrpcOperation::finished(const QGrpcStatus &status)

This signal indicates the end of communication for this call.

If this signal is emitted the respective operation when it's finished with the respective status.

Note: This signal is emitted only once, and in most cases, you will want to disconnect right after receiving it to avoid issues, such as lambda captures not being destroyed after receiving the signal. An easy way to achieve this is by using the Qt::SingleShotConnection ConnectionType.

### `[noexcept]` bool QGrpcOperation::isFinished() const

Returns true when QGrpcOperation finished its workflow, meaning it was finished, canceled, or error occurred, otherwise returns false.

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

Getter of the metadata received from the channel. For the HTTP2 channels it usually contains the HTTP headers received from the server.

### `[noexcept]` QLatin1StringView QGrpcOperation::method() const

Getter of the method that this operation was initialized with.

### template <typename T, QGrpcOperation::if_proto_message<T> = true> std::optional<T> QGrpcOperation::read() const

Reads a message from a raw byte array stored within this QGrpcOperation instance.

Returns an optional deserialized message. On failure, `std::nullopt` is returned.

The error can be retrieved using deserializationError.

Note: This function only participates in overload resolution if `T` is a subclass of QProtobufMessage.

See also read, deserializationError, and deserializationErrorString.

### `[since 6.8]` bool QGrpcOperation::read(QProtobufMessage *message) const

Reads a message from a raw byte array which is stored within this QGrpcOperation instance.

The function writes the deserialized value to the message pointer.

If the deserialization is successful, this function returns `true`. Otherwise, it returns `false`, and the error can be retrieved with deserializationError.

This function was introduced in Qt 6.8.

See also read, deserializationError, and deserializationErrorString.