Skip to main content

Crate sashite_pin

Crate sashite_pin 

Source
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:

ComponentEncodesValues
letter caseSideuppercase → First, lowercase → Second
letterLetterthe piece-name abbreviation (AZ)
+ / - prefixStateEnhanced / Diminished (else Normal)
^ suffixterminal statuspresent → 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_std and allocation-free: parsing borrows the input bytes and an Identifier is a 4-byte Copy value; nothing is heap-allocated.
  • No unsafe: the crate is built under a forbid-unsafe lint 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 serde feature adds serde (kept no_std).

Structs§

EncodedPin
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§

ParseError
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.