aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/serialise.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-14 17:00:13 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-14 17:00:13 +0000
commit3c8b5b62192b828c392e9122536d666e23278d8e (patch)
tree6302c4599c947dee9044e74f5f116aa927713c8f /src/libutil/serialise.hh
parent5f80aea795d3f6f78d682c7b99453b6fb7c9b6ba (diff)
parent13e49be6602314fe5e5d7beb8a807d5d892e864e (diff)
Merge remote-tracking branch 'upstream/master' into single-ca-drv-build
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 3650857aa..5309828bc 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -231,6 +231,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
{