WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@majiayu000
Copy link
Contributor

Summary

  • Improve documentation for the Read trait explaining how it differs from tokio's AsyncRead
  • Add a complete example showing how to implement Read on a custom struct using put_slice
  • Expand ReadBufCursor documentation with examples for both safe (put_slice) and unsafe (as_mut/advance) usage patterns
  • Document when to use each approach

Motivation

Users have reported confusion when trying to implement the Read trait, as the documentation was sparse and the relationship between ReadBufCursor methods was unclear. The new documentation provides practical guidance with working examples.

Fixes #3649

Test plan

  • All existing tests pass (cargo test --features full)
  • Doc tests for new examples pass
  • Examples compile and demonstrate intended usage

Add comprehensive documentation for implementing the Read trait:
- Explain the difference from tokio's AsyncRead
- Provide a complete example of implementing Read using put_slice
- Document when to use unsafe methods

Improve ReadBufCursor documentation:
- Describe safe vs unsafe approaches
- Add examples for both put_slice and as_mut/advance usage
- Link to relevant methods

Fixes hyperium#3649
Drop the sentence comparing with tokio's AsyncRead and io-uring,
as suggested by maintainer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@majiayu000
Copy link
Contributor Author

Done, removed that sentence. Thanks for the review!

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much!

@seanmonstar seanmonstar merged commit 32b76f4 into hyperium:master Dec 19, 2025
22 checks passed
@majiayu000 majiayu000 deleted the fix-read-trait-docs branch December 19, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of documentation on Read trait

2 participants