}
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> {
p: &'a dyn Piece,
}
-trait ApiPieceOp : Debug {
+trait ApiPieceOp: Debug {
#[throws(ApiPieceOpError)]
fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate;
}
#[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())?;
#[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)?
}
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),
})};
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()
}
}
-const DEFKEY_FLIP : UoKey = 'f';
+const DEFKEY_FLIP: UoKey = 'f';
api_route!{
api_uo, "/_/api/k",
}
#[throws(MgmtError)]
- fn readonly<'igr, 'ig : 'igr, 'cs,
+ fn readonly<'igr, 'ig: 'igr, 'cs,
F: FnOnce(&InstanceGuard) -> Result<MgmtGameResponse,ME>,
P: Into<PermSet<TablePermission>>>
}
#[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,
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);
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();
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();
.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))
},
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 += "..";
}
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")?;
}
}
#[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,
match &wanted {
AccountScope::Server => {
- let y : Authorisation<Uid> = {
+ let y: Authorisation<Uid> = {
cs.authorised_uid(None,None)?
};
y.therefore_ok()
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),
);
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),
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>)
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;
#[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);
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
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)?;
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()