本页内容

QGrpcInterceptionContext Class

为拦截器回调提供上下文信息。更多...

头文件: #include <QGrpcInterceptor>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
自: Qt 6.11

公共函数

QGrpcInterceptionContext(const QGrpcInterceptionContext &)
QGrpcInterceptionContext(QGrpcInterceptionContext &&)
~QGrpcInterceptionContext()
const QGrpcCallOptions &callOptions() const &
const QAbstractGrpcChannel &channel() const &
QtGrpc::RpcDescriptor descriptor() const
quint64 operationId() const
quint32 version() const
QGrpcInterceptionContext &operator=(QGrpcInterceptionContext &&)
QGrpcInterceptionContext &operator=(const QGrpcInterceptionContext &)

详细描述

QGrpcInterceptionContext 会被传递给拦截器回调,并提供对被拦截 RPC 相关信息的访问,例如通道、RPC 描述符或调用选项。

Qt GRPC 会为每次回调调用创建一个 QGrpcInterceptionContext 实例。该上下文对象仅在回调期间有效,且不得存储。

注意:QGrpcInterceptionContext 不可复制,也不可移动。

另请参阅 QGrpcStartInterceptor 、QGrpcInitialMetadataInterceptor 、QGrpcMessageReceivedInterceptor 、QGrpcWriteMessageInterceptor 、QGrpcWritesDoneInterceptor 、QGrpcTrailingMetadataInterceptor 、QGrpcFinishedInterceptor 以及QGrpcCancelInterceptor 。

成员函数文档

[delete] QGrpcInterceptionContext::QGrpcInterceptionContext(const QGrpcInterceptionContext &)

复制并构造一个QGrpcInterceptionContext 实例。该函数已被删除。

[delete] QGrpcInterceptionContext::QGrpcInterceptionContext(QGrpcInterceptionContext &&)

通过移动构造一个QGrpcInterceptionContext 实例。该函数已被删除。

[constexpr noexcept default] QGrpcInterceptionContext::~QGrpcInterceptionContext()

销毁QGrpcInterceptionContext 的实例。

[noexcept] const QGrpcCallOptions &QGrpcInterceptionContext::callOptions() const &

返回针对被拦截的 RPC 当前有效的调用选项。

[noexcept] const QAbstractGrpcChannel &QGrpcInterceptionContext::channel() const &

返回用于拦截该 RPC 的通道。

[noexcept] QtGrpc::RpcDescriptor QGrpcInterceptionContext::descriptor() const

返回标识被拦截的 RPC 的描述符。

[noexcept] quint64 QGrpcInterceptionContext::operationId() const

返回被拦截调用的唯一标识符。

在应用程序生命周期内,每个 ID 在所有通道中都是唯一的。

该标识符可用于关联跨多个挂钩点、属于同一 RPC 操作的拦截回调。

[noexcept] quint32 QGrpcInterceptionContext::version() const

返回拦截上下文的版本。

Qt 的未来版本可能会扩展 `QGrpcInterceptionContext`。此函数可用于识别上下文所支持的修订版本。

[delete] QGrpcInterceptionContext &QGrpcInterceptionContext::operator=(QGrpcInterceptionContext &&)

将other 按“移动-赋值”方式赋值给此QGrpcInterceptionContext 实例。该函数已被删除。

[delete] QGrpcInterceptionContext &QGrpcInterceptionContext::operator=(const QGrpcInterceptionContext &)

将other 复制并赋值给此QGrpcInterceptionContext 实例。该函数已被删除。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.