chiark / gitweb /
style: Remove space before : in daemon/
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:02:46 +0000 (00:02 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Feb 2021 00:02:46 +0000 (00:02 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
daemon/cmdlistener.rs
daemon/main.rs
daemon/session.rs

index d863ba7fababc3794e52c6fcbfef2f0bfa683e5a..e96b0c073da002b6d95d9e2d0dd6a56b796a5319 100644 (file)
@@ -15,24 +15,24 @@ pub struct InstanceAccess<'i, Id> {
 }
 
 impl<'r, Id> FromFormValue<'r> for InstanceAccess<'r, Id>
-  where Id : AccessId, OE : From<Id::Error>
+  where Id: AccessId, OE: From<Id::Error>
 {
   type Error = OER;
   #[throws(OER)]
   fn from_form_value(param: &'r RawStr) -> Self {
     let token = RawTokenVal::from_str(param.as_str());
     let i = InstanceAccessDetails::from_token(token)?;
-    InstanceAccess { raw_token : token, i }
+    InstanceAccess { raw_token: token, i }
   }
 }
 
 #[derive(Debug,Serialize,Deserialize)]
-struct ApiPiece<O : ApiPieceOp> {
-  ctoken : RawToken,
-  piece : VisiblePieceId,
-  gen : Generation,
-  cseq : ClientSequence,
-  op : O,
+struct ApiPiece<O:ApiPieceOp> {
+  ctoken: RawToken,
+  piece: VisiblePieceId,
+  gen: Generation,
+  cseq: ClientSequence,
+  op: O,
 }
 
 struct ApiPieceOpArgs<'a> {
@@ -42,7 +42,7 @@ struct ApiPieceOpArgs<'a> {
   p: &'a dyn Piece,
 }
 
-trait ApiPieceOp : Debug {
+trait ApiPieceOp: Debug {
   #[throws(ApiPieceOpError)]
   fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate;
 
@@ -101,7 +101,7 @@ fn log_did_to_piece(
 }
 
 #[throws(OE)]
-fn api_piece_op<O: ApiPieceOp>(form : Json<ApiPiece<O>>)
+fn api_piece_op<O: ApiPieceOp>(form: Json<ApiPiece<O>>)
                    -> impl response::Responder<'static> {
 //  thread::sleep(Duration::from_millis(2000));
   let iad = lookup_token(form.ctoken.borrow())?;
@@ -183,7 +183,7 @@ macro_rules! api_route_core {
 
     #[post($path, format="json", data="<form>")]
     #[throws(OER)]
-    fn $fn(form : Json<ApiPiece<$form>>)
+    fn $fn(form: Json<ApiPiece<$form>>)
            -> impl response::Responder<'static> {
       api_piece_op(form)?
     }
@@ -267,7 +267,7 @@ api_route!{
 
     let pls = &htmlescape::encode_minimal(&gpl.nick);
 
-    let logent = LogEntry { html : Html(match was {
+    let logent = LogEntry { html: Html(match was {
         Some(was) => format!("{} wrested {} from {}", pls, pcs, was),
         None => format!("{} wrested {}", pls, pcs),
     })};
@@ -304,14 +304,14 @@ api_route!{
 api_route!{
   api_raise, "/_/api/setz",
   struct ApiPieceSetZ {
-    z : ZCoord,
+    z: ZCoord,
   }
   #[throws(ApiPieceOpError)]
   fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate {
     // xxx prevent restzcking anything that is occulting
     let ApiPieceOpArgs { gs,piece, .. } = a;
     let pc = gs.pieces.byid_mut(piece).unwrap();
-    pc.zlevel = ZLevel { z : self.z.clone(), zg : gs.gen };
+    pc.zlevel = ZLevel { z: self.z.clone(), zg: gs.gen };
     let update = PieceUpdateOp::SetZLevel(());
     (WhatResponseToClientOp::Predictable,
      update, vec![]).into()
@@ -392,7 +392,7 @@ api_route!{
   }
 }
 
-const DEFKEY_FLIP : UoKey = 'f';
+const DEFKEY_FLIP: UoKey = 'f';
 
 api_route!{
   api_uo, "/_/api/k",
index 33f46221c7618b932df114f613176eef05ae3ec9..313056ea1dc74063282402d1a60184206f55d76d 100644 (file)
@@ -256,7 +256,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
   }
 
   #[throws(MgmtError)]
-  fn readonly<'igr, 'ig : 'igr, 'cs,
+  fn readonly<'igr, 'ig: 'igr, 'cs,
               F: FnOnce(&InstanceGuard) -> Result<MgmtGameResponse,ME>,
               P: Into<PermSet<TablePermission>>>
   
@@ -274,7 +274,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
   }
 
   #[throws(MgmtError)]
-  fn update_links<'igr, 'ig : 'igr, 'cs,
+  fn update_links<'igr, 'ig: 'igr, 'cs,
                F: FnOnce(&mut Arc<LinksTable>) -> Result<Html,ME>>
     (
       cs: &'cs CommandStream,
@@ -464,10 +464,10 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
 
     Insn::SetLinks(mut spec_links) =>  {
       update_links(cs,ag,ig, |ig_links|{
-        let mut new_links : LinksTable = default();
+        let mut new_links: LinksTable = default();
         // todo want a FromIterator impl
         for (k,v) in spec_links.drain() {
-          let url : Url = (&v).try_into()?;
+          let url: Url = (&v).try_into()?;
           new_links[k] = Some(url.into_string());
         }
         let new_links = Arc::new(new_links);
@@ -481,9 +481,9 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
 
     Insn::SetLink { kind, url } =>  {
       update_links(cs,ag,ig, |ig_links|{
-        let mut new_links : LinksTable = (**ig_links).clone();
-        let url : Url = (&url).try_into()?;
-        let show : Html = (kind, url.as_str()).into();
+        let mut new_links: LinksTable = (**ig_links).clone();
+        let url: Url = (&url).try_into()?;
+        let show: Html = (kind, url.as_str()).into();
         new_links[kind] = Some(url.into_string());
         let new_links = Arc::new(new_links);
         *ig_links = new_links.clone();
@@ -496,7 +496,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
 
     Insn::RemoveLink { kind } =>  {
       update_links(cs,ag,ig, |ig_links|{
-        let mut new_links : LinksTable = (**ig_links).clone();
+        let mut new_links: LinksTable = (**ig_links).clone();
         new_links[kind] = None;
         let new_links = Arc::new(new_links);
         *ig_links = new_links.clone();
@@ -586,7 +586,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>(
         .try_into().map_err(
           |_| SE::InternalError(format!("implicit item count out of range"))
         )?;
-      let count : Box<dyn ExactSizeIterator<Item=u32>> = match count {
+      let count: Box<dyn ExactSizeIterator<Item=u32>> = match count {
         Some(explicit) if implicit == 1 => {
           Box::new((0..explicit).map(|_| 0))
         },
@@ -866,7 +866,7 @@ impl CommandStream<'_> {
           let mut cmd_s = log_enabled!(log::Level::Info)
             .as_some_from(|| format!("{:?}", &cmd))
             .unwrap_or_default();
-          const MAX : usize = 200;
+          const MAX: usize = 200;
           if cmd_s.len() > MAX-3 {
             cmd_s.truncate(MAX-3);
             cmd_s += "..";
@@ -886,7 +886,7 @@ impl CommandStream<'_> {
         }
         Err(EOF) => break,
         Err(IO(e)) => Err(e).context("read command stream")?,
-        Err(Parse(s)) => MgmtResponse::Error { error : ME::ParseFailed(s) },
+        Err(Parse(s)) => MgmtResponse::Error { error: ME::ParseFailed(s) },
       };
       self.chan.write(&resp).context("swrite command stream")?;
     }
@@ -1015,7 +1015,7 @@ impl CommandStream<'_> {
   }
 
   #[throws(MgmtError)]
-  pub fn check_acl_modify_player<'igr, 'ig : 'igr,
+  pub fn check_acl_modify_player<'igr, 'ig: 'igr,
                                  P: Into<PermSet<TablePermission>>>(
     &self,
     ag: &AccountsGuard,
@@ -1172,7 +1172,7 @@ fn do_authorise_scope(cs: &CommandStream, wanted: &AccountScope)
   match &wanted {
 
     AccountScope::Server => {
-      let y : Authorisation<Uid> = {
+      let y: Authorisation<Uid> = {
         cs.authorised_uid(None,None)?
       };
       y.therefore_ok()
@@ -1181,11 +1181,11 @@ fn do_authorise_scope(cs: &CommandStream, wanted: &AccountScope)
     AccountScope::Unix { user: wanted } => {
       struct InUserList;
 
-      let y : Authorisation<(Passwd,Uid,InUserList)> = {
+      let y: Authorisation<(Passwd,Uid,InUserList)> = {
 
-        struct AuthorisedIf { authorised_for : Option<Uid> }
+        struct AuthorisedIf { authorised_for: Option<Uid> }
 
-        const SERVER_ONLY : (AuthorisedIf, Authorisation<InUserList>) = (
+        const SERVER_ONLY: (AuthorisedIf, Authorisation<InUserList>) = (
           AuthorisedIf { authorised_for: None },
           Authorisation::authorised(&InUserList),
         );
index da569460c6811a22f67cb56a895b18c38edf6223..cc0534e675ca5730946f00c2af7156a499dd75f5 100644 (file)
@@ -44,7 +44,7 @@ struct FrontPageRenderContext {
 enum ResourceLocation { Main, Wasm(&'static str), }
 type RL = ResourceLocation;
 
-const RESOURCES : &[(&'static str, ResourceLocation, ContentType)] = &[
+const RESOURCES: &[(&'static str, ResourceLocation, ContentType)] = &[
   ("script.js",    RL::Main,                       ContentType::JavaScript),
   ("LICENCE",      RL::Main,                       ContentType::Plain),
   ("libre",        RL::Main,                       ContentType::HTML),
@@ -132,8 +132,8 @@ struct WholeQueryString<T>(pub Option<T>);
 
 impl<'a,'r,T> FromRequest<'a,'r> for WholeQueryString<T>
   where T: 'a + FromFormValue<'a>,
-        T::Error : Debug,
-        for <'x> &'x T::Error : Into<rocket::http::Status>,
+        T::Error: Debug,
+        for <'x> &'x T::Error: Into<rocket::http::Status>,
 {
   type Error = <T as FromFormValue<'a>>::Error;
   fn from_request(r: &'a rocket::Request<'r>)
@@ -154,7 +154,7 @@ pub struct Parse<T: FromStr>(pub T);
 
 impl<'r, T> FromParam<'r> for Parse<T>
   where T: FromStr,
-        <T as FromStr>::Err : Debug,
+        <T as FromStr>::Err: Debug,
 //  where  : Into<OE>
 {
   type Error = <T as FromStr>::Err;
@@ -166,7 +166,7 @@ impl<'r, T> FromParam<'r> for Parse<T>
 
 #[get("/_/updates?<ctoken>&<gen>")]
 #[throws(OER)]
-fn updates<'r>(ctoken : InstanceAccess<ClientId>, gen: u64,
+fn updates<'r>(ctoken: InstanceAccess<ClientId>, gen: u64,
                cors: rocket_cors::Guard<'r>)
                -> impl response::Responder<'r> {
   let gen = Generation(gen);
index ec31a2389b962ac23817c05e9cb9c08552506dfa..e49dbd37089e45ee89bb1ddbdcf0ae200d8b822a 100644 (file)
@@ -65,7 +65,7 @@ fn session(form: Json<SessionForm>,
   session_inner(form, layout.map(|pl| pl.0))?
 }
 
-fn session_inner(form : Json<SessionForm>,
+fn session_inner(form: Json<SessionForm>,
                  layout: Option<PresentationLayout>)
                  -> Result<Template,OE> {
   // make session in this game, log a message to other players
@@ -77,8 +77,8 @@ fn session_inner(form : Json<SessionForm>,
     let client = ig.clients.insert(cl);
 
     let ciad = InstanceAccessDetails {
-      gref : iad.gref.clone(),
-      ident : client,
+      gref: iad.gref.clone(),
+      ident: client,
       acctid: iad.acctid,
     };
     let ctoken = record_token(&mut ig, ciad)?;
@@ -136,7 +136,7 @@ fn session_inner(form : Json<SessionForm>,
       uses.push(for_piece);
     }
 
-    let mut timestamp_abbrev : Option<String> = None;
+    let mut timestamp_abbrev: Option<String> = None;
 
     let log = itertools::chain(
       ig.gs.log.iter()