Update edition, cargo fix and cargo fix --edition
This commit is contained in:
parent
3f71040aec
commit
26fe2b64da
23 changed files with 105 additions and 104 deletions
|
@ -4,6 +4,7 @@ description = "A wiki engine"
|
|||
license = "GPL-3.0"
|
||||
name = "sausagewiki"
|
||||
version = "0.1.0-dev"
|
||||
edition = "2018"
|
||||
|
||||
[build-dependencies]
|
||||
quote = "0.3.10"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
mod static_assets {
|
||||
use std::collections::HashMap;
|
||||
use futures::Future;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
// The CSS should be built to a single CSS file at compile time
|
||||
#[derive(StaticResource)]
|
||||
|
@ -32,8 +32,8 @@ mod static_assets {
|
|||
// #[mime = "application/font-woff"]
|
||||
// pub struct AmaticFont;
|
||||
|
||||
type BoxResource = Box<Resource + Sync + Send>;
|
||||
type ResourceFn = Box<Fn() -> BoxResource + Sync + Send>;
|
||||
type BoxResource = Box<dyn Resource + Sync + Send>;
|
||||
type ResourceFn = Box<dyn Fn() -> BoxResource + Sync + Send>;
|
||||
lazy_static! {
|
||||
pub static ref ASSETS_MAP: HashMap<&'static str, ResourceFn> = hashmap!{
|
||||
// The CSS should be built to a single CSS file at compile time
|
||||
|
|
|
@ -4,8 +4,8 @@ use diesel::sql_types::*;
|
|||
use r2d2::{CustomizeConnection, Pool};
|
||||
use r2d2_diesel::{self, ConnectionManager};
|
||||
|
||||
use rendering;
|
||||
use theme;
|
||||
use crate::rendering;
|
||||
use crate::theme;
|
||||
|
||||
embed_migrations!();
|
||||
|
||||
|
@ -39,7 +39,7 @@ impl CustomizeConnection<SqliteConnection, r2d2_diesel::Error> for SqliteInitial
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_pool<S: Into<String>>(connection_string: S) -> Result<Pool<ConnectionManager<SqliteConnection>>, Box<::std::error::Error>> {
|
||||
pub fn create_pool<S: Into<String>>(connection_string: S) -> Result<Pool<ConnectionManager<SqliteConnection>>, Box<dyn (::std::error::Error)>> {
|
||||
let manager = ConnectionManager::<SqliteConnection>::new(connection_string);
|
||||
let pool = Pool::builder()
|
||||
.connection_customizer(Box::new(SqliteInitializer {}))
|
||||
|
|
|
@ -52,7 +52,7 @@ mod theme;
|
|||
mod web;
|
||||
mod wiki_lookup;
|
||||
|
||||
pub fn main(db_file: String, bind_host: IpAddr, bind_port: u16, trust_identity: bool) -> Result<(), Box<std::error::Error>> {
|
||||
pub fn main(db_file: String, bind_host: IpAddr, bind_port: u16, trust_identity: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let db_pool = db::create_pool(db_file)?;
|
||||
let cpu_pool = futures_cpupool::CpuPool::new_num_cpus();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ extern crate sausagewiki;
|
|||
use std::net::IpAddr;
|
||||
|
||||
mod build_config;
|
||||
use build_config::*;
|
||||
use crate::build_config::*;
|
||||
|
||||
const DATABASE: &str = "DATABASE";
|
||||
const TRUST_IDENTITY: &str = "trust-identity";
|
||||
|
@ -49,7 +49,7 @@ fn args<'a>() -> clap::ArgMatches<'a> {
|
|||
.get_matches()
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<std::error::Error>> {
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args = args();
|
||||
|
||||
const CLAP: &str = "Guaranteed by clap";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use chrono;
|
||||
|
||||
use theme::Theme;
|
||||
use crate::theme::Theme;
|
||||
|
||||
fn slug_link(slug: &str) -> &str {
|
||||
if slug.is_empty() {
|
||||
|
|
|
@ -3,10 +3,10 @@ use hyper;
|
|||
use hyper::header::ContentType;
|
||||
use hyper::server::*;
|
||||
|
||||
use build_config;
|
||||
use mimes::*;
|
||||
use site::system_page;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::build_config;
|
||||
use crate::mimes::*;
|
||||
use crate::site::system_page;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
#[derive(Licenses)]
|
||||
pub struct AboutResource;
|
||||
|
|
|
@ -6,13 +6,13 @@ use hyper::server::*;
|
|||
use serde_json;
|
||||
use serde_urlencoded;
|
||||
|
||||
use assets::ScriptJs;
|
||||
use mimes::*;
|
||||
use rendering::render_markdown;
|
||||
use site::Layout;
|
||||
use state::{State, UpdateResult, RebaseConflict};
|
||||
use theme::{self, Theme};
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::assets::ScriptJs;
|
||||
use crate::mimes::*;
|
||||
use crate::rendering::render_markdown;
|
||||
use crate::site::Layout;
|
||||
use crate::state::{State, UpdateResult, RebaseConflict};
|
||||
use crate::theme::{self, Theme};
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
use super::changes_resource::QueryParameters;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ use hyper;
|
|||
use hyper::header::ContentType;
|
||||
use hyper::server::*;
|
||||
|
||||
use mimes::*;
|
||||
use models;
|
||||
use rendering::render_markdown;
|
||||
use site::system_page;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::models;
|
||||
use crate::rendering::render_markdown;
|
||||
use crate::site::system_page;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
use super::changes_resource::QueryParameters;
|
||||
use super::diff_resource;
|
||||
|
|
|
@ -6,11 +6,11 @@ use hyper::header::ContentType;
|
|||
use hyper::server::*;
|
||||
use serde_urlencoded;
|
||||
|
||||
use mimes::*;
|
||||
use schema::article_revisions;
|
||||
use site::system_page;
|
||||
use state::State;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::schema::article_revisions;
|
||||
use crate::site::system_page;
|
||||
use crate::state::State;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
use super::diff_resource;
|
||||
use super::pagination::Pagination;
|
||||
|
@ -18,7 +18,7 @@ use super::TemporaryRedirectResource;
|
|||
|
||||
const DEFAULT_LIMIT: i32 = 30;
|
||||
|
||||
type BoxResource = Box<Resource + Sync + Send>;
|
||||
type BoxResource = Box<dyn Resource + Sync + Send>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ChangesLookup {
|
||||
|
@ -97,7 +97,7 @@ impl ChangesLookup {
|
|||
Self { state, show_authors }
|
||||
}
|
||||
|
||||
pub fn lookup(&self, query: Option<&str>) -> Box<Future<Item=Option<BoxResource>, Error=::web::Error>> {
|
||||
pub fn lookup(&self, query: Option<&str>) -> Box<dyn Future<Item=Option<BoxResource>, Error=crate::web::Error>> {
|
||||
use super::pagination;
|
||||
|
||||
let state = self.state.clone();
|
||||
|
@ -154,7 +154,7 @@ impl ChangesLookup {
|
|||
args.into_link()
|
||||
)) as BoxResource,
|
||||
}))
|
||||
})) as Box<Future<Item=Option<BoxResource>, Error=::web::Error>>
|
||||
})) as Box<dyn Future<Item=Option<BoxResource>, Error=crate::web::Error>>
|
||||
},
|
||||
Pagination::Before(x) => Box::new(finished(Some(Box::new(ChangesResource::new(state, show_authors, Some(x), article_id, author, limit)) as BoxResource))),
|
||||
Pagination::None => Box::new(finished(Some(Box::new(ChangesResource::new(state, show_authors, None, article_id, author, limit)) as BoxResource))),
|
||||
|
|
|
@ -8,17 +8,17 @@ use hyper::header::ContentType;
|
|||
use hyper::server::*;
|
||||
use serde_urlencoded;
|
||||
|
||||
use mimes::*;
|
||||
use models::ArticleRevision;
|
||||
use site::Layout;
|
||||
use state::State;
|
||||
use theme;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::models::ArticleRevision;
|
||||
use crate::site::Layout;
|
||||
use crate::state::State;
|
||||
use crate::theme;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
use super::changes_resource;
|
||||
use super::pagination::Pagination;
|
||||
|
||||
type BoxResource = Box<Resource + Sync + Send>;
|
||||
type BoxResource = Box<dyn Resource + Sync + Send>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DiffLookup {
|
||||
|
@ -48,7 +48,7 @@ impl DiffLookup {
|
|||
Self { state }
|
||||
}
|
||||
|
||||
pub fn lookup(&self, article_id: u32, query: Option<&str>) -> Box<Future<Item=Option<BoxResource>, Error=::web::Error>> {
|
||||
pub fn lookup(&self, article_id: u32, query: Option<&str>) -> Box<dyn Future<Item=Option<BoxResource>, Error=crate::web::Error>> {
|
||||
let state = self.state.clone();
|
||||
|
||||
Box::new(done(
|
||||
|
|
|
@ -3,9 +3,9 @@ use hyper;
|
|||
use hyper::header::ContentType;
|
||||
use hyper::server::*;
|
||||
|
||||
use mimes::*;
|
||||
use site::system_page;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::site::system_page;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
pub struct HtmlResource {
|
||||
base: Option<&'static str>,
|
||||
|
|
|
@ -5,13 +5,13 @@ use hyper::server::*;
|
|||
use serde_json;
|
||||
use serde_urlencoded;
|
||||
|
||||
use assets::ScriptJs;
|
||||
use mimes::*;
|
||||
use rendering::render_markdown;
|
||||
use site::Layout;
|
||||
use state::State;
|
||||
use theme::{self, Theme};
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::assets::ScriptJs;
|
||||
use crate::mimes::*;
|
||||
use crate::rendering::render_markdown;
|
||||
use crate::site::Layout;
|
||||
use crate::state::State;
|
||||
use crate::theme::{self, Theme};
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
const NEW: &str = "NEW";
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ pub struct Error;
|
|||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
write!(f, "{}", (self as &error::Error).description())
|
||||
write!(f, "{}", (self as &dyn error::Error).description())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use hyper::header::{ContentType, ContentLength, CacheControl, CacheDirective};
|
|||
use hyper::server::*;
|
||||
use hyper::StatusCode;
|
||||
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct ReadOnlyResource {
|
||||
|
|
|
@ -5,16 +5,16 @@ use hyper::server::*;
|
|||
use serde_json;
|
||||
use serde_urlencoded;
|
||||
|
||||
use mimes::*;
|
||||
use models::SearchResult;
|
||||
use site::system_page;
|
||||
use state::State;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::models::SearchResult;
|
||||
use crate::site::system_page;
|
||||
use crate::state::State;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
const DEFAULT_LIMIT: u32 = 10;
|
||||
const DEFAULT_SNIPPET_SIZE: u32 = 30;
|
||||
|
||||
type BoxResource = Box<Resource + Sync + Send>;
|
||||
type BoxResource = Box<dyn Resource + Sync + Send>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub struct QueryParameters {
|
||||
|
@ -66,7 +66,7 @@ impl SearchLookup {
|
|||
Self { state }
|
||||
}
|
||||
|
||||
pub fn lookup(&self, query: Option<&str>) -> Result<Option<BoxResource>, ::web::Error> {
|
||||
pub fn lookup(&self, query: Option<&str>) -> Result<Option<BoxResource>, crate::web::Error> {
|
||||
let args: QueryParameters = serde_urlencoded::from_str(query.unwrap_or(""))?;
|
||||
|
||||
Ok(Some(Box::new(
|
||||
|
|
|
@ -3,11 +3,11 @@ use hyper;
|
|||
use hyper::header::ContentType;
|
||||
use hyper::server::*;
|
||||
|
||||
use mimes::*;
|
||||
use models::ArticleRevisionStub;
|
||||
use site::system_page;
|
||||
use state::State;
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::mimes::*;
|
||||
use crate::models::ArticleRevisionStub;
|
||||
use crate::site::system_page;
|
||||
use crate::state::State;
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
pub struct SitemapResource {
|
||||
state: State,
|
||||
|
|
|
@ -3,7 +3,7 @@ use hyper;
|
|||
use hyper::header::Location;
|
||||
use hyper::server::*;
|
||||
|
||||
use web::{Resource, ResponseFuture};
|
||||
use crate::web::{Resource, ResponseFuture};
|
||||
|
||||
pub struct TemporaryRedirectResource {
|
||||
location: String,
|
||||
|
|
14
src/site.rs
14
src/site.rs
|
@ -9,11 +9,11 @@ use hyper::mime;
|
|||
use hyper::server::*;
|
||||
use hyper;
|
||||
|
||||
use assets::{ThemesCss, StyleCss, SearchJs};
|
||||
use build_config;
|
||||
use theme;
|
||||
use web::Lookup;
|
||||
use wiki_lookup::WikiLookup;
|
||||
use crate::assets::{ThemesCss, StyleCss, SearchJs};
|
||||
use crate::build_config;
|
||||
use crate::theme;
|
||||
use crate::web::Lookup;
|
||||
use crate::wiki_lookup::WikiLookup;
|
||||
|
||||
lazy_static! {
|
||||
static ref TEXT_HTML: mime::Mime = "text/html;charset=utf-8".parse().unwrap();
|
||||
|
@ -93,7 +93,7 @@ impl Site {
|
|||
.with_status(hyper::StatusCode::NotFound)
|
||||
}
|
||||
|
||||
fn internal_server_error(base: Option<&str>, err: Box<::std::error::Error + Send + Sync>) -> Response {
|
||||
fn internal_server_error(base: Option<&str>, err: Box<dyn ::std::error::Error + Send + Sync>) -> Response {
|
||||
eprintln!("Internal Server Error:\n{:#?}", err);
|
||||
|
||||
Response::new()
|
||||
|
@ -121,7 +121,7 @@ impl Service for Site {
|
|||
type Request = Request;
|
||||
type Response = Response;
|
||||
type Error = hyper::Error;
|
||||
type Future = Box<futures::Future<Item = Response, Error = Self::Error>>;
|
||||
type Future = Box<dyn futures::Future<Item = Response, Error = Self::Error>>;
|
||||
|
||||
fn call(&self, req: Request) -> Self::Future {
|
||||
let (method, uri, _http_version, headers, body) = req.deconstruct();
|
||||
|
|
28
src/state.rs
28
src/state.rs
|
@ -7,10 +7,10 @@ use futures_cpupool::{self, CpuFuture};
|
|||
use r2d2::Pool;
|
||||
use r2d2_diesel::ConnectionManager;
|
||||
|
||||
use merge;
|
||||
use models;
|
||||
use schema::*;
|
||||
use theme::Theme;
|
||||
use crate::merge;
|
||||
use crate::models;
|
||||
use crate::schema::*;
|
||||
use crate::theme::Theme;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct State {
|
||||
|
@ -18,7 +18,7 @@ pub struct State {
|
|||
cpu_pool: futures_cpupool::CpuPool,
|
||||
}
|
||||
|
||||
pub type Error = Box<std::error::Error + Send + Sync>;
|
||||
pub type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
|
||||
pub enum SlugLookup {
|
||||
Miss,
|
||||
|
@ -81,7 +81,7 @@ fn decide_slug(conn: &SqliteConnection, article_id: i32, prev_title: &str, title
|
|||
|
||||
let base_slug = if base_slug.is_empty() { "article" } else { &base_slug };
|
||||
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
let mut slug = base_slug.to_owned();
|
||||
let mut disambiguator = 1;
|
||||
|
@ -113,7 +113,7 @@ impl<'a> SyncState<'a> {
|
|||
}
|
||||
|
||||
pub fn get_article_slug(&self, article_id: i32) -> Result<Option<String>, Error> {
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
Ok(article_revisions::table
|
||||
.filter(article_revisions::article_id.eq(article_id))
|
||||
|
@ -124,7 +124,7 @@ impl<'a> SyncState<'a> {
|
|||
}
|
||||
|
||||
pub fn get_article_revision(&self, article_id: i32, revision: i32) -> Result<Option<models::ArticleRevision>, Error> {
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
Ok(article_revisions::table
|
||||
.filter(article_revisions::article_id.eq(article_id))
|
||||
|
@ -140,7 +140,7 @@ impl<'a> SyncState<'a> {
|
|||
FnOnce(article_revisions::BoxedQuery<'x, diesel::sqlite::Sqlite>) ->
|
||||
article_revisions::BoxedQuery<'x, diesel::sqlite::Sqlite>,
|
||||
{
|
||||
use schema::article_revisions::dsl::*;
|
||||
use crate::schema::article_revisions::dsl::*;
|
||||
|
||||
Ok(f(article_revisions.into_boxed())
|
||||
.select((
|
||||
|
@ -159,7 +159,7 @@ impl<'a> SyncState<'a> {
|
|||
}
|
||||
|
||||
fn get_article_revision_stub(&self, article_id: i32, revision: i32) -> Result<Option<models::ArticleRevisionStub>, Error> {
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
Ok(self.query_article_revision_stubs(move |query| {
|
||||
query
|
||||
|
@ -178,7 +178,7 @@ impl<'a> SyncState<'a> {
|
|||
}
|
||||
|
||||
self.db_connection.transaction(|| {
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
Ok(match article_revisions::table
|
||||
.filter(article_revisions::slug.eq(slug))
|
||||
|
@ -238,7 +238,7 @@ impl<'a> SyncState<'a> {
|
|||
let (title_b, body_b, theme_b) = stored.pop().expect("Application layer guarantee");
|
||||
let (title_o, body_o, theme_o) = stored.pop().expect("Application layer guarantee");
|
||||
|
||||
use merge::MergeResult::*;
|
||||
use crate::merge::MergeResult::*;
|
||||
|
||||
fn merge_themes(a: Theme, o: Theme, b: Theme) -> Theme {
|
||||
// Last change wins
|
||||
|
@ -279,7 +279,7 @@ impl<'a> SyncState<'a> {
|
|||
}
|
||||
|
||||
self.db_connection.transaction(|| {
|
||||
use schema::article_revisions;
|
||||
use crate::schema::article_revisions;
|
||||
|
||||
let (latest_revision, prev_title, prev_slug, prev_theme) = article_revisions::table
|
||||
.filter(article_revisions::article_id.eq(article_id))
|
||||
|
@ -499,7 +499,7 @@ impl State {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use db;
|
||||
use crate::db;
|
||||
|
||||
impl UpdateResult {
|
||||
pub fn unwrap(self) -> models::ArticleRevision {
|
||||
|
|
|
@ -188,7 +188,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn basic_db_roundtrip() -> Result<(), Box<Error>> {
|
||||
fn basic_db_roundtrip() -> Result<(), Box<dyn Error>> {
|
||||
let conn = SqliteConnection::establish(":memory:")?;
|
||||
|
||||
#[derive(QueryableByName, PartialEq, Eq, Debug)]
|
||||
|
@ -204,7 +204,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn db_invalid_value_gives_error() -> Result<(), Box<Error>> {
|
||||
fn db_invalid_value_gives_error() -> Result<(), Box<dyn Error>> {
|
||||
let conn = SqliteConnection::establish(":memory:")?;
|
||||
|
||||
#[derive(QueryableByName, PartialEq, Eq, Debug)]
|
||||
|
|
|
@ -8,8 +8,8 @@ lazy_static! {
|
|||
static ref TEXT_PLAIN: mime::Mime = "text/plain;charset=utf-8".parse().unwrap();
|
||||
}
|
||||
|
||||
pub type Error = Box<std::error::Error + Send + Sync>;
|
||||
pub type ResponseFuture = Box<futures::Future<Item = server::Response, Error = Error>>;
|
||||
pub type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
pub type ResponseFuture = Box<dyn futures::Future<Item = server::Response, Error = Error>>;
|
||||
|
||||
pub trait Resource {
|
||||
fn allow(&self) -> Vec<hyper::Method>;
|
||||
|
|
|
@ -7,15 +7,15 @@ use futures::future::FutureResult;
|
|||
use percent_encoding::percent_decode;
|
||||
use slug::slugify;
|
||||
|
||||
use resources::*;
|
||||
use state::State;
|
||||
use web::{Lookup, Resource};
|
||||
use crate::resources::*;
|
||||
use crate::state::State;
|
||||
use crate::web::{Lookup, Resource};
|
||||
|
||||
#[allow(unused)]
|
||||
use assets::*;
|
||||
use crate::assets::*;
|
||||
|
||||
type BoxResource = Box<Resource + Sync + Send>;
|
||||
type ResourceFn = Box<Fn() -> BoxResource + Sync + Send>;
|
||||
type BoxResource = Box<dyn Resource + Sync + Send>;
|
||||
type ResourceFn = Box<dyn Fn() -> BoxResource + Sync + Send>;
|
||||
|
||||
lazy_static! {
|
||||
static ref LICENSES_MAP: HashMap<&'static str, ResourceFn> = hashmap!{
|
||||
|
@ -55,7 +55,7 @@ fn split_one(path: &str) -> Result<(Cow<str>, Option<&str>), Utf8Error> {
|
|||
}
|
||||
|
||||
fn map_lookup(map: &HashMap<&str, ResourceFn>, path: &str) ->
|
||||
FutureResult<Option<BoxResource>, Box<::std::error::Error + Send + Sync>>
|
||||
FutureResult<Option<BoxResource>, Box<dyn ::std::error::Error + Send + Sync>>
|
||||
{
|
||||
let (head, tail) = match split_one(path) {
|
||||
Ok(x) => x,
|
||||
|
@ -74,7 +74,7 @@ fn map_lookup(map: &HashMap<&str, ResourceFn>, path: &str) ->
|
|||
|
||||
#[allow(unused)]
|
||||
fn fs_lookup(root: &str, path: &str) ->
|
||||
FutureResult<Option<BoxResource>, Box<::std::error::Error + Send + Sync>>
|
||||
FutureResult<Option<BoxResource>, Box<dyn ::std::error::Error + Send + Sync>>
|
||||
{
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
@ -93,7 +93,7 @@ fn fs_lookup(root: &str, path: &str) ->
|
|||
filename.push_str(path);
|
||||
|
||||
let mut f = File::open(&filename)
|
||||
.unwrap_or_else(|_| panic!(format!("Not found: {}", filename)));
|
||||
.unwrap_or_else(|_| panic!("Not found: {}", filename));
|
||||
|
||||
let mut body = Vec::new();
|
||||
f.read_to_end(&mut body)
|
||||
|
@ -233,7 +233,7 @@ impl WikiLookup {
|
|||
let state = self.state.clone();
|
||||
let slug = slug.into_owned();
|
||||
|
||||
use state::SlugLookup;
|
||||
use crate::state::SlugLookup;
|
||||
Box::new(self.state.lookup_slug(slug.clone())
|
||||
.and_then(move |x| Ok(Some(match x {
|
||||
SlugLookup::Miss =>
|
||||
|
@ -249,8 +249,8 @@ impl WikiLookup {
|
|||
|
||||
impl Lookup for WikiLookup {
|
||||
type Resource = BoxResource;
|
||||
type Error = Box<::std::error::Error + Send + Sync>;
|
||||
type Future = Box<Future<Item = Option<Self::Resource>, Error = Self::Error>>;
|
||||
type Error = Box<dyn ::std::error::Error + Send + Sync>;
|
||||
type Future = Box<dyn Future<Item = Option<Self::Resource>, Error = Self::Error>>;
|
||||
|
||||
fn lookup(&self, path: &str, query: Option<&str>) -> Self::Future {
|
||||
assert!(path.starts_with("/"));
|
||||
|
|
Loading…
Reference in a new issue