Type Alias Result

Source
pub type Result<T> = Result<T, Error>;
Expand description

A specialized Result type for read and write operations for the scrypt encrypted data format.

§Examples

use scryptenc::{Decryptor, Encryptor};

fn encrypt(plaintext: &[u8], passphrase: &[u8]) -> Vec<u8> {
    Encryptor::new(&plaintext, passphrase).encrypt_to_vec()
}

fn decrypt(ciphertext: &[u8], passphrase: &[u8]) -> scryptenc::Result<Vec<u8>> {
    Decryptor::new(&ciphertext, passphrase).and_then(|c| c.decrypt_to_vec())
}

let data = b"Hello, world!\n";
let passphrase = b"passphrase";

let ciphertext = encrypt(data, passphrase);
assert_ne!(ciphertext, data);

let plaintext = decrypt(&ciphertext, passphrase).unwrap();
assert_eq!(plaintext, data);

Aliased Type§

pub enum Result<T> {
    Ok(T),
    Err(Error),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(Error)

Contains the error value