openpql-runner 0.1.4

A high-performance Rust implementation of Poker Query Language (PQL), enabling SQL-like queries for poker analysis and calculations. This project is a spiritual successor to the original Java implementation developed by Odds Oracle.
Documentation
use super::*;

#[pqlfn]
pub fn rate_hi_hand(
    ctx: &PQLFnContext,
    text: &PQLString,
) -> Result<PQLHiRating, RuntimeError> {
    let game = match ctx.game {
        PQLGame::Holdem | PQLGame::Omaha => PQLGame::Holdem,
        PQLGame::ShortDeck => PQLGame::ShortDeck,
    };

    parse_cards(text).map_or(Err(RuntimeError::InvalidHand), |cards| {
        if cards.count() == 5 {
            Ok(game.eval_rating(cards, PQLCardSet::default()))
        } else {
            Err(RuntimeError::RequiresFiveCards)
        }
    })
}