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

Bridge sync and async #6

Open
piegamesde opened this issue Aug 3, 2021 · 2 comments
Open

Bridge sync and async #6

piegamesde opened this issue Aug 3, 2021 · 2 comments

Comments

@piegamesde
Copy link

If you want to play with std::io::Read/std::io::Write, check out the ringbuf crate directly, as it's Producer and Consumer types implement these traits, so I didn't include them here.

If I understand this correctly, this crate is a blocking+async wrapper around the ringbuf crate. My use case however requires having one side Write and the other side AsyncRead. I think this would fit quite well into this crate (simply copy the code and strip half of the work ^^)

@najamelan
Copy link
Owner

This is an interesting requirement. Is it an option for you to use block_on in the sync part? It would be the easiest solution. If not I could add Read and Write to futures_ringbuf.

@piegamesde
Copy link
Author

Yes, I've written a simple AsyncWrite -> Write adapter that uses block_on internally (this probably also exists in some helper library but it was few enough lines of code to build ad-hoc). It works fine, but conceptually it feels wasteful having compatibility layers going back and forth like this.

ringbuf already provides Read and Write implementations, but the key difference is that those are not blocking, returning Err(WouldBlock) instead.

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

No branches or pull requests

2 participants