From: Ian Jackson Date: Mon, 1 Feb 2021 00:02:46 +0000 (+0000) Subject: style: Remove space before : in daemon/ X-Git-Tag: otter-0.4.0~567 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=97f98cbd1f47e5aa37590fb888d1d73bb032c9a2;p=otter.git style: Remove space before : in daemon/ Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index d863ba7f..e96b0c07 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -15,24 +15,24 @@ pub struct InstanceAccess<'i, Id> { } impl<'r, Id> FromFormValue<'r> for InstanceAccess<'r, Id> - where Id : AccessId, OE : From + where Id: AccessId, OE: From { 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 { - ctoken : RawToken, - piece : VisiblePieceId, - gen : Generation, - cseq : ClientSequence, - op : O, +struct ApiPiece { + 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(form : Json>) +fn api_piece_op(form: Json>) -> 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="
")] #[throws(OER)] - fn $fn(form : Json>) + fn $fn(form: Json>) -> 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", diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 33f46221..313056ea 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -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, P: Into>> @@ -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) -> Result> ( 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> = match count { + let count: Box> = 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>>( &self, ag: &AccountsGuard, @@ -1172,7 +1172,7 @@ fn do_authorise_scope(cs: &CommandStream, wanted: &AccountScope) match &wanted { AccountScope::Server => { - let y : Authorisation = { + let y: Authorisation = { 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 } + struct AuthorisedIf { authorised_for: Option } - const SERVER_ONLY : (AuthorisedIf, Authorisation) = ( + const SERVER_ONLY: (AuthorisedIf, Authorisation) = ( AuthorisedIf { authorised_for: None }, Authorisation::authorised(&InUserList), ); diff --git a/daemon/main.rs b/daemon/main.rs index da569460..cc0534e6 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -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(pub Option); impl<'a,'r,T> FromRequest<'a,'r> for WholeQueryString where T: 'a + FromFormValue<'a>, - T::Error : Debug, - for <'x> &'x T::Error : Into, + T::Error: Debug, + for <'x> &'x T::Error: Into, { type Error = >::Error; fn from_request(r: &'a rocket::Request<'r>) @@ -154,7 +154,7 @@ pub struct Parse(pub T); impl<'r, T> FromParam<'r> for Parse where T: FromStr, - ::Err : Debug, + ::Err: Debug, // where : Into { type Error = ::Err; @@ -166,7 +166,7 @@ impl<'r, T> FromParam<'r> for Parse #[get("/_/updates?&")] #[throws(OER)] -fn updates<'r>(ctoken : InstanceAccess, gen: u64, +fn updates<'r>(ctoken: InstanceAccess, gen: u64, cors: rocket_cors::Guard<'r>) -> impl response::Responder<'r> { let gen = Generation(gen); diff --git a/daemon/session.rs b/daemon/session.rs index ec31a238..e49dbd37 100644 --- a/daemon/session.rs +++ b/daemon/session.rs @@ -65,7 +65,7 @@ fn session(form: Json, session_inner(form, layout.map(|pl| pl.0))? } -fn session_inner(form : Json, +fn session_inner(form: Json, layout: Option) -> Result { // make session in this game, log a message to other players @@ -77,8 +77,8 @@ fn session_inner(form : Json, 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, uses.push(for_piece); } - let mut timestamp_abbrev : Option = None; + let mut timestamp_abbrev: Option = None; let log = itertools::chain( ig.gs.log.iter()