aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-13 14:47:53 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-13 14:51:17 +0000
commit85aacbee64680e60b22e8a729756b0a3882f8b8f (patch)
tree10388e457650366ed00a3c7f1763d10227ac40f9 /src/libutil/serialise.hh
parent859cd4acea8feadcc0b080ec1a75891e6277339c (diff)
Use `TeeSink` and `TeeSouce` in a few more places
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r--src/libutil/serialise.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index c29c6b29b..69ae0874a 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -225,6 +225,17 @@ struct SizedSource : Source
}
};
+/* A sink that that just counts the number of bytes given to it */
+struct LengthSink : Sink
+{
+ uint64_t length = 0;
+
+ virtual void operator () (const unsigned char * _, size_t len)
+ {
+ length += len;
+ }
+};
+
/* Convert a function into a sink. */
struct LambdaSink : Sink
{