pub struct LuaTool<'a> { /* private fields */ }Expand description
A Lua function exposed to the loop as a tool.
The description and schema come from the manifest at construction, because
def is what the model reads and a tool that arrives with an empty one is a
bare name the model cannot call.
Implementations§
Source§impl<'a> LuaTool<'a>
impl<'a> LuaTool<'a>
pub const fn new( lua: &'a Lua, name: String, description: String, schema: Json, callback: &'a Function, budget: &'a Mutex<ExecutionBudget>, ) -> Self
Sourcepub const fn with_timeout(self, timeout: Duration) -> Self
pub const fn with_timeout(self, timeout: Duration) -> Self
Cap how long one call may run.
Best effort, not a guarantee: the Luau interrupt fires at any call or loop iteration, so a single long native function still finishes. The interrupt is best effort, not a guarantee.
pub fn name(&self) -> &str
Trait Implementations§
Source§impl Tool for LuaTool<'_>
impl Tool for LuaTool<'_>
Source§fn def(&self) -> ToolDef
fn def(&self) -> ToolDef
What the model is told about this tool.
A Lua-registered tool and a built-in one are the same ToolDef, which
holds only if this returns the manifest’s own description and schema.
Returning an empty pair made every extension tool a bare name, in print
mode, the terminal, and ACP alike.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for LuaTool<'a>
impl<'a> !UnwindSafe for LuaTool<'a>
impl<'a> Forget for LuaTool<'a>
impl<'a> Freeze for LuaTool<'a>
impl<'a> Move for LuaTool<'a>
impl<'a> Send for LuaTool<'a>
impl<'a> Sync for LuaTool<'a>where
Arc<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Sync,
RawVecInner: Sync,
NodeRef<Owned, String, Value, LeafOrInternal>: Sync,
BoxRaw<(String, Value)>: Sync,
Weak<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Sync,
Atomic<*mut ()>: Sync,
Mutex<ExecutionBudget>: Sync,
impl<'a> Unpin for LuaTool<'a>
impl<'a> UnsafeUnpin for LuaTool<'a>where
&'a Lua: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
&'a Function: UnsafeUnpin,
&'a Mutex<ExecutionBudget>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more