Skip to content

Commit

Permalink
WSHUB-458: cborencoder: Document the write callback function.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjlongland committed Jul 3, 2021
1 parent dcb1091 commit daf704a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,20 @@ typedef enum CborEncoderAppendType
CborEncoderAppendStringData = 1
} CborEncoderAppendType;

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

enum CborEncoderFlags
{
Expand Down

0 comments on commit daf704a

Please sign in to comment.