Created
January 16, 2017 05:18
-
-
Save jimmycuadra/54f81f73e39d2e6ed52341876cbf4826 to your computer and use it in GitHub Desktop.
Rough idea for a revision of ruma-api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait Endpoint { | |
type Request: Request; | |
type Response: Response; | |
fn info() -> Info; | |
} | |
pub struct Info { | |
pub description: &'static str, | |
pub name: &'static str, | |
pub rate_limited: bool, | |
pub requires_authentication: bool, | |
pub router_path: &'static str, | |
} | |
pub trait Request { | |
fn body<T>(&self) -> Option<T> where T: Deserialize + Serialize; | |
fn headers(&self) -> Option<HashMap<String, String>>; | |
fn method() -> Method; | |
fn path<T>(&self) -> Option<T> where T: Deserialize + Serialize; | |
fn query<T>(&self) -> Option<T> where T: Deserialize + Serialize; | |
} | |
pub trait Response { | |
type Status; | |
fn body<T>(&self) -> T where T: Deserialize + Serialize; | |
fn headers(&self) -> Option<HashMap<String, String>>; | |
fn status(&self) -> Self::Status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment