From: Ian Jackson Date: Mon, 1 Feb 2021 00:23:03 +0000 (+0000) Subject: style: Centralise many type aliases X-Git-Tag: otter-0.4.0~562 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=bae3f5f4d2f90fe176ababe7013f1c77570c75d1;p=otter.git style: Centralise many type aliases Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index e96b0c07..642bf151 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -4,8 +4,6 @@ pub use super::*; -type WRC = WhatResponseToClientOp; - type PL = PresentationLayout; #[derive(Clone,Debug)] diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 313056ea..4cb64c6f 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -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"; diff --git a/src/accounts.rs b/src/accounts.rs index 0a6a9259..7775a2dd 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -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)] diff --git a/src/bin/otter.rs b/src/bin/otter.rs index dd44980b..b4589591 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -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; diff --git a/src/error.rs b/src/error.rs index 2311f3bd..f5b8cbaa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -4,8 +4,6 @@ use crate::imports::*; -type IE = InternalError; - #[derive(Error,Debug)] pub enum OnlineError { #[error("Game in process of being destroyed")] diff --git a/src/gamestate.rs b/src/gamestate.rs index 1704761b..de075fca 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -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) -> Html; diff --git a/src/global.rs b/src/global.rs index b504cf83..b8ba07a8 100644 --- a/src/global.rs +++ b/src/global.rs @@ -9,9 +9,6 @@ use crate::imports::*; use slotmap::dense as sm; use std::sync::PoisonError; -type ME = MgmtError; -type ESU = ErrorSignaledViaUpdate; - #[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) } diff --git a/src/imports.rs b/src/imports.rs index 88c80740..98d3fbf5 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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 = ErrorSignaledViaUpdate; +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; diff --git a/src/pieces.rs b/src/pieces.rs index 4adf1cf9..b5d873b3 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -8,6 +8,8 @@ use crate::imports::*; type ColourMap = IndexVec; +type SE = SVGProcessingError; + #[derive(Debug,Serialize,Deserialize)] // todo: this serialisation is rather large struct SimpleShape { @@ -36,9 +38,6 @@ impl From 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; diff --git a/src/shapelib-toml.rs b/src/shapelib-toml.rs index bdd0d9d8..cc89cf7e 100644 --- a/src/shapelib-toml.rs +++ b/src/shapelib-toml.rs @@ -21,7 +21,6 @@ pub use crate::imports::*; -#[doc(hidden)] pub type IE = InternalError; #[doc(hidden)] pub type LLE = shapelib::LibraryLoadError; #[cfg(doc)] diff --git a/src/spec.rs b/src/spec.rs index 144526b9..bc440179 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -23,8 +23,6 @@ use crate::gamestate::PieceSpec; pub use implementation::PlayerAccessSpec; -type ME = crate::commands::MgmtError; - //---------- common types ---------- pub type Coord = i32; diff --git a/src/updates.rs b/src/updates.rs index 5bd3b24e..0f8187c3 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -6,9 +6,6 @@ use crate::imports::*; -type PUE = PreparedUpdateEntry; -type ESVU = ErrorSignaledViaUpdate; - #[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)