use std::{io::{self, ErrorKind, Read, Write}, str}; #[derive(Default, Clone, Copy)] pub enum Style { #[default] Plain, Spaces, Prefixed, Table, } #[derive(Debug)] pub struct ParseStyleError; impl str::FromStr for Style { type Err = ParseStyleError; fn from_str(s: &str) -> Result { match s { "plain" => Ok(Self::Plain), "spaces" => Ok(Self::Spaces), "prefixed" => Ok(Self::Prefixed), "table" => Ok(Self::Table), _ => Err(ParseStyleError), } } } pub struct Encoder { reader: R, writer: W, style: Style, wrap: Option, } impl Encoder { pub fn new(reader: R, writer: W, style: Option