Impl FromStr
for Style
This commit is contained in:
parent
3ab6634661
commit
ac01fe7b82
1 changed files with 18 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::io::{self, ErrorKind, Read, Write};
|
use std::{io::{self, ErrorKind, Read, Write}, str};
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy)]
|
#[derive(Default, Clone, Copy)]
|
||||||
pub enum Style {
|
pub enum Style {
|
||||||
|
@ -9,6 +9,23 @@ pub enum Style {
|
||||||
Table,
|
Table,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ParseStyleError;
|
||||||
|
|
||||||
|
impl str::FromStr for Style {
|
||||||
|
type Err = ParseStyleError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"plain" => Ok(Self::Plain),
|
||||||
|
"spaces" => Ok(Self::Spaces),
|
||||||
|
"prefixed" => Ok(Self::Prefixed),
|
||||||
|
"table" => Ok(Self::Table),
|
||||||
|
_ => Err(ParseStyleError),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Encoder<R: Read, W: Write> {
|
pub struct Encoder<R: Read, W: Write> {
|
||||||
reader: R,
|
reader: R,
|
||||||
writer: W,
|
writer: W,
|
||||||
|
|
Loading…
Add table
Reference in a new issue