I'm using npyz crate to load a *.npz
file and access the data. Here is my code:
use npyz::npz::NpzArchive;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open an npz file
let mut bytes = NpzArchive::open("file.npz")?;
let data = NpzArchive::new(&bytes)?;
Ok(())
}
I'm running into this error:
error[E0277]: the trait bound `&NpzArchive<BufReader<File>>: std::io::Read` is not satisfied
--> src/main.rs:8:32
|
8 | let data = NpzArchive::new(&bytes)?;
| --------------- ^^^^^^ the trait `std::io::Read` is not implemented for `&NpzArchive<BufReader<File>>`
| |
| required by a bound introduced by this call
|
note: required by a bound in `NpzArchive::<R>::new`
--> /Users/avataar/.cargo/registry/src/github.com-1ecc6299db9ec823/npyz-0.7.2/src/npz_feature.rs:28:9
|
28 | impl<R: io::Read + io::Seek> NpzArchive<R> {
| ^^^^^^^^ required by this bound in `NpzArchive::<R>::new`
error[E0277]: the trait bound `&NpzArchive<BufReader<File>>: Seek` is not satisfied
--> src/main.rs:8:32
|
8 | let data = NpzArchive::new(&bytes)?;
| --------------- ^^^^^^ the trait `Seek` is not implemented for `&NpzArchive<BufReader<File>>`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Seek`:
&File
&mut S
Box<S>
BufReader<R>
BufWriter<W>
File
std::io::Cursor<T>
std::io::Empty
note: required by a bound in `NpzArchive::<R>::new`
--> /Users/avataar/.cargo/registry/src/github.com-1ecc6299db9ec823/npyz-0.7.2/src/npz_feature.rs:28:20
|
28 | impl<R: io::Read + io::Seek> NpzArchive<R> {
| ^^^^^^^^ required by this bound in `NpzArchive::<R>::new`
My Cargo.toml
files dependencies looks like this:
[dependencies]
npyz = {version = "0.7.2", features = ["npz"] }