Skip to content

Commit

Permalink
Add comments advising to close a digester or `Digesting{Reader,Writer…
Browse files Browse the repository at this point in the history
…}` before

calling `Digest()` (there was a comment at `Close()` for a digester but not at
`Digest()`).

Add comments that calling `Digest()` and then accepting more data or calling
`Digest()` again is not guaranteed to be supported.

PiperOrigin-RevId: 683632672
  • Loading branch information
QrczakMK committed Oct 9, 2024
1 parent 39b1b89 commit 3b7a321
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions riegeli/digests/digester_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ struct IsValidDigesterTarget<
// //
// // `OriginalDigestType` can be any type convertible to `DigestType` using
// // `DigestConverter`.
// //
// // Depending on the digester, `Digest()` can be more efficient if `Close()`
// // is called before.
// //
// // Many digesters support calling `Digest()` and then accepting more data
// // or calling `Digest()` again, but this is not guaranteed.
// OriginalDigestType Digest();
// ```
//
Expand Down
6 changes: 6 additions & 0 deletions riegeli/digests/digesting_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ class DigestingReader : public DigestingReaderBase {
// Digests buffered data if needed, and returns the digest.
//
// The digest is converted to `DesiredDigestType` using `DigestConverter`.
//
// Depending on the digester, `Digest()` can be more efficient if `Close()` is
// called before.
//
// Many digesters support calling `Digest()` and then accepting more data or
// calling `Digest()` again, but this is not guaranteed.
template <
typename DesiredDigestType = DigestType,
std::enable_if_t<HasDigestConverter<DigestType, DesiredDigestType>::value,
Expand Down
6 changes: 6 additions & 0 deletions riegeli/digests/digesting_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ class DigestingWriter : public DigestingWriterBase {
// Digests buffered data if needed, and returns the digest.
//
// The digest is converted to `DesiredDigestType` using `DigestConverter`.
//
// Depending on the digester, `Digest()` can be more efficient if `Close()` is
// called before.
//
// Many digesters support calling `Digest()` and then accepting more data or
// calling `Digest()` again, but this is not guaranteed.
template <
typename DesiredDigestType = DigestType,
std::enable_if_t<HasDigestConverter<DigestType, DesiredDigestType>::value,
Expand Down

0 comments on commit 3b7a321

Please sign in to comment.