runtime/turn/wave/
closure.rs1use kernel::{AxCode, AxError, TimeMs, Tool, ToolCall, ToolMeta, ToolOutcome};
10
11use super::{Admitted, ConcurrentInvoke};
12use crate::bench::Ticket;
13
14impl<F> ConcurrentInvoke for F
18where
19 F: FnMut(&ToolCall, TimeMs) -> Result<ToolOutcome, AxError>,
20{
21 fn meta_of(&self, _call: &ToolCall) -> Option<&ToolMeta> {
22 None
23 }
24
25 fn admit(&mut self, call: &ToolCall, t: TimeMs) -> Admitted {
26 Admitted::Answered(self(call, t))
27 }
28
29 fn tool(&self, _ticket: &Ticket) -> Result<&dyn Tool, AxError> {
30 Err(unheld_ticket())
31 }
32
33 fn account(
34 &mut self,
35 _call: &ToolCall,
36 _ticket: Ticket,
37 _answered: Result<ToolOutcome, AxError>,
38 ) -> Result<ToolOutcome, AxError> {
39 Err(unheld_ticket())
40 }
41}
42
43fn unheld_ticket() -> AxError {
44 AxError::failure(
45 AxCode::ToolUnavailable,
46 "run a cleared tool call",
47 "a tool face that answers every call as it admits it was handed a ticket",
48 )
49 .with_recovery("report this against runtime::turn::wave: only a bench issues tickets")
50}