extern crate alloc;
use alloc::string::String;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CalloutResult {
Success,
Fail,
Skip,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CalloutDir {
Progress,
Retraction,
Both,
}
#[derive(Clone, Debug)]
pub struct CalloutCtx<'a> {
pub name: &'a str,
pub args: &'a str,
pub tag: Option<&'a str>,
pub body: &'a str,
pub haystack: &'a [u8],
pub current: usize,
pub dir: CalloutDir,
}
pub type CalloutFn = fn(&CalloutCtx<'_>) -> CalloutResult;
pub fn builtin_skip(_ctx: &CalloutCtx<'_>) -> CalloutResult {
CalloutResult::Skip
}
pub fn describe(ctx: &CalloutCtx<'_>) -> String {
alloc::format!(
"callout name={} args={} pos={}",
ctx.name,
ctx.args,
ctx.current
)
}