chiark / gitweb /
style: Centralise many type aliases
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:23:03 +0000 (00:23 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:23:03 +0000 (00:23 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
12 files changed:
daemon/api.rs
daemon/cmdlistener.rs
src/accounts.rs
src/bin/otter.rs
src/error.rs
src/gamestate.rs
src/global.rs
src/imports.rs
src/pieces.rs
src/shapelib-toml.rs
src/spec.rs
src/updates.rs

index e96b0c073da002b6d95d9e2d0dd6a56b796a5319..642bf1512b19ecc861d72b387e5ddcc774b31d99 100644 (file)
@@ -4,8 +4,6 @@
 
 pub use super::*;
 
-type WRC = WhatResponseToClientOp;
-
 type PL = PresentationLayout;
 
 #[derive(Clone,Debug)]
index 313056ea1dc74063282402d1a60184206f55d76d..4cb64c6fd781e0037949c2cdc72a25adbbfabc81 100644 (file)
@@ -21,9 +21,6 @@ type CSE = anyhow::Error;
 use MgmtCommand::*;
 use MgmtResponse::*;
 
-type ME = MgmtError;
-
-type AS = AccountScope;
 type TP = TablePermission;
 
 const USERLIST: &str = "/etc/userlist";
index 0a6a925989ac294eb6dcb0aefc70193ee01f41d0..7775a2dde9010f164100eadf556303ed3c7f018b 100644 (file)
@@ -21,9 +21,6 @@ pub enum AccountScope {
   Unix { user: String },
 }
 
-type AS = AccountScope;
-type ME = MgmtError;
-type IE = InternalError;
 
 #[derive(Debug,Clone)]
 #[derive(Eq,PartialEq,Ord,PartialOrd,Hash)]
index dd44980bfd8c55ccf6f614827f6614863ec2ee9b..b4589591512e84d71338018be4a5fb85bb5d97b7 100644 (file)
@@ -15,10 +15,8 @@ use derive_more::Display;
 use otter::imports::*;
 
 type APE = ArgumentParseError;
-type AS = AccountScope;
 type E = anyhow::Error;
 type MC = MgmtCommand;
-type ME = MgmtError;
 type MGI = MgmtGameInstruction;
 type MGR = MgmtGameResponse;
 type MR = MgmtResponse;
index 2311f3bdec6cd0adc90de704086bf17264ebc5a9..f5b8cbaa64bec9413eb79a5aedd7c222a2b95fee 100644 (file)
@@ -4,8 +4,6 @@
 
 use crate::imports::*;
 
-type IE = InternalError;
-
 #[derive(Error,Debug)]
 pub enum OnlineError {
   #[error("Game in process of being destroyed")]
index 1704761b9b6e056a477aa46a10b41d9611850723..de075fca239b3e670b292313111eb684492ebc3c 100644 (file)
@@ -4,8 +4,6 @@
 
 use crate::imports::*;
 
-type IE = InternalError;
-type IR = Result<(), IE>;
 type SE = SVGProcessingError;
 
 // ---------- newtypes and type aliases ----------
@@ -137,7 +135,8 @@ pub trait Piece: Outline + Send + Debug {
   }
 
   // #[throws] doesn't work here - fehler #todo
-  fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) -> IR;
+  fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions)
+               -> Result<(),IE>;
 
   fn describe_html(&self, face: Option<FaceId>) -> Html;
 
index b504cf838ce72162742c8ada4666ba97253f922e..b8ba07a8707f717274ad2dd6ad5dbf3f3ab78229 100644 (file)
@@ -9,9 +9,6 @@ use crate::imports::*;
 use slotmap::dense as sm;
 use std::sync::PoisonError;
 
-type ME = MgmtError;
-type ESU<POEPU> = ErrorSignaledViaUpdate<POEPU>;
-
 #[allow(non_camel_case_types)] type PUE_P = PreparedUpdateEntry_Piece;
 
 // ---------- newtypes and type aliases ----------
@@ -704,7 +701,7 @@ impl<'ig> InstanceGuard<'ig> {
       }
       buf.finish();
 
-      self.remove_clients(old_players_set, ESU::PlayerRemoved);
+      self.remove_clients(old_players_set, ESVU::PlayerRemoved);
       self.tokens_deregister_for_id(
         |id:PlayerId| old_players_set.contains(&id)
       );
@@ -753,7 +750,7 @@ impl<'ig> InstanceGuard<'ig> {
     // ppoint of no return
     (||{
       self.remove_clients(&[player].iter().cloned().collect(),
-                          ESU::TokenRevoked);
+                          ESVU::TokenRevoked);
     })(); // <- No ?, ensures that IEFE is infallible (barring panics)
   }
 
index 88c807403b56b255bad9862406bc64b192f1cd3c..98d3fbf54ac6e89d5f322bef7ef3abc78e04f2c4 100644 (file)
@@ -114,9 +114,23 @@ pub type Colour = Html;
 pub enum Impossible { }
 display_as_debug!(Impossible);
 
+// ---------- type abbreviations ----------
+
 pub type AE = anyhow::Error;
+
+// accounts.rs
+pub type AS = AccountScope;
+
+// commands.rs
+pub type ME = MgmtError;
+
+// error.rs
+pub type ESVU<POEPU> = ErrorSignaledViaUpdate<POEPU>;
+pub type IE = InternalError;
 pub type OE = OnlineError;
 pub type POEPP = PieceOpErrorPartiallyProcessed;
 
 // updates.rs
+pub type PUE = PreparedUpdateEntry;
 pub type PUO = PieceUpdateOps;
+pub type WRC = WhatResponseToClientOp;
index 4adf1cf9b43c25dd7689547842952f44b87ce5b6..b5d873b32aad8086a63a5d7bfb655d949f32900f 100644 (file)
@@ -8,6 +8,8 @@ use crate::imports::*;
 
 type ColourMap = IndexVec<FaceId, Colour>;
 
+type SE = SVGProcessingError;
+
 #[derive(Debug,Serialize,Deserialize)]
 // todo: this serialisation is rather large
 struct SimpleShape {
@@ -36,9 +38,6 @@ impl From<SVGProcessingError> for MgmtError {
   fn from(se: SVGProcessingError) -> MgmtError { se.into() }
 }
 
-type IE = InternalError;
-type SE = SVGProcessingError;
-
 #[throws(SE)]
 pub fn svg_rescale_path(input: &Html, scale: f64) -> Html {
   type BM = u64;
index bdd0d9d872359dc83ac379e70bf09676cf268d67..cc89cf7e429f2b5bf04ed47016cfa0208a982017 100644 (file)
@@ -21,7 +21,6 @@
 
 pub use crate::imports::*;
 
-#[doc(hidden)] pub type IE = InternalError;
 #[doc(hidden)] pub type LLE = shapelib::LibraryLoadError;
 
 #[cfg(doc)]
index 144526b92e8e2517dd28ba2cd9716ccc05f93484..bc440179434b276428c3a06200eccbe76a3d125f 100644 (file)
@@ -23,8 +23,6 @@ use crate::gamestate::PieceSpec;
 
 pub use implementation::PlayerAccessSpec;
 
-type ME = crate::commands::MgmtError;
-
 //---------- common types ----------
 
 pub type Coord = i32;
index 5bd3b24e336292b3b07d38cffa33406a2925c7bd..0f8187c3e40a0cfa8972fc9a4e7519265cdfa45d 100644 (file)
@@ -6,9 +6,6 @@
 
 use crate::imports::*;
 
-type PUE = PreparedUpdateEntry;
-type ESVU<POEPU> = ErrorSignaledViaUpdate<POEPU>;
-
 #[allow(non_camel_case_types)] type PUE_P = PreparedUpdateEntry_Piece;
 #[allow(non_camel_case_types)] type TUE_P<'u> = TransmitUpdateEntry_Piece<'u>;
 
@@ -394,6 +391,7 @@ type IsResponseToClientOp = Option<(
   ClientId,
   ClientSequence
 )>;
+
 #[derive(Debug, Copy, Clone, Serialize, Deserialize)]
 pub enum WhatResponseToClientOp {
   /// In PROTOCOL.md terms, a Client update
@@ -604,8 +602,6 @@ impl<'r> Drop for PrepareUpdatesBuffer<'r> {
 
 // ---------- for traansmission ----------
 
-type WRC = WhatResponseToClientOp;
-
 impl PreparedUpdate {
   pub fn for_transmit<'u>(&'u self, tz: &'u Timezone,
                           player: PlayerId, dest: ClientId)