aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index dd88a23f..b724e810 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -102,6 +102,9 @@ typedef struct SerdWriterImpl SerdWriter;
/// An interface that receives a stream of RDF data
typedef struct SerdSinkImpl SerdSink;
+/// A sink for bytes that receives string output
+typedef struct SerdByteSinkImpl SerdByteSink;
+
/// Return status code
typedef enum {
SERD_SUCCESS, ///< No error
@@ -401,6 +404,41 @@ typedef size_t (*SerdWriteFunc)(const void* SERD_NONNULL buf,
void* SERD_NONNULL stream);
/**
+ Create a new byte sink.
+
+ @param write_func Function called with bytes to consume.
+ @param stream Context parameter passed to `sink`.
+ @param block_size Number of bytes to write per call.
+*/
+SERD_API
+SerdByteSink* SERD_ALLOCATED
+serd_byte_sink_new(SerdWriteFunc SERD_NONNULL write_func,
+ void* SERD_NULLABLE stream,
+ size_t block_size);
+
+/**
+ Write to `sink`.
+
+ Compatible with SerdWriteFunc.
+*/
+SERD_API
+size_t
+serd_byte_sink_write(const void* SERD_NONNULL buf,
+ size_t size,
+ size_t nmemb,
+ SerdByteSink* SERD_NONNULL sink);
+
+/// Flush any pending output in `sink` to the underlying write function
+SERD_API
+void
+serd_byte_sink_flush(SerdByteSink* SERD_NONNULL sink);
+
+/// Free `sink`
+SERD_API
+void
+serd_byte_sink_free(SerdByteSink* SERD_NULLABLE sink);
+
+/**
@}
@defgroup serd_syntax Syntax Utilities
@{