use std::str::FromStr;
pub mod errors;
use errors::ClientsParsingError;
#[derive(Debug)]
pub enum Clients {
CouchDB,
}
impl Clients {
pub fn to_list() -> [&'static str; 1] {
["couchdb"]
}
}
impl FromStr for Clients {
type Err = ClientsParsingError;
fn from_str(value: &str) -> Result<Clients, Self::Err> {
if value.to_lowercase() == "couchdb" {
Ok(Clients::CouchDB)
} else {
Err(ClientsParsingError::new(format!(
"{} is not a valid client, try one of {:?}",
value,
Clients::to_list()
)))
}
}
}
impl From<&str> for Clients {
fn from(value: &str) -> Clients {
Clients::from_str(value).unwrap()
}
}
impl From<String> for Clients {
fn from(value: String) -> Clients {
Clients::from(value.as_str())
}
}