Trait otter_api_tests::PieceTrait
source · [−]pub trait PieceTrait: 'static + PieceBaseTrait + Downcast + Send + Debug + Serialize + Deserialize {
Show 14 methods
fn svg_piece(
&self,
f: &mut Html,
gpc: &GPiece,
gs: &GameState,
id: VisiblePieceId
) -> Result<(), InternalError>;
fn describe_html(
&self,
gpc: &GPiece,
_goccults: &GOccults
) -> Result<Html, InternalError>;
fn add_ui_operations(
&self,
_y: ShowUnocculted,
_upd: &mut Vec<UoDescription, Global>,
_gs: &GameState,
_gpc: &GPiece
) -> Result<(), InternalError> { ... }
fn ui_operation(
&self,
_y: ShowUnocculted,
_a: ApiPieceOpArgs<'_>,
_opname: &str,
_wrc: WhatResponseToClientOp
) -> Result<OpOutcomeThunkGeneric<(PlayerId, PieceId), (PieceUpdate, Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>), ApiPieceOpError>, ApiPieceOpError> { ... }
fn ui_permit_flip(&self, _gpc: &GPiece) -> Result<bool, ApiPieceOpError> { ... }
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gplayers: &DenseSlotMap<PlayerId, GPlayer>,
_ipieces: &IPieces,
_goccults: &GOccults,
_gpieces: &mut GPieces,
_tpiece: PieceId,
_was_held: Option<PlayerId>
) -> Result<OpOutcomeThunkGeneric<(PlayerId,), Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>, InternalError>, InternalError> { ... }
fn save_reloaded_hook(
&self,
_piece: PieceId,
_gs: &mut GameState,
_ig: &InstanceRef
) -> Result<(), InternalError> { ... }
fn loaded_hook_preview(
&self,
_gpc: &mut GPiece
) -> Result<(), InternalError> { ... }
fn bbox_preview(&self) -> Result<RectC<i32>, InternalError> { ... }
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates { ... }
fn sortkey(&self) -> Option<&str> { ... }
fn occultation_notify_hook(
&self,
_piece: PieceId
) -> Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
{ ... }
fn op_multigrab(
&self,
_a: ApiPieceOpArgs<'_>,
_show: ShowUnocculted,
_qty: u32,
_new_z: ShouldSetZLevel
) -> Result<OpOutcomeThunkGeneric<(PlayerId, PieceId), (PieceUpdate, Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>), ApiPieceOpError>, ApiPieceOpError> { ... }
fn abs_bbox(&self, p: &GPiece) -> Result<RectC<i32>, InternalError> { ... }
}
Required Methods
fn svg_piece(
&self,
f: &mut Html,
gpc: &GPiece,
gs: &GameState,
id: VisiblePieceId
) -> Result<(), InternalError>
fn describe_html(
&self,
gpc: &GPiece,
_goccults: &GOccults
) -> Result<Html, InternalError>
Provided Methods
fn add_ui_operations(
&self,
_y: ShowUnocculted,
_upd: &mut Vec<UoDescription, Global>,
_gs: &GameState,
_gpc: &GPiece
) -> Result<(), InternalError>
fn ui_operation(
&self,
_y: ShowUnocculted,
_a: ApiPieceOpArgs<'_>,
_opname: &str,
_wrc: WhatResponseToClientOp
) -> Result<OpOutcomeThunkGeneric<(PlayerId, PieceId), (PieceUpdate, Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>), ApiPieceOpError>, ApiPieceOpError>
fn ui_permit_flip(&self, _gpc: &GPiece) -> Result<bool, ApiPieceOpError>
fn ui_permit_flip(&self, _gpc: &GPiece) -> Result<bool, ApiPieceOpError>
Can return false
to mean “I will handle it in ui_operation”
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gplayers: &DenseSlotMap<PlayerId, GPlayer>,
_ipieces: &IPieces,
_goccults: &GOccults,
_gpieces: &mut GPieces,
_tpiece: PieceId,
_was_held: Option<PlayerId>
) -> Result<OpOutcomeThunkGeneric<(PlayerId,), Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>, InternalError>, InternalError>
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gplayers: &DenseSlotMap<PlayerId, GPlayer>,
_ipieces: &IPieces,
_goccults: &GOccults,
_gpieces: &mut GPieces,
_tpiece: PieceId,
_was_held: Option<PlayerId>
) -> Result<OpOutcomeThunkGeneric<(PlayerId,), Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>, InternalError>, InternalError>
Piece is responsible for dealing with the possibility that they may be occulted!
fn save_reloaded_hook(
&self,
_piece: PieceId,
_gs: &mut GameState,
_ig: &InstanceRef
) -> Result<(), InternalError>
fn loaded_hook_preview(&self, _gpc: &mut GPiece) -> Result<(), InternalError>
fn bbox_preview(&self) -> Result<RectC<i32>, InternalError>
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates
Not called if the whole game is destroyed. You can use Drop of course but it’s not usually much use since you don’t have a reference to the game or anything.
fn occultation_notify_hook(
&self,
_piece: PieceId
) -> Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
fn op_multigrab(
&self,
_a: ApiPieceOpArgs<'_>,
_show: ShowUnocculted,
_qty: u32,
_new_z: ShouldSetZLevel
) -> Result<OpOutcomeThunkGeneric<(PlayerId, PieceId), (PieceUpdate, Vec<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>, Global>), ApiPieceOpError>, ApiPieceOpError>
Implementations
sourceimpl dyn PieceTrait + 'static
impl dyn PieceTrait + 'static
sourcepub fn is<__T>(&self) -> bool where
__T: PieceTrait,
pub fn is<__T>(&self) -> bool where
__T: PieceTrait,
Returns true if the trait object wraps an object of type __T
.
sourcepub fn downcast<__T>(
self: Box<dyn PieceTrait + 'static, Global>
) -> Result<Box<__T, Global>, Box<dyn PieceTrait + 'static, Global>> where
__T: PieceTrait,
pub fn downcast<__T>(
self: Box<dyn PieceTrait + 'static, Global>
) -> Result<Box<__T, Global>, Box<dyn PieceTrait + 'static, Global>> where
__T: PieceTrait,
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T>(
self: Rc<dyn PieceTrait + 'static>
) -> Result<Rc<__T>, Rc<dyn PieceTrait + 'static>> where
__T: PieceTrait,
pub fn downcast_rc<__T>(
self: Rc<dyn PieceTrait + 'static>
) -> Result<Rc<__T>, Rc<dyn PieceTrait + 'static>> where
__T: PieceTrait,
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
sourcepub fn downcast_ref<__T>(&self) -> Option<&__T> where
__T: PieceTrait,
pub fn downcast_ref<__T>(&self) -> Option<&__T> where
__T: PieceTrait,
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
sourcepub fn downcast_mut<__T>(&mut self) -> Option<&mut __T> where
__T: PieceTrait,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T> where
__T: PieceTrait,
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Box<dyn PieceTrait + Send + 'static, Global>
impl<'de> Deserialize<'de> for Box<dyn PieceTrait + Send + 'static, Global>
sourcefn deserialize<D>(
deserializer: D
) -> Result<Box<dyn PieceTrait + Send + 'static, Global>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Box<dyn PieceTrait + Send + 'static, Global>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'de> Deserialize<'de> for Box<dyn PieceTrait + 'static, Global>
impl<'de> Deserialize<'de> for Box<dyn PieceTrait + 'static, Global>
sourcefn deserialize<D>(
deserializer: D
) -> Result<Box<dyn PieceTrait + 'static, Global>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Box<dyn PieceTrait + 'static, Global>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'r> RefTraitObjectPieceTraitExt<'r> for &'r (dyn PieceTrait + 'static)
impl<'r> RefTraitObjectPieceTraitExt<'r> for &'r (dyn PieceTrait + 'static)
fn downcast_piece<P>(self) -> Result<&'r P, PieceTraitDowncastFailed<'r>> where
P: PieceTrait,
sourceimpl<'r> RefTraitObjectPieceTraitExt<'r> for &'r (dyn PieceTrait + 'static)
impl<'r> RefTraitObjectPieceTraitExt<'r> for &'r (dyn PieceTrait + 'static)
fn downcast_piece_fastsplit<P>(
self
) -> Result<&'r P, PieceTraitDowncastFailed<'r>> where
P: PieceTrait,
sourceimpl<'typetag> Serialize for dyn PieceTrait + Sync + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Sync + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + Send + Sync + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Send + Sync + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + Send + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Send + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more