-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add documentation for SyncIoBridge with examples and alternatives #6815
base: master
Are you sure you want to change the base?
Conversation
6673e3e
to
30d38d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I think that most of the examples added here don't actually compile. Before we can merge this, we need to make them compile. I left some suggestions on how to do that.
Hi @hawkw. |
cd8edbc
to
6bdda28
Compare
Hi @Darksonn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting of the documentation and the examples looks about right now.
/// Use a [`tokio::io::AsyncRead`] synchronously as a [`std::io::Read`] or | ||
/// a [`tokio::io::AsyncWrite`] as a [`std::io::Write`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why, but the links to AsyncRead
and AsyncWrite
are no longer working in the rendered documentation. Are you able to get them to work again.
/// // Hash the data using the blake3 hashing function. | ||
/// let hash = blake3::hash(&data); | ||
/// | ||
/// Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes more sense to actually return the hash from this function.
/// // Hash the data using the blake3 hashing function. | |
/// let hash = blake3::hash(&data); | |
/// | |
/// Ok(()) | |
/// // Hash the data using the blake3 hashing function. | |
/// let hash = blake3::hash(&data); | |
/// | |
/// Ok(hash) |
/// // Finalize the hash after all data has been processed. | ||
/// let hash = hasher.finalize(); | ||
/// | ||
/// Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
/// ```ignore | ||
/// use async_compression::tokio::write::GzipEncoder; | ||
/// use tokio::io::AsyncReadExt; | ||
/// use tokio::io::Cursor; | ||
/// use std::io::AsyncRead; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example does not compile. I tried pasting it into the playground and got an error.
error[E0432]: unresolved import `tokio::io::Cursor`
--> src/main.rs:3:5
|
3 | use tokio::io::Cursor;
| ^^^^^^^^^^^^^^^^^ no `Cursor` in `io`
|
error[E0432]: unresolved import `std::io::AsyncRead`
--> src/main.rs:4:5
|
4 | use std::io::AsyncRead;
| ^^^^^^^^^^^^^^^^^^ no `AsyncRead` in `io`
Motivation
The SyncIoBridge documentation lacked clarity on its usage, potentially leading to inefficient use and suboptimal performance. Users needed better guidance on when to use it and how to handle common use cases effectively.
Solution
This update enhances the SyncIoBridge documentation by:
These improvements aim to help users use SyncIoBridge more effectively and avoid common pitfalls.
Rendered