diff options
Diffstat (limited to 'serd/serd.h')
-rw-r--r-- | serd/serd.h | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/serd/serd.h b/serd/serd.h index 79f164ea..94499a4d 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -267,10 +267,55 @@ serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags); /** @} - @name URI + @name Sink @{ */ +/** + Sink function for raw string output. +*/ +typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); + +/** + Sink adapter that writes blocks to the target sink. + + This is itself a SerdSink which can be used with any SerdSink as a target to + transparently write chunked I/O to the output sink. This can significantly + improve write performance when the target is a file or similar resource. +*/ +typedef struct SerdBulkSinkImpl SerdBulkSink; + +/** + Create a new bulk sink adapter. + @param sink Target sink where completed blocks will be written. + @param stream Stream parameter for target sink. + @param block_size Size of blocks to write, and internal buffer size. +*/ +SERD_API +SerdBulkSink* +serd_bulk_sink_new(SerdSink sink, void* stream, size_t block_size); + +/** + Free a bulk sink adapter. +*/ +SERD_API +void +serd_bulk_sink_free(SerdBulkSink* bsink); + +/** + Write data to a bulk sink adapter. + + This function may safely be cast to SerdSink. +*/ +SERD_API +size_t +serd_bulk_sink_write(const void* buf, size_t len, SerdBulkSink* bsink); + +/** + @} + @name URI + @{ +*/ static const SerdURI SERD_URI_NULL = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; /** @@ -302,11 +347,6 @@ void serd_uri_resolve(const SerdURI* uri, const SerdURI* base, SerdURI* out); /** - Sink function for raw string output. -*/ -typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); - -/** Serialise @c uri with a series of calls to @c sink. */ SERD_API |