chiark / gitweb /
formatting, some from rustfmt (manually picked)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Dec 2020 01:05:25 +0000 (01:05 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 6 Dec 2020 01:05:25 +0000 (01:05 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/global.rs

index 939ed1184901f761bd8864db0e41e5ef717c2693..4bcd508e17c8a8ac3e7084dceabab6c83bb3dc74 100644 (file)
@@ -39,13 +39,13 @@ pub struct InstanceName {
 pub struct InstanceRef (Arc<Mutex<InstanceContainer>>);
 
 pub struct Instance {
-  pub name : Arc<InstanceName>,
-  pub gs : GameState,
-  pub ipieces : PiecesLoaded,
-  pub clients : DenseSlotMap<ClientId,Client>,
-  pub iplayers : SecondarySlotMap<PlayerId, PlayerRecord>,
-  pub tokens_players : TokenRegistry<PlayerId>,
-  pub tokens_clients : TokenRegistry<ClientId>,
+  pub name: Arc<InstanceName>,
+  pub gs: GameState,
+  pub ipieces: PiecesLoaded,
+  pub clients: DenseSlotMap<ClientId, Client>,
+  pub iplayers: SecondarySlotMap<PlayerId, PlayerRecord>,
+  pub tokens_players: TokenRegistry<PlayerId>,
+  pub tokens_clients: TokenRegistry<ClientId>,
   pub acl: LoadedAcl<TablePermission>,
 }
 
@@ -63,20 +63,20 @@ pub struct IPlayerState {
 
 #[derive(Debug,Serialize,Deserialize)]
 #[serde(transparent)]
-pub struct PiecesLoaded (ActualPiecesLoaded);
-pub type ActualPiecesLoaded = SecondarySlotMap<PieceId,Box<dyn Piece>>;
+pub struct PiecesLoaded(ActualPiecesLoaded);
+pub type ActualPiecesLoaded = SecondarySlotMap<PieceId, Box<dyn Piece>>;
 #[derive(Copy,Clone,Debug)]
 pub struct ModifyingPieces(());
 
 #[derive(Debug,Serialize,Deserialize,Default)]
 #[serde(transparent)]
-pub struct Pieces (pub(in crate::global) ActualPieces);
-type ActualPieces = DenseSlotMap<PieceId,PieceState>;
+pub struct Pieces(pub(in crate::global) ActualPieces);
+type ActualPieces = DenseSlotMap<PieceId, PieceState>;
 
-#[derive(Debug)] 
+#[derive(Debug)]
 pub struct Client {
-  pub player : PlayerId,
-  pub lastseen : Instant,
+  pub player: PlayerId,
+  pub lastseen: Instant,
 }
 
 // KINDS OF PERSISTENT STATE
@@ -151,33 +151,33 @@ pub struct Client {
 // `live` is `false`.
 #[derive(Debug)]
 pub struct InstanceGuard<'g> {
-  pub c : MutexGuard<'g,InstanceContainer>,
-  pub gref : InstanceRef,
+  pub c: MutexGuard<'g, InstanceContainer>,
+  pub gref: InstanceRef,
 }
 
 #[derive(Debug,Default)]
 pub struct TokenRegistry<Id: AccessId> {
-  tr : HashSet<RawToken>,
-  id : PhantomData<Id>,
+  tr: HashSet<RawToken>,
+  id: PhantomData<Id>,
 }
 
 #[derive(Clone,Debug)]
 pub struct InstanceAccessDetails<Id> {
-  pub gref : InstanceRef,
-  pub ident : Id,
-  pub acctid : AccountId,
+  pub gref: InstanceRef,
+  pub ident: Id,
+  pub acctid: AccountId,
 }
 
 #[derive(Clone,Debug)]
 pub struct InstanceAccess<'i, Id> {
-  pub raw_token : &'i RawTokenVal,
-  pub i : InstanceAccessDetails<Id>,
+  pub raw_token: &'i RawTokenVal,
+  pub i: InstanceAccessDetails<Id>,
 }
 
 // ========== internal data structures ==========
 
 lazy_static! {
-  pub static ref GLOBAL : Global = Default::default();
+  pub static ref GLOBAL: Global = default();
 }
 
 #[derive(Default)]