Closed
Description
This example uses rust-crypto 0.2.14
. Failing to import the Encryptor
trait that implements encrypt
causes an unexpected error message. The trait isn't private and importing it compiles as expected.
extern crate crypto;
use crypto::{ buffer, aes, blockmodes };
use crypto::buffer::{ ReadBuffer, WriteBuffer };
fn enc(key: &[u8], iv: &[u8], data: &[u8]) {
// Don't import the trait that implements encrypt()
//use crypto::symmetriccipher::Encryptor;
let mut encryptor = aes::cbc_encryptor(aes::KeySize::KeySize256,
key, iv, blockmodes::PkcsPadding);
let mut read_buffer = buffer::RefReadBuffer::new(data);
let mut buffer = [0; 4096];
let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer);
// Expected error: type `_` does not implement any method in scope named `encrypt`
// Get error: source trait is private
encryptor.encrypt(&mut read_buffer, &mut write_buffer, true);
}
fn main() {
}
src/main.rs:19:5: 19:65 error: source trait is private
src/main.rs:19 encryptor.encrypt(&mut read_buffer, &mut write_buffer, true);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rustc 1.0.0-nightly (706be5ba1 2015-02-05 23:14:28 +0000)