-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement async versions of VarIntReader and VarIntWriter #4
Comments
Note that I ccurrently find it hard to implement this in a straight-forward way as a super-trait of async fn read_and_verify() -> io::Result<()> {
let mut f = tokio::fs::File::open("/tmp/varintbytes").await?;
let i1: u32 = f.read_varint_async().await?;
let i2: u32 = f.read_varint_async().await?;
let i3: u32 = f.read_varint_async().await?;
assert!(f.read_varint_async().await.is_err());
Ok(())
} error[E0599]: no method named `read_varint_async` found for type `tokio::fs::file::File` in the current scope
--> src/main.rs:22:15
|
22 | assert!(f.read_varint_async().await.is_err());
| ^^^^^^^^^^^^^^^^^ method not found in `tokio::fs::file::File`
|
= note: the method `read_varint_async` exists but the following trait bounds were not satisfied:
`tokio::fs::file::File : integer_encoding::reader::VarIntAsyncReader` despite If I don't manage to understand it, maybe we will start by using a bare function returning a future, which will not be quite as elegant, but do the same. |
@dermesser Can you push your code changes to a branch? I can have a look and try to fix the issue. |
@devashishdxt the example is now in branch |
@dermesser Thanks. I’ll take a look tomorrow. |
I was using futures::AsyncRead and wondered why tokio::fs::File didn't implement it; tokio has its own AsyncRead... Related to: #4
the mystery has been solved; I was using traits from |
You can try using feature based approach to support both the versions. Something similar to this. |
I'm still skeptic about the current chaos in async rust. I believe tokio is the way forward, not the futures crate, isn't it? |
I agree with you. I also think that |
I might just use this occasion to ask - do you know what exactly is the relation between tokio and futures? Are they symbiotic? Competing? I've heard more from tokio, but otherwise my opinion is based on not much more than gut feeling. |
There is a lot going on in Rust’s async world. If you want to understand why |
Thank you for the link. I suppose I will try using your suggested approach with the features; it should only affect the AsyncRead/AsyncWrite (and similar) traits after all. If I understand correctly, futures themselves are compatible across the runtimes/reactors in both crates, if they use the standard future type. bleugh :) |
Hi, what could be the reason that we get lots of funny errors since a few days? Seems related to this . |
This does look like the reason, although there are roughly two sub-reasons:
|
Using
futures::io
traits:AsyncRead
andAsyncWrite
.The text was updated successfully, but these errors were encountered: