chiark / gitweb /
bundles: Minor code tidying, including a new type alias
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 15:18:06 +0000 (16:18 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 16:16:13 +0000 (17:16 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/global.rs

index 5813298a7b64cedfc06062f44b98f7c7ed48f8b0..319446349ee1833ce2d2110f06962a9b817378b5 100644 (file)
@@ -113,7 +113,7 @@ fn execute_and_respond<R,W>(cs: &mut CommandStreamData, cmd: MgmtCommand,
   ) -> (R, Authorisation<InstanceName>)
   where F: FnMut(
     &mut InstanceGuard<'ig>,
-    MutexGuard<'ig, InstanceBundles>,
+    BundlesGuard<'ig>,
   ) -> Result<R, MgmtError>
   {
     let bundles = gref.lock_bundles();
@@ -256,8 +256,8 @@ fn execute_and_respond<R,W>(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<R,W>(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
index a9eb8b8f5c517210317eb7cac54b4ee07e51915c..044ace922603e1d74a8dcf8518ea32f71ee26749 100644 (file)
@@ -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<A> Unauthorised<InstanceRef, A> {
     })
   }
 
-  pub fn lock_bundles<'r>(&'r self) -> Unauthorised<MutexGuard<'r, InstanceBundles>, A> {
+  pub fn lock_bundles<'r>(&'r self) -> Unauthorised<BundlesGuard<'_>, A> {
     let must_not_escape = self.by_ref(Authorisation::authorise_any());
     Unauthorised::of(must_not_escape.lock_bundles())
   }