Remove all calls to Future::boxed(), which is deprecated
This commit is contained in:
parent
12be38dfdc
commit
551cc22383
4 changed files with 22 additions and 22 deletions
|
@ -74,7 +74,7 @@ pub fn static_resource(input: TokenStream) -> TokenStream {
|
|||
fn head(&self) ->
|
||||
::futures::BoxFuture<::hyper::server::Response, Box<::std::error::Error + Send + Sync>>
|
||||
{
|
||||
::futures::finished(::hyper::server::Response::new()
|
||||
Box::new(::futures::finished(::hyper::server::Response::new()
|
||||
.with_status(::hyper::StatusCode::Ok)
|
||||
.with_header(::hyper::header::ContentType(
|
||||
#mime.parse().expect("Statically supplied mime type must be parseable")))
|
||||
|
@ -84,7 +84,7 @@ pub fn static_resource(input: TokenStream) -> TokenStream {
|
|||
::hyper::header::CacheDirective::Public,
|
||||
]))
|
||||
.with_header(::hyper::header::ETag(Self::etag()))
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn get(self: Box<Self>) ->
|
||||
|
@ -92,17 +92,17 @@ pub fn static_resource(input: TokenStream) -> TokenStream {
|
|||
{
|
||||
let body = include_bytes!(#abs_filename);
|
||||
|
||||
self.head().map(move |head|
|
||||
Box::new(self.head().map(move |head|
|
||||
head
|
||||
.with_header(::hyper::header::ContentLength(body.len() as u64))
|
||||
.with_body(body as &'static [u8])
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn put(self: Box<Self>, _body: ::hyper::Body) ->
|
||||
::futures::BoxFuture<::hyper::server::Response, Box<::std::error::Error + Send + Sync>>
|
||||
{
|
||||
::futures::finished(self.method_not_allowed()).boxed()
|
||||
Box::new(::futures::finished(self.method_not_allowed()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,10 +70,10 @@ impl Resource for ArticleResource {
|
|||
}
|
||||
|
||||
fn head(&self) -> futures::BoxFuture<Response, Box<::std::error::Error + Send + Sync>> {
|
||||
futures::finished(Response::new()
|
||||
Box::new(futures::finished(Response::new()
|
||||
.with_status(hyper::StatusCode::Ok)
|
||||
.with_header(ContentType(TEXT_HTML.clone()))
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn get(self: Box<Self>) -> futures::BoxFuture<Response, Box<::std::error::Error + Send + Sync>> {
|
||||
|
@ -93,7 +93,7 @@ impl Resource for ArticleResource {
|
|||
script_js_checksum: &'a str,
|
||||
}
|
||||
|
||||
self.head().map(move |head|
|
||||
Box::new(self.head().map(move |head|
|
||||
head
|
||||
.with_body(Layout {
|
||||
title: &self.data.title,
|
||||
|
@ -108,7 +108,7 @@ impl Resource for ArticleResource {
|
|||
},
|
||||
style_css_checksum: StyleCss::checksum(),
|
||||
}.to_string())
|
||||
).boxed()
|
||||
))
|
||||
}
|
||||
|
||||
fn put(self: Box<Self>, body: hyper::Body) ->
|
||||
|
@ -132,7 +132,7 @@ impl Resource for ArticleResource {
|
|||
created: &'a str,
|
||||
}
|
||||
|
||||
body
|
||||
Box::new(body
|
||||
.concat2()
|
||||
.map_err(Into::into)
|
||||
.and_then(|body| {
|
||||
|
@ -153,6 +153,6 @@ impl Resource for ArticleResource {
|
|||
}).expect("Should never fail"))
|
||||
)
|
||||
})
|
||||
.boxed()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
10
src/site.rs
10
src/site.rs
|
@ -77,21 +77,21 @@ impl Service for Site {
|
|||
let (method, uri, _http_version, _headers, body) = req.deconstruct();
|
||||
println!("{} {}", method, uri);
|
||||
|
||||
self.root.lookup(uri.path(), uri.query(), None /*uri.fragment()*/)
|
||||
Box::new(self.root.lookup(uri.path(), uri.query(), None /*uri.fragment()*/)
|
||||
.and_then(move |resource| match resource {
|
||||
Some(resource) => {
|
||||
use hyper::Method::*;
|
||||
match method {
|
||||
Options => futures::finished(resource.options()).boxed(),
|
||||
Options => Box::new(futures::finished(resource.options())),
|
||||
Head => resource.head(),
|
||||
Get => resource.get(),
|
||||
Put => resource.put(body),
|
||||
_ => futures::finished(resource.method_not_allowed()).boxed()
|
||||
_ => Box::new(futures::finished(resource.method_not_allowed()))
|
||||
}
|
||||
},
|
||||
None => futures::finished(Self::not_found()).boxed()
|
||||
None => Box::new(futures::finished(Self::not_found()))
|
||||
})
|
||||
.or_else(|err| Ok(Self::internal_server_error(err)))
|
||||
.boxed()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ impl Lookup for WikiLookup {
|
|||
if path.starts_with("/_") {
|
||||
// Reserved namespace
|
||||
|
||||
return futures::finished(
|
||||
return Box::new(futures::finished(
|
||||
LOOKUP_MAP.get(path).map(|x| x())
|
||||
).boxed();
|
||||
));
|
||||
}
|
||||
|
||||
let mut split = path[1..].split('/');
|
||||
|
@ -66,18 +66,18 @@ impl Lookup for WikiLookup {
|
|||
|
||||
if split.next() != None {
|
||||
// Currently disallow any URLs of the form /slug/...
|
||||
return futures::finished(None).boxed();
|
||||
return Box::new(futures::finished(None));
|
||||
}
|
||||
|
||||
if let Ok(article_id) = slug.parse() {
|
||||
let state = self.state.clone();
|
||||
self.state.get_article_revision_by_id(article_id)
|
||||
Box::new(self.state.get_article_revision_by_id(article_id)
|
||||
.and_then(|x| Ok(x.map(move |article|
|
||||
Box::new(ArticleResource::new(state, article)) as Box<Resource + Sync + Send>
|
||||
)))
|
||||
.boxed()
|
||||
)
|
||||
} else {
|
||||
futures::finished(None).boxed()
|
||||
Box::new(futures::finished(None))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue