Skip to content

Commit 5d6231d

Browse files
committed
WSHUB-458: cborencoder: Document the write callback function.
What is not known, is what the significance is of `CborEncoderAppendType`. It basically tells the writer the nature of the data being written, but the default implementation ignores this and just blindly appends it no matter what. That raises the question of why it's important enough that the writer function needs to know about it.
1 parent 508dab6 commit 5d6231d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/cbor.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,20 @@ typedef enum CborEncoderAppendType
212212
CborEncoderApendRawData = 2
213213
} CborEncoderAppendType;
214214

215-
typedef CborError (*CborEncoderWriteFunction)(void *, const void *, size_t, CborEncoderAppendType);
215+
/**
216+
* Writer interface call-back function. When there is data to be written to
217+
* the CBOR document, this routine will be called. The \a token parameter is
218+
* taken from the \a token argument provided to \ref cbor_encoder_init_writer
219+
* and may be used in any way the writer function sees fit.
220+
*
221+
* The \a data parameter contains a pointer to the raw bytes to be copied to
222+
* the output buffer, with \a len specifying how long the payload is, which
223+
* can be as small as a single byte or an entire (byte or text) string.
224+
*
225+
* The \a append parameter informs the writer function whether it is writing
226+
* a string or general CBOR data.
227+
*/
228+
typedef CborError (*CborEncoderWriteFunction)(void *token, const void *data, size_t len, CborEncoderAppendType append);
216229

217230
enum CborEncoderFlags
218231
{

0 commit comments

Comments
 (0)