From 59e5c49aa86124a57d10f5401dc617025e859a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sun, 26 Jan 2020 20:59:48 +0100 Subject: [PATCH] convert plume-models to all async where sensible! note that State has no asynchronous work to do, so wrapping it up in async makes no sense. --- plume-models/src/db_conn.rs | 2 +- plume-models/src/plume_rocket.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plume-models/src/db_conn.rs b/plume-models/src/db_conn.rs index 169690a6..a44f5ecb 100644 --- a/plume-models/src/db_conn.rs +++ b/plume-models/src/db_conn.rs @@ -28,7 +28,7 @@ impl<'a, 'r> FromRequestAsync<'a, 'r> for DbConn { Box::pin(async move { match DbConn::from_request(request).await { Outcome::Success(a) => return Outcome::Success(a), - Outcome::Failure(_) => return Outcome::Failure((Status::ServiceUnavailable, ())), + _ => return Outcome::Failure((Status::ServiceUnavailable, ())), }; }) } diff --git a/plume-models/src/plume_rocket.rs b/plume-models/src/plume_rocket.rs index ca5f05df..7e297d0f 100644 --- a/plume-models/src/plume_rocket.rs +++ b/plume-models/src/plume_rocket.rs @@ -4,7 +4,7 @@ pub use self::module::PlumeRocket; mod module { use crate::{db_conn::DbConn, search, users}; use rocket::{ - request::{self, FlashMessage, FromRequest, FromRequestAsync, Request}, + request::{self, FlashMessage, FromRequestAsync, Request}, Outcome, State, }; use scheduled_thread_pool::ScheduledThreadPool; @@ -28,13 +28,13 @@ mod module { let conn = try_outcome!(DbConn::from_request(request).await); let intl = try_outcome!(rocket_i18n::I18n::from_request(request).await); let user = try_outcome!(users::User::from_request(request).await); - let worker = request.guard::<'_, State<'_, Arc>>()?; - let searcher = request.guard::<'_, State<'_, Arc>>()?; + let worker = try_outcome!(request.guard::<'_, State<'_, Arc>>()); + let searcher = try_outcome!(request.guard::<'_, State<'_, Arc>>()); let flash_msg = request.guard::>().succeeded(); Outcome::Success(PlumeRocket { conn, intl, - user, + user: Some(user), flash_msg: flash_msg.map(|f| (f.name().into(), f.msg().into())), worker: worker.clone(), searcher: searcher.clone(),