From 30f90f98900878b7aa23d358ea0bf5b203537615 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 23 Apr 2022 09:51:01 +0100 Subject: [PATCH] Drop use of fehler in PieceTrait definition, for ambassador Signed-off-by: Ian Jackson --- src/gamestate.rs | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index 98e41037..59207446 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -192,21 +192,21 @@ pub trait PieceBaseTrait: OutlineTrait + Send + Debug + 'static { #[typetag::serde] // usual variable: p pub trait PieceTrait: PieceBaseTrait + Send + Debug + 'static { - #[throws(InternalError)] - fn add_ui_operations(&self, _: ShowUnocculted, + fn add_ui_operations(&self, _y: ShowUnocculted, _upd: &mut Vec, - _gs: &GameState, _gpc: &GPiece) { } + _gs: &GameState, _gpc: &GPiece) -> Result<(),IE> { + Ok(()) + } - fn ui_operation(&self, _: ShowUnocculted, _a: ApiPieceOpArgs<'_>, + fn ui_operation(&self, _y: ShowUnocculted, _a: ApiPieceOpArgs<'_>, _opname: &str, _wrc: WhatResponseToClientOp) -> Result { throw!(Ia::BadUiOperation) } /// Can return `false` to mean "I will handle it in ui_operation" - #[throws(ApiPieceOpError)] - fn ui_permit_flip(&self, _gpc: &GPiece) -> bool { - true + fn ui_permit_flip(&self, _gpc: &GPiece) -> Result { + Ok(true) } // #[throws] doesn't work here - fehler #todo @@ -218,17 +218,17 @@ pub trait PieceTrait: PieceBaseTrait + Send + Debug + 'static { /// Piece is responsible for dealing with the possibility that they /// may be occulted! - #[throws(IE)] fn held_change_hook(&self, _ig: &InstanceRef, _gpieces: &mut GPieces, _piece: PieceId, _was_held: Option) - -> UnpreparedUpdates { None } + -> Result { Ok(None) } - #[throws(IE)] fn loaded_hook(&self, _piece: PieceId, - _gs: &mut GameState, _ig: &InstanceRef) { } + _gs: &mut GameState, _ig: &InstanceRef) -> Result<(),IE> { + Ok(()) + } /// Not called if the whole game is destroyed. /// You can use Drop of course but it's not usually much use since @@ -244,19 +244,18 @@ pub trait PieceTrait: PieceBaseTrait + Send + Debug + 'static { None } - #[throws(ApiPieceOpError)] - fn op_multigrab(&self, _: ApiPieceOpArgs, _: PieceRenderInstructions, - _: MultigrabQty) -> OpOutcomeThunk { + fn op_multigrab(&self, _a: ApiPieceOpArgs, _pri: PieceRenderInstructions, + _qty: MultigrabQty) + -> Result { Err(Ia::BadPieceStateForOperation)? } - #[throws(IE)] - fn abs_bbox(&self, p: &GPiece) -> Rect { - Rect { corners: self.bbox_approx()?.corners.iter().map( + fn abs_bbox(&self, p: &GPiece) -> Result { + Ok(Rect { corners: self.bbox_approx()?.corners.iter().map( |c| *c + p.pos ) - .collect::,_>>()? - .into_inner().unwrap() } + .collect::,_>>()? + .into_inner().unwrap() }) } } -- 2.30.2