diff --git a/src/decode.rs b/src/decode.rs index b2cb1c7..77d42f8 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -43,13 +43,13 @@ impl Decoder { _ => unreachable!(), } let mut c = char::from(in_buf[0]); - if let Some(idx) = super::get_idx(c.to_ascii_uppercase()) { + if let Some(idx) = super::get_idx(c.to_ascii_uppercase().try_into().unwrap()) { out_buf[0] |= (idx << 4) as u8; } else { return Err(Error::IllegalChar(c)); } c = char::from(in_buf[1]); - if let Some(idx) = super::get_idx(c.to_ascii_uppercase()) { + if let Some(idx) = super::get_idx(c.to_ascii_uppercase().try_into().unwrap()) { out_buf[0] |= idx as u8; } else { return Err(Error::IllegalChar(c)); diff --git a/src/encode.rs b/src/encode.rs index 1902a3e..d64faf1 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -3,25 +3,45 @@ use { std::io::{ErrorKind, Read, Write}, }; +pub enum Style { + Plain, + Spaces, + SpacesWithHex, +} + +impl Default for Style { + fn default() -> Self { + Self::Plain + } +} + pub struct Encoder { reader: R, writer: W, + style: Style, + wrap: Option, } impl Encoder { /// Creates a new encoder with the given reader and writer. If alphabet is /// `None` the encoder will use the default rfc4648 alphabet. - pub fn new(reader: R, writer: W) -> Self { - Self { reader, writer } + pub fn new(reader: R, writer: W, style: Option