pub enum BoardEvent {
PositionChanged(Position),
BatteryStatus(BatteryStatus),
PieceStatus(PieceStatus),
}Expand description
A decoded board-state or status notification.
§Examples
use chessnut_move::protocol::{BoardEvent, File, Rank, Square};
fn report(event: BoardEvent) {
match event {
BoardEvent::PositionChanged(position) => {
let e4 = Square::new(File::E, Rank::Four);
println!("e4 contains {:?}", position.piece_at(e4));
}
BoardEvent::BatteryStatus(status) => {
println!("board battery: {}%", status.percentage);
}
BoardEvent::PieceStatus(status) => {
let unavailable = status
.pieces
.iter()
.filter(|piece| piece.battery_percentage.is_none())
.count();
println!("{unavailable} piece batteries are unavailable");
}
}
}Variants§
PositionChanged(Position)
The occupancy or piece arrangement of the 64 squares changed.
This event is only fired when realtime updates is enabled, and there’s not an active auto-move occurring.
BatteryStatus(BatteryStatus)
The board responded to a battery-status query.
PieceStatus(PieceStatus)
The board responded to a piece-status query.
Trait Implementations§
Source§impl Clone for BoardEvent
impl Clone for BoardEvent
Source§fn clone(&self) -> BoardEvent
fn clone(&self) -> BoardEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for BoardEvent
Source§impl Debug for BoardEvent
impl Debug for BoardEvent
impl Eq for BoardEvent
Source§impl Hash for BoardEvent
impl Hash for BoardEvent
Source§impl PartialEq for BoardEvent
impl PartialEq for BoardEvent
impl StructuralPartialEq for BoardEvent
Auto Trait Implementations§
impl Freeze for BoardEvent
impl RefUnwindSafe for BoardEvent
impl Send for BoardEvent
impl Sync for BoardEvent
impl Unpin for BoardEvent
impl UnsafeUnpin for BoardEvent
impl UnwindSafe for BoardEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more