sashite_qi/lib.rs
1//! # Qi — a position model for two-player board games
2//!
3//! `Qi` is an immutable, format-agnostic model of a board-game **position** as
4//! defined by the [Sashité Game Protocol](https://sashite.dev/game-protocol/).
5//! A position encodes exactly four things: a **board** of squares, two **hands**
6//! of off-board pieces, a **style** per player, and the **turn**.
7//!
8//! ## Generic over pieces and styles
9//!
10//! Pieces and styles are type parameters, so `Qi` is independent of any
11//! notation: the caller chooses how a piece and a style are represented (a typed
12//! identifier, an interned id, a string, …). The Sashité notation crates plug in
13//! their own token types; nothing here depends on them.
14//!
15//! ## Immutable, move-based transformations
16//!
17//! Transformations consume the position and return a new one, so they chain like
18//! the protocol's value semantics while *moving* — not cloning — the underlying
19//! storage. Clone a position explicitly to keep a snapshot.
20//!
21//! ## Bounded by construction
22//!
23//! Every board is bounded — at most [`MAX_DIMENSIONS`] dimensions, each at most
24//! [`MAX_DIMENSION_SIZE`], at most [`MAX_SQUARE_COUNT`] squares — and the piece
25//! count can never exceed the square count. These invariants are checked when a
26//! position is built or transformed, so a `Qi` is safe to construct from
27//! untrusted input.
28//!
29//! ## Guarantees
30//!
31//! - **`no_std`.** The crate links only `core` and `alloc`.
32//! - **No `unsafe`.** Built under a forbid-`unsafe` lint policy.
33//! - **No required dependencies.** `serde` is an optional, off-by-default add-on.
34
35#![no_std]
36
37extern crate alloc;
38
39mod error;
40mod limits;
41mod player;
42mod qi;
43
44#[cfg(feature = "serde")]
45mod serde_impl;
46
47pub use crate::error::Error;
48pub use crate::limits::{MAX_DIMENSIONS, MAX_DIMENSION_SIZE, MAX_SQUARE_COUNT};
49pub use crate::player::Player;
50pub use crate::qi::Qi;