Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and encapsulate ReadDecoder implementation #523

Merged
merged 9 commits into from
Oct 21, 2024

Commits on Oct 9, 2024

  1. Explicitly handle when Reader.finish is called twice.

    Before this commit calling `Reader.finish` a 2nd time would return a
    random, accidental error (`UnexpectedEof`), because of how
    `StreamingDecoder`'s `state` is set after processing the `IEND` chunk.
    After this commit, `Reader.finish` will handle this condition
    explicitly, in a similar same way to how `next_frame` handles being
    called when we have already consumed all the frames.
    anforowicz committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    7b7d1ff View commit details
    Browse the repository at this point in the history
  2. Stop tracking ReadDecoder::at_eof.

    After a recent commit, all public APIs of a `Reader` take care of not
    going beyond the `IEND` chunk and returning `PolledAfterEndOfImage`
    instead.  This means that tracking `at_eof` at the level of
    `ReadDecoder` is obsolete and leads to unnecessary complexity.  This
    commit refactors away this complexity.
    anforowicz committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    c21cac9 View commit details
    Browse the repository at this point in the history
  3. Reuse ReadDecoder::decode_next from finish_decoding.

    `ReadDecoder::finish_decoding` now reuses `decode_next` instead of
    duplicating some of its code.  Some duplication (e.g. handling of
    `Decoded::Nothing` remains - this will be taken care of in a subsequent
    commit).
    anforowicz committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    f578e4c View commit details
    Browse the repository at this point in the history
  4. Only call decode_next from other ReadDecoder methods.

    This commit means that `decode_next` can be a private method of
    `ReadDecoder` (this is not enforced yet, before a subsequent commit
    moves `ReadDecoder` into a separate `mod`ule).
    anforowicz committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    4cdd51c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c120416 View commit details
    Browse the repository at this point in the history
  6. Remove unnecessary loop from ReadDecoder.decode_next.

    Before this commit `fn decode_next` would `loop` to skip
    `Decoded::Nothing` events.  This is unnecessary, because all the callers
    of `decode_next` already account for `Decoded::Nothing` (explicitly or
    implicitly via a wildcard).
    anforowicz committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    8f3de8a View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    6b93ce4 View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. Add separate read_decoder.rs module to enforce encapsulation.

    This commit helps to keep some aspects of `ReadDecoder` private
    (e.g. its fields, `decode_next` methods, etc.).  This commit
    also means that `mod.rs` no longer directly depends on `Decoded`
    nor `StreamingDecoder`.
    anforowicz committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    2fb4b8e View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2024

  1. Mark ReadDecoder private

    kornelski committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    ae2dca9 View commit details
    Browse the repository at this point in the history