Skip to main content

LuaTool

Struct LuaTool 

Source
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>

Source

pub const fn new( lua: &'a Lua, name: String, description: String, schema: Json, callback: &'a Function, budget: &'a Mutex<ExecutionBudget>, ) -> Self

Source

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.

Source

pub fn name(&self) -> &str

Trait Implementations§

Source§

impl<'a> Clone for LuaTool<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Tool for LuaTool<'_>

Source§

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.

Source§

fn run<'life0, 'life1, 'async_trait>( &'life0 self, args: &'life1 Json, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Errors Read more

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>
where &'a Lua: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, &'a Function: Freeze, &'a Mutex<ExecutionBudget>: Freeze,

§

impl<'a> Move for LuaTool<'a>

§

impl<'a> Send for LuaTool<'a>
where &'a Lua: Send, RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, &'a Function: Send, &'a Mutex<ExecutionBudget>: Send,

§

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>
where &'a Lua: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, &'a Function: Unpin, &'a Mutex<ExecutionBudget>: Unpin,

§

impl<'a> UnsafeUnpin for LuaTool<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.