sashite-epin 1.0.0

Extended Piece Identifier Notation (EPIN): a compact, ASCII-only, no_std token format that extends PIN with a native/derived style marker for abstract strategy board games.
Documentation
//! A short, runnable tour of the `sashite-epin` API.
//!
//! Run with `cargo run --example basic`.

use sashite_epin::{Identifier, Letter, Side, State};
// EPIN re-exports the PIN layer, so downstream code needs no separate
// `sashite-pin` dependency to name the underlying PIN identifier.
use sashite_epin::sashite_pin::Identifier as Pin;

fn main() -> Result<(), sashite_epin::ParseError> {
    // --- Parsing ---
    let king = Identifier::parse("+K^'")?;
    println!("token          : {king}");
    println!("letter         : {}", king.letter().as_char());
    println!("side           : {:?}", king.side());
    println!("state          : {:?}", king.state());
    println!("terminal       : {}", king.is_terminal());
    println!("derived        : {}", king.is_derived());

    // --- The underlying PIN core (escape hatch to the full PIN API) ---
    println!("pin core       : {}", king.pin().encode().as_str());

    // --- Style-status transforms (idempotent) ---
    println!("as native      : {}", king.native().encode().as_str());
    println!("as derived     : {}", king.derive().encode().as_str());

    // --- Composing with PIN transformations through `with_pin` ---
    // Flip the side while preserving the native/derived flag.
    let flipped = king.with_pin(king.pin().flipped());
    println!("flipped side   : {flipped}");

    // --- Building from typed components (infallible) ---
    // The `?` converts sashite_pin::ParseError into sashite_epin::ParseError.
    let pin = Pin::new(
        Letter::try_from_char('R')?,
        Side::Second,
        State::Enhanced,
        false,
    );
    let rook = Identifier::new(pin, true);
    println!("built          : {rook} (a derived, promoted second-side rook)");

    // --- Validation without constructing ---
    println!("is_valid \"r'\"  : {}", Identifier::is_valid("r'"));
    println!("is_valid \"K'^\" : {}", Identifier::is_valid("K'^"));

    Ok(())
}