Something strange is happening when I try to use the bytes crate via git instead of the crate from crates.io. It seems the BytesMut
type no longer impls BufMut
. I have a small reproducing example here:
Cargo.toml:
[package]
name = "foo"
version = "0.1.0"
edition = "2021"[dependencies]
#bytes = "1.6"
bytes = { git = "GitHub - tokio-rs/bytes: Utilities for working with bytes", branch = "master" }
tokio = { version = "*", features = ["full"] }
main.rs:
use tokio::fs::File;
use tokio::io::{self, AsyncReadExt};
use bytes::BytesMut;#[tokio::main]
async fn main() -> io::Result<()> {
let mut f = File::open("foo.txt").await?;
let mut buffer = BytesMut::with_capacity(10);
f.read_buf(&mut buffer).await?;
Ok(())
}
Error when using the dependency from git instead of as a crate:
error[E0277]: the trait bound
BytesMut: bytes::buf::buf_mut::BufMut
is not satisfied
--> src/main.rs:10:16
|
10 | f.read_buf(&mut buffer).await?;
| -------- ^^^^^^^^^^^ the traitbytes::buf::buf_mut::BufMut
is not implemented forBytesMut
| |
| required by a bound introduced by this call
|
= help: the following other types implement traitbytes::buf::buf_mut::BufMut
:
ReadBuf<'a>
Box
bytes::bytes_mut::BytesMut
bytes::buf::chain::Chain<T, U>
bytes::buf::limit::Limit
Vec
&mut T
&mut [u8]
&mut [MaybeUninit]
note: required by a bound intokio::io::AsyncReadExt::read_buf
--> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/io/util/async_read_ext.rs:249:16
|
246 | fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
| -------- required by a bound in this associated function
...
249 | B: BufMut + ?Sized,
| ^^^^^^ required by this bound inAsyncReadExt::read_buf
I'd be thankful for any pointers on what's going on