br_crypto/qp.rs
1use std::io::{Error};
2use quoted_printable::{decode as qp_decode, ParseMode, encode as qp_encode};
3
4pub fn decode<T: AsRef<[u8]>>(text: T) -> Result<Vec<u8>, Error> {
5 match qp_decode(text, ParseMode::Robust) {
6 Ok(e) => Ok(e),
7 Err(e) => Err(Error::other(e))
8 }
9}
10
11pub fn encode(text: &str) -> String {
12 let encoded = qp_encode(text);
13 String::from_utf8(encoded).unwrap()
14}
15