[][src]Struct qt_core::QCborStreamWriter

#[repr(C)]
pub struct QCborStreamWriter { /* fields omitted */ }

The QCborStreamWriter class is a simple CBOR encoder operating on a one-way stream.

C++ class: QCborStreamWriter.

C++ documentation:

The QCborStreamWriter class is a simple CBOR encoder operating on a one-way stream.

This class can be used to quickly encode a stream of CBOR content directly to either a QByteArray or QIODevice. CBOR is the Concise Binary Object Representation, a very compact form of binary data encoding that is compatible with JSON. It was created by the IETF Constrained RESTful Environments (CoRE) WG, which has used it in many new RFCs. It is meant to be used alongside the CoAP protocol.

QCborStreamWriter provides a StAX-like API, similar to that of QXmlStreamWriter. It is rather low-level and requires a bit of knowledge of CBOR encoding. For a simpler API, see QCborValue and especially the encoding function QCborValue::toCbor().

The typical use of QCborStreamWriter is to create the object on the target QByteArray or QIODevice, then call one of the append() overloads with the desired type to be encoded. To create arrays and maps, QCborStreamWriter provides startArray() and startMap() overloads, which must be terminated by the corresponding endArray() and endMap() functions.

The following example encodes the equivalent of this JSON content:

{ "label": "journald", "autoDetect": false, "condition": "libs.journald", "output": [ "privateFeature" ] }

writer.startMap(4); // 4 elements in the map

writer.append(QLatin1String("label")); writer.append(QLatin1String("journald"));

writer.append(QLatin1String("autoDetect")); writer.append(false);

writer.append(QLatin1String("condition")); writer.append(QLatin1String("libs.journald"));

writer.append(QLatin1String("output")); writer.startArray(1); writer.append(QLatin1String("privateFeature")); writer.endArray();

writer.endMap();

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]