Typedef anj_get_external_data_t

Typedef Documentation

typedef int anj_get_external_data_t(void *buffer, size_t *inout_size, size_t offset, void *user_args)

Callback to read a chunk of external data.

Called by the library when encoding a resource whose type is ANJ_DATA_TYPE_EXTERNAL_BYTES or ANJ_DATA_TYPE_EXTERNAL_STRING. It may be invoked multiple times until the entire resource value has been streamed.

The library guarantees sequential calls with monotonically increasing offset and no overlaps.

Param buffer:

Output buffer to be filled with data.

Param inout_size:

[inout]

  • On input: size of buffer in bytes.

  • On output: number of bytes actually written.

Param offset:

Absolute offset (in bytes) from the beginning of the resource value.

Param user_args:

Application-defined pointer passed unchanged to every callback.

Return:

  • 0 if the end of the resource was reached (all data provided),

  • a negative value on error,

  • ANJ_IO_NEED_NEXT_CALL if more data remains. In this case, the implementation must have filled the entire buffer (i.e., left inout_size unchanged).