This commit is contained in:
Jimmy Cuadra 2017-08-01 18:17:09 -07:00
parent 35c2e6edd8
commit 6ef1776aed

View File

@ -8,16 +8,19 @@
//! input parameters for requests, and the structure of a successful response. //! input parameters for requests, and the structure of a successful response.
//! Such types can then be used by client code to make requests, and by server code to fulfill //! Such types can then be used by client code to make requests, and by server code to fulfill
//! those requests. //! those requests.
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![deny(missing_docs)] #![deny(missing_docs)]
#![feature(try_from)] #![feature(try_from)]
extern crate futures; extern crate futures;
extern crate http; extern crate http;
#[cfg(test)] extern crate ruma_identifiers; #[cfg(test)]
#[cfg(test)] extern crate serde; extern crate ruma_identifiers;
#[cfg(test)] #[macro_use] extern crate serde_derive; #[cfg(test)]
extern crate serde;
#[cfg(test)]
#[macro_use]
extern crate serde_derive;
extern crate serde_json; extern crate serde_json;
extern crate serde_urlencoded; extern crate serde_urlencoded;
@ -102,7 +105,7 @@ mod tests {
pub mod create { pub mod create {
use std::convert::TryFrom; use std::convert::TryFrom;
use futures::future::{FutureFrom, FutureResult, err, ok}; use futures::future::{err, ok, FutureFrom, FutureResult};
use http::method::PUT; use http::method::PUT;
use http::{Request as HttpRequest, Response as HttpResponse}; use http::{Request as HttpRequest, Response as HttpResponse};
use ruma_identifiers::{RoomAliasId, RoomId}; use ruma_identifiers::{RoomAliasId, RoomId};
@ -125,13 +128,12 @@ mod tests {
rate_limited: false, rate_limited: false,
requires_authentication: true, requires_authentication: true,
}; };
} }
/// A request to create a new room alias. /// A request to create a new room alias.
#[derive(Debug)] #[derive(Debug)]
pub struct Request { pub struct Request {
pub room_id: RoomId, // body pub room_id: RoomId, // body
pub room_alias: RoomAliasId, // path pub room_alias: RoomAliasId, // path
} }
@ -146,7 +148,8 @@ mod tests {
fn try_from(request: Request) -> Result<HttpRequest<Vec<u8>>, Self::Error> { fn try_from(request: Request) -> Result<HttpRequest<Vec<u8>>, Self::Error> {
let metadata = Endpoint::METADATA; let metadata = Endpoint::METADATA;
let path = metadata.path let path = metadata
.path
.to_string() .to_string()
.replace(":room_alias", &request.room_alias.to_string()); .replace(":room_alias", &request.room_alias.to_string());
@ -170,7 +173,9 @@ mod tests {
type Future = FutureResult<Self, Self::Error>; type Future = FutureResult<Self, Self::Error>;
type Error = Error; type Error = Error;
fn future_from(http_response: HttpResponse<Vec<u8>>) -> FutureResult<Self, Self::Error> { fn future_from(
http_response: HttpResponse<Vec<u8>>,
) -> FutureResult<Self, Self::Error> {
if http_response.status().is_success() { if http_response.status().is_success() {
ok(Response) ok(Response)
} else { } else {