QGrpcSerializationFormat Class

The QGrpcSerializationFormat class holds the protobuf message serializer and the associated content-type suffix. More...

Header: #include <QGrpcSerializationFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: Qt 6.8

This class is equality-comparable.

Public Functions

QGrpcSerializationFormat(QGrpcSerializationFormat &&other)
~QGrpcSerializationFormat()
(since 6.8) void swap(QGrpcSerializationFormat &other)
QGrpcSerializationFormat &operator=(QGrpcSerializationFormat &&other)

Detailed Description

The QGrpcSerializationFormat class contains the serializer used for serializing and deserializing protobuf messages, as well as the associated content-type suffix, which indicates the message encoding in transport. For HTTP/2 specific details see the Content-Type section.

Note: The content-type is transport, and therefore implementation specific.

The class can be constructed using one of the SerializationFormat presets or a custom suffix and serializer:

 QGrpcSerializationFormat jsonFormat(QtGrpc::SerializationFormat::Json);

This creates a QProtobufJsonSerializer with the json suffix. For HTTP/2 transportation this results in the application/grpc+json content-type.

 class DummySerializer : public QAbstractProtobufSerializer
 {
     ...
 };
 QGrpcSerializationFormat dummyFormat("dummy", std::make_shared<DummySerializer>());

This uses DummySerializer for encoding and decoding messages with the dummy suffix. For HTTP/2 transportation this results in the application/grpc+dummy content-type.

Note: Custom serializers require server support for the specified format.

See also QGrpcChannelOptions::serializationFormat.

Member Function Documentation

[constexpr noexcept] QGrpcSerializationFormat::QGrpcSerializationFormat(QGrpcSerializationFormat &&other)

Move-constructs a new QGrpcSerializationFormat 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] QGrpcSerializationFormat::~QGrpcSerializationFormat()

Destroys the QGrpcSerializationFormat.

[noexcept, since 6.8] void QGrpcSerializationFormat::swap(QGrpcSerializationFormat &other)

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

This function was introduced in Qt 6.8.

[noexcept default] QGrpcSerializationFormat &QGrpcSerializationFormat::operator=(QGrpcSerializationFormat &&other)

Move-assigns other to this QGrpcSerializationFormat instance and returns a reference to it.

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.