aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd/write_result.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd/write_result.h')
-rw-r--r--include/serd/write_result.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/serd/write_result.h b/include/serd/write_result.h
new file mode 100644
index 00000000..14211354
--- /dev/null
+++ b/include/serd/write_result.h
@@ -0,0 +1,50 @@
+// Copyright 2011-2023 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef SERD_WRITE_RESULT_H
+#define SERD_WRITE_RESULT_H
+
+#include "serd/attributes.h"
+#include "serd/status.h"
+
+#include <stddef.h>
+
+SERD_BEGIN_DECLS
+
+/**
+ @defgroup serd_write_result Write Result
+ @ingroup serd_utilities
+ @{
+*/
+
+/**
+ A status code with an associated byte count.
+
+ This is returned by functions which write to a buffer to inform the caller
+ about the size written, or in case of overflow, size required.
+*/
+typedef struct {
+ /**
+ Status code.
+
+ This reports the status of the operation as usual, and also dictates the
+ meaning of `count`.
+ */
+ SerdStatus status;
+
+ /**
+ Number of bytes written or required.
+
+ On success, this is the total number of bytes written. On #SERD_OVERFLOW,
+ this is the number of bytes of output space that are required for success.
+ */
+ size_t count;
+} SerdWriteResult;
+
+/**
+ @}
+*/
+
+SERD_END_DECLS
+
+#endif // SERD_WRITE_RESULT_H