patron 0.2.1

A wrapper around the hyper.rs library to allow for targeted clients to specific remote APIs. This library should be useful on it's own or as a building block for specific remote API wrappers.
use error;
use std;


#[derive(Debug, Clone)]
pub enum Method {
  Get,
  Post,
  Put,
}


impl Method {}


impl std::str::FromStr for Method {
  type Err = error::Error;


  fn from_str(s: &str) -> std::result::Result<self::Method, Self::Err> {
    Ok(
      match s.to_uppercase().as_str() {
        "GET" => self::Method::Get,
        "POST" => self::Method::Post,
        "PUT" => self::Method::Put,
        invalid => return Err(error::Error::InvalidMethod(invalid.to_string())),
      },
    )

  }
}


impl std::fmt::Display for Method {
  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    f.write_str(
      match *self {
        self::Method::Get => "GET",
        self::Method::Post => "POST",
        self::Method::Put => "PUT",
      },
    )
  }
}