QAbstractGrpcChannel Class | Qt GRPC | Qt 6.12.0
Description: The QAbstractGrpcChannel class provides an interface for implementing the transport layer of gRPC operations.
Keywords: class

- Qt 6.12
- Qt GRPC
- C++ Classes
- QAbstractGrpcChannel
- Qt 6.12.0 Reference Documentation

# QAbstractGrpcChannel Class

The QAbstractGrpcChannel class provides an interface for implementing the transport layer of gRPC™ operations. More...

Header: | `#include <QAbstractGrpcChannel>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Grpc)` `target_link_libraries(mytarget PRIVATE Qt6::Grpc)`
Since: | Qt 6.5
Inherited By: | QGrpcHttp2Channel

- List of all members, including inherited members

## Public Functions

virtual | ~QAbstractGrpcChannel()
const QGrpcChannelOptions & | channelOptions() const &
virtual std::shared_ptr<QAbstractProtobufSerializer> | serializer() const = 0
`(since 6.8)` void | setChannelOptions(QGrpcChannelOptions &&options)
`(since 6.8)` void | setChannelOptions(const QGrpcChannelOptions &options)

## Protected Functions

| QAbstractGrpcChannel()
| QAbstractGrpcChannel(const QGrpcChannelOptions &options)

## Private Functions

`(since 6.7)` virtual void | bidiStream(QGrpcOperationContext *operationContext, QByteArray &&messageData) = 0
`(since 6.7)` virtual void | call(QGrpcOperationContext *operationContext, QByteArray &&messageData) = 0
`(since 6.7)` virtual void | clientStream(QGrpcOperationContext *operationContext, QByteArray &&messageData) = 0
`(since 6.7)` virtual void | serverStream(QGrpcOperationContext *operationContext, QByteArray &&messageData) = 0

## Detailed Description

Implement this interface to create a custom channel for gRPC™ transportation. The QGrpcHttp2Channel class is provided as a fully featured implementation of QAbstractGrpcChannel for HTTP/2 communication.

See also QGrpcChannelOptions and QGrpcHttp2Channel.

## Member Function Documentation

### `[protected]` QAbstractGrpcChannel::QAbstractGrpcChannel()

Default-constructs the QAbstractGrpcChannel.

### `[explicit protected]` QAbstractGrpcChannel::QAbstractGrpcChannel(const QGrpcChannelOptions &options)

Constructs the QAbstractGrpcChannel using the specified options.

### `[virtual noexcept]` QAbstractGrpcChannel::~QAbstractGrpcChannel()

Destroys the QAbstractGrpcChannel.

### `[pure virtual private, since 6.7]` void QAbstractGrpcChannel::bidiStream(QGrpcOperationContext *operationContext, QByteArray &&messageData)

This pure virtual function is called when a user starts a new RPC through the generated client interface. The operationContext should be used to communicate with the corresponding RPC handler, which is a derived type of the QGrpcOperation object.

This function should start the corresponding RPC on the channel side with the serialized messageData. The implementation must be asynchronous and must not block the calling thread.

Note: It is the channel's responsibility to support and restrict the subset of features that its RPC type allows.

This function was introduced in Qt 6.7.

### `[pure virtual private, since 6.7]` void QAbstractGrpcChannel::call(QGrpcOperationContext *operationContext, QByteArray &&messageData)

This pure virtual function is called when a user starts a new RPC through the generated client interface. The operationContext should be used to communicate with the corresponding RPC handler, which is a derived type of the QGrpcOperation object.

This function should start the corresponding RPC on the channel side with the serialized messageData. The implementation must be asynchronous and must not block the calling thread.

Note: It is the channel's responsibility to support and restrict the subset of features that its RPC type allows.

This function was introduced in Qt 6.7.

### `[noexcept]` const QGrpcChannelOptions &QAbstractGrpcChannel::channelOptions() const &

Returns the options utilized by the channel.

See also setChannelOptions.

### `[pure virtual private, since 6.7]` void QAbstractGrpcChannel::clientStream(QGrpcOperationContext *operationContext, QByteArray &&messageData)

This pure virtual function is called when a user starts a new RPC through the generated client interface. The operationContext should be used to communicate with the corresponding RPC handler, which is a derived type of the QGrpcOperation object.

This function should start the corresponding RPC on the channel side with the serialized messageData. The implementation must be asynchronous and must not block the calling thread.

Note: It is the channel's responsibility to support and restrict the subset of features that its RPC type allows.

This function was introduced in Qt 6.7.

### `[pure virtual]` std::shared_ptr<QAbstractProtobufSerializer> QAbstractGrpcChannel::serializer() const

This pure virtual function retrieves the QAbstractProtobufSerializer used for the serialization and deserialization of messages.

### `[pure virtual private, since 6.7]` void QAbstractGrpcChannel::serverStream(QGrpcOperationContext *operationContext, QByteArray &&messageData)

This pure virtual function is called when a user starts a new RPC through the generated client interface. The operationContext should be used to communicate with the corresponding RPC handler, which is a derived type of the QGrpcOperation object.

This function should start the corresponding RPC on the channel side with the serialized messageData. The implementation must be asynchronous and must not block the calling thread.

Note: It is the channel's responsibility to support and restrict the subset of features that its RPC type allows.

This function was introduced in Qt 6.7.

### `[since 6.8]` void QAbstractGrpcChannel::setChannelOptions(QGrpcChannelOptions &&options)

### `[since 6.8]` void QAbstractGrpcChannel::setChannelOptions(const QGrpcChannelOptions &options)

Sets the channel options.

Note: The updated channel options do not affect currently active calls or streams. The revised options will apply only to new RPCs made through this channel.

These functions were introduced in Qt 6.8.

See also channelOptions.