Index: lib/src/digest_sink.dart |
diff --git a/lib/src/digest_sink.dart b/lib/src/digest_sink.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bb5c85f496d670a60d95a5fcfccbd16d87c326a6 |
--- /dev/null |
+++ b/lib/src/digest_sink.dart |
@@ -0,0 +1,29 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library crypto.digest_sink; |
+ |
+import 'digest.dart'; |
+ |
+/// A sink used to get a digest value out of [Hash.startChunkedConversion]. |
+class DigestSink extends Sink<Digest> { |
+ /// The value added to the sink, if any. |
+ Digest get value { |
+ assert(_value != null); |
+ return _value; |
+ } |
+ Digest _value; |
+ |
+ /// Adds [value] to the sink. |
+ /// |
+ /// Unlike most sinks, this may only be called once. |
+ void add(Digest value) { |
+ assert(_value == null); |
+ _value = value; |
+ } |
+ |
+ void close() { |
+ assert(_value != null); |
+ } |
+} |