diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-08-17 13:43:39 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-08-17 13:43:39 +0200 |
commit | 7cdc739ece681128dd4153e53acb85867accdd1b (patch) | |
tree | c6c202a7f596f1077a3b6295344367b937963a5d /src/libutil/serialise.hh | |
parent | bf290c2306d8554b82a9f1d30279b90bf8606fa6 (diff) | |
parent | e849b198720c60c186c8f9486c43c495ad436e1b (diff) |
Merge remote-tracking branch 'origin/master' into markdown
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r-- | src/libutil/serialise.hh | 11 |
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 { |