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: | QGrpcBidirStream, QGrpcCallReply, QGrpcClientStream, and QGrpcServerStream |
Status: | Technical Preview |
Public Functions
void | cancel() |
(since 6.8) QAbstractProtobufSerializer::DeserializationError | deserializationError() const |
(since 6.8) QString | deserializationErrorString() const |
bool | isFinished() const |
const QGrpcMetadata & | metadata() const |
QLatin1StringView | method() const |
std::optional<T> | read() const |
(since 6.8) bool | read(QProtobufMessage *message) const |
Signals
void | errorOccurred(const QGrpcStatus &status) |
void | finished() |
Detailed Description
Member Function Documentation
void QGrpcOperation::cancel()
Attempts to cancel the operation in a channel and immediately emits QGrpcOperation::errorOccurred with the QGrpcStatus::Cancelled status code.
Any manipulation of the operation after this call has no effect.
[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::errorOccurred(const QGrpcStatus &status)
This signal is emitted when an error with status occurs in the channel.
See also QAbstractGrpcClient::errorOccurred.
[signal]
void QGrpcOperation::finished()
This signal indicates the end of communication for this call.
If this signal is emitted by the stream then this stream is successfully closed either by client or server.
[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 QGrpcMetadata &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> 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.
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.