Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created January 16, 2017 05:18
Show Gist options
  • Save jimmycuadra/54f81f73e39d2e6ed52341876cbf4826 to your computer and use it in GitHub Desktop.
Save jimmycuadra/54f81f73e39d2e6ed52341876cbf4826 to your computer and use it in GitHub Desktop.
Rough idea for a revision of ruma-api
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