Skip to main content

Crate sashite_epin

Crate sashite_epin 

Source
Expand description

§Extended Piece Identifier Notation (EPIN)

A no_std, unsafe-free implementation of the EPIN v1.0.0 specification.

EPIN is a strict superset of PIN: it inherits the four PIN attributes (piece name, side, state, terminal status) and adds a single optional trailing marker, the derivation marker ', which flags whether a piece’s style is native or derived. A token has the shape:

<pin>[']        e.g.  K   r'   +K^   -k^'

matching the anchored regular expression \A[-+]?[A-Za-z]\^?'?\z. What “native” and “derived” mean, and how a concrete style is resolved, is defined by the surrounding context — EPIN encodes only the flag.

This crate is a thin layer over sashite_pin: an Identifier is a PIN sashite_pin::Identifier paired with the native/derived flag. The PIN layer is re-exported (see below) so callers can reach the full PIN API — including the type returned by Identifier::pin — without declaring sashite-pin themselves.

§Example

use sashite_epin::{Identifier, Side};

let king: Identifier = "+K^'".parse()?;
assert_eq!(king.letter().as_char(), 'K');
assert_eq!(king.side(), Side::First);
assert!(king.is_terminal());
assert!(king.is_derived());

// The underlying PIN token is one method away.
assert_eq!(king.pin().encode().as_str(), "+K^");

// Native/derived is a single, idempotent flag.
assert_eq!(king.native().encode().as_str(), "+K^");
assert_eq!(king.encode().as_str(), "+K^'");

§Guarantees

  • no_std and allocation-free: parsing borrows the input bytes and an Identifier is a small Copy value; nothing is heap-allocated.
  • No unsafe: the crate is built under a forbid-unsafe lint policy.
  • Single source of truth: all PIN-level parsing, validation, and encoding is delegated to sashite_pin; EPIN only adds the ' marker.
  • No required dependencies beyond PIN: the optional serde feature adds serde (and turns on sashite-pin/serde), and keeps the crate no_std.

Re-exports§

pub use sashite_pin;

Structs§

EncodedEpin
The canonical string form of an Identifier, stored inline.
Identifier
A parsed EPIN token: a PIN identity plus a native/derived style flag.
Letter
The single-letter abbreviation of a piece name.

Enums§

ParseError
The reason a string could not be parsed as an EPIN token.
Side
The camp a piece belongs to.
State
The state of a piece, encoded by the optional + / - prefix.