From f0d6357527117d1f644d2bd6ef30fa9c2fcd9e0d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 15 May 2021 16:18:06 +0100 Subject: [PATCH] bundles: Minor code tidying, including a new type alias Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 10 +++++----- src/global.rs | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 5813298a..31944634 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -113,7 +113,7 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, ) -> (R, Authorisation) where F: FnMut( &mut InstanceGuard<'ig>, - MutexGuard<'ig, InstanceBundles>, + BundlesGuard<'ig>, ) -> Result { let bundles = gref.lock_bundles(); @@ -256,8 +256,8 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, let (upload, auth) = { let (ag, gref) = start_modify_game(&game)?; modify_bundles( - cs, &ag, &gref, &[TP::UploadBundles], - &mut |mut ig, mut bundles: MutexGuard<'_, InstanceBundles>| { + cs,&ag,&gref, &[TP::UploadBundles], + &mut |mut ig, mut bundles: BundlesGuard<'_>| { bundles.start_upload(&mut ig, kind) } )? @@ -293,8 +293,8 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, MC::ClearBundles { game } => { let (ag, gref) = start_modify_game(&game)?; modify_bundles( - cs, &ag, &gref, &[TP::ClearBundles], - &mut |mut ig, mut bundles: MutexGuard<'_, InstanceBundles>| { + cs,&ag,&gref, &[TP::ClearBundles], + &mut |mut ig, mut bundles: BundlesGuard<'_>| { bundles.clear(&mut ig) })?; Fine diff --git a/src/global.rs b/src/global.rs index a9eb8b8f..044ace92 100644 --- a/src/global.rs +++ b/src/global.rs @@ -104,6 +104,8 @@ pub struct Client { pub lastseen: Instant, } +pub type BundlesGuard<'b> = MutexGuard<'b, InstanceBundles>; + // KINDS OF PERSISTENT STATE // // TokenTable TokenTable GameState Instance GameState @@ -319,7 +321,7 @@ impl Unauthorised { }) } - pub fn lock_bundles<'r>(&'r self) -> Unauthorised, A> { + pub fn lock_bundles<'r>(&'r self) -> Unauthorised, A> { let must_not_escape = self.by_ref(Authorisation::authorise_any()); Unauthorised::of(must_not_escape.lock_bundles()) } -- 2.30.2