// ---------- piece trait, and rendering ----------
#[typetag::serde]
-pub trait Outline : Send + Debug {
- fn surround_path(&self, pri : &PieceRenderInstructions) -> Result<Html, IE>;
- fn thresh_dragraise(&self, pri : &PieceRenderInstructions)
+pub trait Outline: Send + Debug {
+ fn surround_path(&self, pri: &PieceRenderInstructions) -> Result<Html, IE>;
+ fn thresh_dragraise(&self, pri: &PieceRenderInstructions)
-> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> [Pos;2];
}
}
#[typetag::serde]
-pub trait Piece : Outline + Send + Debug {
+pub trait Piece: Outline + Send + Debug {
fn nfaces(&self) -> RawFaceId;
#[throws(InternalError)]
// #[throws] doesn't work here for some reason
fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) -> IR;
- fn describe_html(&self, face : Option<FaceId>) -> Html;
+ fn describe_html(&self, face: Option<FaceId>) -> Html;
fn delete_hook(&self, _p: &PieceState, _gs: &mut GameState)
-> ExecuteGameChangeUpdates {
#[derive(Debug,Copy,Clone)]
pub struct PieceRenderInstructions {
- pub id : VisiblePieceId,
- pub face : FaceId,
+ pub id: VisiblePieceId,
+ pub face: FaceId,
}
#[typetag::serde(tag="type")]
-pub trait PieceSpec : Debug {
+pub trait PieceSpec: Debug {
fn count(&self) -> usize { 1 }
- fn load(&self, i: usize) -> Result<Box<dyn Piece>,SpecError>;
+ fn load(&self, i: usize) -> Result<Box<dyn Piece>, SpecError>;
}
// ========== implementations ==========
}
impl Display for Generation {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- Display::fmt(&self.0,f)
+ Display::fmt(&self.0, f)
}
}
}
}
-pub trait ClampTable : Sized {
+pub trait ClampTable: Sized {
fn clamped(self, range: Self) -> (Self, bool);
}
impl Debug for Html {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- const MAX : usize = 23;
+ const MAX: usize = 23;
if self.0.len() < MAX {
write!(f, "<{}>", &self.0)
} else {
}
pub trait PieceExt {
- fn make_defs(&self, pri : &PieceRenderInstructions) -> Result<Html,IE>;
- fn describe_pri(&self, pri : &PieceRenderInstructions) -> Html;
+ fn make_defs(&self, pri: &PieceRenderInstructions) -> Result<Html, IE>;
+ fn describe_pri(&self, pri: &PieceRenderInstructions) -> Html;
fn ui_operations(&self) -> Result<Vec<UoDescription>, IE>;
}
impl<T> PieceExt for T where T: Piece + ?Sized {
#[throws(IE)]
- fn make_defs(&self, pri : &PieceRenderInstructions) -> Html {
+ fn make_defs(&self, pri: &PieceRenderInstructions) -> Html {
let mut defs = Html(String::new());
let dragraise = match self.thresh_dragraise(pri)? {
Some(n) if n < 0 => throw!(SE::NegativeDragraise),
defs
}
- fn describe_pri(&self, pri : &PieceRenderInstructions) -> Html {
+ fn describe_pri(&self, pri: &PieceRenderInstructions) -> Html {
self.describe_html(Some(pri.face))
}
// ========== ad-hoc and temporary ==========
-pub fn make_pieceid_visible(p : PieceId) -> VisiblePieceId {
+pub fn make_pieceid_visible(p: PieceId) -> VisiblePieceId {
// todo-lens need to do censorship mapping here
- let kd : slotmap::KeyData = p.into();
+ let kd: slotmap::KeyData = p.into();
VisiblePieceId(kd)
}
use crate::imports::*;
-use std::sync::PoisonError;
use slotmap::dense as sm;
+use std::sync::PoisonError;
type ME = MgmtError;
type ESU = ErrorSignaledViaUpdate;
visible_slotmap_key!{ ClientId('C') }
-const MAX_CLIENT_INACTIVITY : Duration = Duration::from_secs(200);
+const MAX_CLIENT_INACTIVITY: Duration = Duration::from_secs(200);
-const GAME_SAVE_LAG : Duration = Duration::from_millis(500);
+const GAME_SAVE_LAG: Duration = Duration::from_millis(500);
-const MAX_LOG_AGE : Duration = Duration::from_secs(10 * 86400);
+const MAX_LOG_AGE: Duration = Duration::from_secs(10 * 86400);
#[derive(Hash,Ord,PartialOrd,Eq,PartialEq,Serialize)]
#[repr(transparent)]