sashite-feen 0.1.0

Field Expression Encoding Notation (FEEN): a compact, ASCII-only, no_std, zero-allocation validator and encoder for board-game positions in abstract strategy games, built on EPIN and SIN.
Documentation
//! Resource bounds enforced on every input.
//!
//! These caps keep memory and time bounded even on untrusted input, which is
//! what lets the parser be a single-pass, allocation-free, panic-free validator:
//! the length check runs before any parsing, the dimension count bounds a
//! fixed-size coherence stack, and the per-dimension cap keeps every dimension
//! size in one byte.

/// Maximum length, in bytes, of a FEEN string.
///
/// Any longer input is rejected with [`crate::ParseError::InputTooLong`] before
/// a single byte is parsed. 4096 bytes comfortably covers any realistic board
/// position (a fully occupied 255×255 board encodes to roughly 1500 bytes).
pub const MAX_STRING_LENGTH: usize = 4096;

/// Maximum number of board dimensions (1D, 2D, or 3D).
///
/// This is a `usize` so it can size the fixed-length arrays that hold a board's
/// shape ([`crate::Shape`]) and drive the dimensional-coherence check without
/// any heap allocation. A deeper separator nesting is rejected with
/// [`crate::ParseError::TooManyDimensions`].
pub const MAX_DIMENSIONS: usize = 3;

/// Maximum number of cells along any single dimension.
///
/// Set to [`u8::MAX`] so that every dimension size fits in one byte: this is the
/// largest cap that keeps a [`crate::Shape`] dimension a `u8` (256 would force a
/// `u16` to gain a single, practically useless value). A larger dimension is
/// rejected with [`crate::ParseError::DimensionTooLarge`].
pub const MAX_DIMENSION_SIZE: u8 = u8::MAX;

/// Maximum number of squares on a board (255 × 255).
///
/// A board with more squares is rejected with
/// [`crate::ParseError::TooManySquares`]. This matches the bound used by
/// [`sashite-qi`](https://docs.rs/sashite-qi), the position model FEEN builds
/// on: 65 025 = 255² keeps a flat square index within a `u16`, bounds the memory
/// a decoded position can occupy, and stays far above any real board (chess 64,
/// shōgi 81, xiangqi 90, 3-D Raumschach 125). The per-dimension cap still allows
/// each axis up to 255; this bound caps their product.
pub(crate) const MAX_SQUARE_COUNT: u32 = 65_025;