pub trait PQLFn:
Debug
+ Send
+ Sync
+ PQLFnRtn
+ PQLFnArgs
+ PQLFnEval { }Expand description
Trait for functions to be used in vm
Generated by fn_macro::pqlfn
Example:
ⓘ
#[pqlfn(arg, rtn, eval)]
pub fn hand_ranks(hand: &Hand, _street: PQLStreet) -> PQLRankSet;
pub trait PQLFnArgs {
fn arg_types(&self) -> &[PQLType] {
&[PQLType::Player, PQLType::Street]
}
}
pub trait PQLFnRtn {
fn rtn_type(&self) -> PQLType {
PQLType::RankSet
}
}
pub trait PQLFnEval {
fn evaluate(
&self,
buffer: &mut VmBuffer,
store: &mut VmStore,
stack: &mut VmStack,
) -> Result<VmStackValue, PQLError> {
Ok(self(arg_range(buffer, store, stack), (&*buffer).into()).into())
}
}each pqlfn also generates a match arm for FromStr of &dyn PQLFn
ⓘ
"handranks" => Ok(&(hand_ranks as fn(&Hand, PQLStreet) -> PQLRankSet)),