Code examples for decrypt gives type error
cortex opened this issue · comments
Joakim Lundborg commented
I tried creating an empty repository with the following code, directly from the example for decrypt
extern crate gpgme;
use std::fs::File;
use gpgme::{Context, Data, Protocol};
fn main(){
let mut ctx = Context::from_protocol(Protocol::OpenPgp).unwrap();
let mut cipher = Data::load("some file").unwrap();
let mut plain = Vec::new();
let mut input = File::open("some_file").unwrap();
let mut output = Vec::new();
ctx.decrypt(&mut input, &mut plain).unwrap();
}
This however gives me a type error:
error[E0308]: mismatched types
--> main.rs:12:17
|
12 | ctx.decrypt(&mut input, &mut plain).unwrap();
| ^^^^^^^^^^ expected struct `gpgme::Data`, found struct `std::fs::File`
|
= note: expected type `&mut gpgme::Data<'_>`
found type `&mut std::fs::File`
error[E0308]: mismatched types
--> main.rs:12:29
|
12 | ctx.decrypt(&mut input, &mut plain).unwrap();
| ^^^^^^^^^^ expected struct `gpgme::Data`, found struct `std::vec::Vec`
|
= note: expected type `&mut gpgme::Data<'_>`
found type `&mut std::vec::Vec<_>`
= help: here are some functions which might fulfill your needs:
- .remove(...)
- .swap_remove(...)
error: aborting due to 2 previous errors
error: Could not compile `gpgtest`.
It works when I instantiate a gpgme::Data variable instead of a Vec. What I find quite strange is that the example in examples/decrypt.rs compiles just fine for me if I run cargo run --example decrypt
.
Joakim Lundborg commented
Ok, I figured out that this is actually a breaking API change in master, the examples work when I stick
gpgme = { git = "https://github.com/johnschug/rust-gpgme", branch = "master" }
into my Cargo.toml. Time for a new release in crates.io?