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

Inspect io wrappers #5033

Merged
merged 10 commits into from Sep 28, 2022
Merged

Inspect io wrappers #5033

merged 10 commits into from Sep 28, 2022

Commits on Sep 20, 2022

  1. tokio_util: add inspection wrapper for AsyncRead

    There are use cases like checking hashes of files that benefit from
    being able to inspect bytes read as they come in, while still letting
    the main code process the bytes as normal (e.g. deserializing into
    objects, knowing that if there's a hash failure, you'll discard the
    result).
    
    As this is non-trivial to get right (e.g. handling a `buf` that's not
    empty when passed to `poll_read`, add a wrapper `InspectReader`
    that gets this right, passing all newly read bytes to a supplied `FnMut`
    closure.
    
    Fixes: tokio-rs#4584
    farnz committed Sep 20, 2022
    Copy the full SHA
    a0a9051 View commit details
    Browse the repository at this point in the history
  2. tokio_util: add inspection wrapper for AsyncWrite

    When writing things out, it's useful to be able to inspect the bytes
    that are being written and do things like hash them as they go past.
    This isn't trivial to get right, due to partial writes and efficiently
    handling vectored writes (if used).
    
    Provide an `InspectWriter` wrapper that gets this right, giving a
    supplied `FnMut` closure a chance to inspect the buffers that have been
    successfully written out.
    
    Fixes: tokio-rs#4584
    farnz committed Sep 20, 2022
    Copy the full SHA
    e9520fe View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2022

  1. Copy the full SHA
    ed31c0d View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2022

  1. Copy the full SHA
    5b1ae95 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    cd68c48 View commit details
    Browse the repository at this point in the history
  3. make clippy happy

    farnz committed Sep 28, 2022
    Copy the full SHA
    9d15d7a View commit details
    Browse the repository at this point in the history
  4. use drain instead of a byte-by-byte loop

    Co-authored-by: Alice Ryhl <aliceryhl@google.com>
    farnz and Darksonn committed Sep 28, 2022
    Copy the full SHA
    ed89580 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    6e389c7 View commit details
    Browse the repository at this point in the history
  6. no empty slices on write

    farnz committed Sep 28, 2022
    Copy the full SHA
    0739402 View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    542ee97 View commit details
    Browse the repository at this point in the history