chiark / gitweb /
style: Make commands::* not global, type aliases, etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:36:12 +0000 (00:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:36:12 +0000 (00:36 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/accounts.rs
src/bin/otter.rs
src/commands.rs
src/global.rs
src/imports.rs
src/mgmtchannel.rs
src/shapelib.rs
src/spec.rs

index 4cb64c6fd781e0037949c2cdc72a25adbbfabc81..36ed00ce7c75ad50ae7feabca6fbdff927c8001f 100644 (file)
@@ -5,6 +5,7 @@
 // management API implementation
 
 use super::*;
+use otter::commands::*;
 
 use authproofs::*;
 
index 7775a2dde9010f164100eadf556303ed3c7f018b..8a37e6fa61d3be05c35dc5c0337a837eb68be2a1 100644 (file)
@@ -518,7 +518,7 @@ pub mod loaded_acl {
       Err(if needed & test_existence != 0 {
         P::NOT_FOUND
       } else {
-        MgmtError::AuthorisationError
+        ME::AuthorisationError
       })?
     }
   }
index b4589591512e84d71338018be4a5fb85bb5d97b7..432ee1ef548898d4669a2ec73666e71ace3c74b5 100644 (file)
@@ -12,6 +12,7 @@ use argparse::{self,ArgumentParser,action::{TypedAction,ParseResult}};
 use argparse::action::{Action,IFlagAction,IArgAction};
 use derive_more::Display;
 
+use otter::commands::*;
 use otter::imports::*;
 
 type APE = ArgumentParseError;
@@ -596,10 +597,10 @@ impl ConnForGame {
 */
   #[throws(AE)]
   fn get_pieces(&mut self) -> Vec<MgmtGamePieceInfo> {
-    let insns = vec![ MgmtGameInstruction::ListPieces ];
+    let insns = vec![ MGI::ListPieces ];
     let mut responses = self.alter_game(insns, None)?;
     match responses.as_mut_slice() {
-      [MgmtGameResponse::Pieces(pieces)] => return mem::take(pieces),
+      [MGR::Pieces(pieces)] => return mem::take(pieces),
       wat => Err(anyhow!("ListPieces => {:?}", &wat))?,
     }
   }
index 31a5c85e8f5f2e4077b7d216c65fe616ff005c26..faa2f92ef14bd6b8ff7abd5738d295d023d570cd 100644 (file)
@@ -198,6 +198,8 @@ impl From<InternalError> for MgmtError {
   }
 }
 
+from_instance_lock_error!{MgmtError}
+
 impl AccessTokenInfo {
   pub fn report(self) -> Vec<String> {
     vec![
index b8ba07a8707f717274ad2dd6ad5dbf3f3ab78229..2e115715609bfa362cbb07162950cb047c59464e 100644 (file)
@@ -225,7 +225,6 @@ display_as_debug!{InstanceLockError}
 impl<X> From<PoisonError<X>> for InstanceLockError {
   fn from(_: PoisonError<X>) -> Self { Self::GameCorrupted }
 }
-from_instance_lock_error!{MgmtError}
 
 pub struct PrivateCaller(());
 // outsiders cannot construct this
@@ -319,7 +318,7 @@ impl Instance {
     use hash_map::Entry::*;
     let entry = match entry {
       Vacant(ve) => ve,
-      Occupied(_) => throw!(MgmtError::AlreadyExists),
+      Occupied(_) => throw!(ME::AlreadyExists),
     };
 
     ig.save_access_now()?;
@@ -340,7 +339,7 @@ impl Instance {
     Unauthorised::of(
       games_table
         .get(name)
-        .ok_or(MgmtError::GameNotFound)?
+        .ok_or(ME::GameNotFound)?
         .clone()
         .into()
     )
@@ -540,7 +539,7 @@ impl<'ig> InstanceGuard<'ig> {
     // we have a thing to serialise with the player in it
     self.check_new_nick(&gnew.nick)?;
     if self.c.g.iplayers.values().any(|r| r.ipl.acctid == inew.acctid) {
-      Err(MgmtError::AlreadyExists)?;
+      Err(ME::AlreadyExists)?;
     }
     let player = self.c.g.gs.players.insert(gnew);
     let u = PlayerUpdates::new_begin(&self.c.g.gs).new();
@@ -575,7 +574,7 @@ impl<'ig> InstanceGuard<'ig> {
   #[throws(MgmtError)]
   pub fn check_new_nick(&mut self, new_nick: &str) {
     if self.c.g.gs.players.values().any(|old| old.nick == new_nick) {
-      Err(MgmtError::NickCollision)?;
+      Err(ME::NickCollision)?;
     }
   }
 
index 98d3fbf54ac6e89d5f322bef7ef3abc78e04f2c4..f97558eed907e647e7e603cd32dab7eeaa61766c 100644 (file)
@@ -85,7 +85,7 @@ pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet};
 pub use crate::accounts::*;
 pub use crate::authproofs::{self, Authorisation, Unauthorised};
 pub use crate::authproofs::AuthorisationSuperuser;
-pub use crate::commands::*;
+pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError};
 pub use crate::config::*;
 pub use crate::debugreader::DebugReader;
 pub use crate::error::*;
index 2f629f7aeadd2e78d7f3bd840e2f50f9af32f5ed..dfacb387b04f12c6258fa4b2eded910a675a8a23 100644 (file)
@@ -3,6 +3,7 @@
 // There is NO WARRANTY.
 
 use crate::imports::*;
+use crate::commands::*;
 
 #[derive(Debug,Error)]
 pub enum MgmtChannelReadError {
index f85ab52a4efe3e6fdab4f6f87b8624bface1aa89..40cc898d1211edbfcc067665b3234ed4fc9aea91 100644 (file)
@@ -251,7 +251,7 @@ impl Contents {
 
   #[throws(MgmtError)]
   pub fn list_glob(&self, pat: &str) -> Vec<ItemEnquiryData> {
-    let pat = glob::Pattern::new(pat).map_err(|pe| MgmtError::BadGlob {
+    let pat = glob::Pattern::new(pat).map_err(|pe| ME::BadGlob {
       pat: pat.to_string(), msg: pe.msg.to_string() })?;
     let mut out = vec![];
     for (k,v) in &self.items {
index bc440179434b276428c3a06200eccbe76a3d125f..9cabe247b9f249c49e0aa377f1adf2302f0d3dfb 100644 (file)
@@ -340,7 +340,7 @@ pub mod implementation {
   impl loaded_acl::Perm for TablePermission {
     type Auth = InstanceName;
     const TEST_EXISTENCE: Self = TablePermission::TestExistence;
-    const NOT_FOUND: MgmtError = MgmtError::GameNotFound;
+    const NOT_FOUND: MgmtError = ME::GameNotFound;
   }
 
   impl TablePlayerSpec {