blob: 39b865bd6773dfee4e06c56f256c54a0e50fb835 [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, if any.
Digest get value => _value;
late final Digest _value;
/// Adds [value] to the sink.
///
/// Unlike most sinks, this may only be called once.
@override
void add(Digest value) {
_value = value;
}
@override
void close() {
// Ensure late final field was assigned before closing.
assert((_value as dynamic) != null);
}
}