blob: 9ba4df91e11db747c650ef96de4bc6ba28264aa0 [file] [log] [blame]
// 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.
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.
/// A value must have been added using [add] before reading the `value`.
Digest get value => _value!;
Digest? _value;
/// Adds [value] to the sink.
/// Unlike most sinks, this may only be called once.
void add(Digest value) {
if (_value != null) throw StateError('add may only be called once.');
_value = value;
void close() {
if (_value == null) throw StateError('add must be called once.');