Expand description
§Piece Identifier Notation (PIN)
A no_std, unsafe-free implementation of the
PIN v1.0.0 specification.
PIN is a compact, ASCII-only token that encodes a piece’s identity at the level of notation. A token has the shape:
[<state-modifier>]<abbr>[<terminal-marker>]matching the anchored regular expression ^[+-]?[A-Za-z]\^?$, and maps to
exactly four attributes:
| Component | Encodes | Values |
|---|---|---|
| letter case | Side | uppercase → First, lowercase → Second |
| letter | Letter | the piece-name abbreviation (A–Z) |
+ / - prefix | State | Enhanced / Diminished (else Normal) |
^ suffix | terminal status | present → terminal piece |
PIN standardizes only the encoding; the meaning of each attribute is left to the rule system. See the glossary.
§Example
use sashite_pin::{Identifier, Side, State};
let king: Identifier = "+K^".parse()?;
assert_eq!(king.letter().as_char(), 'K');
assert_eq!(king.side(), Side::First);
assert_eq!(king.state(), State::Enhanced);
assert!(king.is_terminal());
// Round-trips back to its canonical, zero-allocation string form.
assert_eq!(king.encode().as_str(), "+K^");
// Cheap, infallible transformations (the type is `Copy`).
assert_eq!(king.flipped().encode().as_str(), "+k^");§Guarantees
no_stdand allocation-free: parsing borrows the input bytes and anIdentifieris a 4-byteCopyvalue; nothing is heap-allocated.- No
unsafe: the crate is built under a forbid-unsafelint policy. - Bounded, panic-free parsing: inputs longer than three bytes are rejected before inspection, and the public parsing API never panics.
- No required dependencies: the default build has an empty dependency
graph; the optional
serdefeature addsserde(keptno_std).
Structs§
- Encoded
Pin - The canonical string form of an
Identifier, stored inline. - Identifier
- A parsed PIN token: the identity of a piece at the level of notation.
- Letter
- The single-letter abbreviation of a piece name.
Enums§
- Parse
Error - The reason a string could not be parsed as a PIN token.
- Side
- The camp a piece belongs to.
- State
- The state of a piece, encoded by the optional
+/-prefix.