pub struct Registry { /* private fields */ }Expand description
The embedded VM and everything registered against it.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new(host: &Arc<dyn Host>) -> Result<Self>
pub fn new(host: &Arc<dyn Host>) -> Result<Self>
Build a sandboxed VM. The host table is installed after this returns.
§Errors
Error::Malformed when the VM cannot be created or sandboxed, which
in practice means the Luau build is broken rather than anything here.
Sourcepub fn load_dir(&mut self, dir: &Path) -> Result<Vec<LoadedScript>>
pub fn load_dir(&mut self, dir: &Path) -> Result<Vec<LoadedScript>>
Load every .lua file in dir, in name order.
§Errors
Error::Read when the directory cannot be read. A failing script inside
it is reported by Registry::load_dir rather than aborting the rest.
Sourcepub fn load_file(&mut self, path: &Path) -> Result<LoadedScript>
pub fn load_file(&mut self, path: &Path) -> Result<LoadedScript>
Load one script and register whatever it declared.
§Errors
Error::Read when the file cannot be read, and Error::Malformed when
the script itself is bad.
Sourcepub fn load_source(&mut self, source: &str, name: &str) -> Result<LoadedScript>
pub fn load_source(&mut self, source: &str, name: &str) -> Result<LoadedScript>
Load a script from memory.
§Errors
Error::Malformed when the script fails to load or registers something
malformed. The script’s name is in the message, so a model that wrote it
can be told which one.
Sourcepub fn guard<'a>(&'a self, inner: &'a dyn Tool) -> HookGuardedTool<'a>
pub fn guard<'a>(&'a self, inner: &'a dyn Tool) -> HookGuardedTool<'a>
Wrap a tool so this registry’s hooks see every call to it.
The guard is what makes an extension able to reduce the agent’s power
rather than only add to it. yk-core knows nothing about Lua, so the
check arrives as an ordinary Tool and the loop is unchanged.
Sourcepub fn tools(&self) -> Vec<LuaTool<'_>>
pub fn tools(&self) -> Vec<LuaTool<'_>>
The tools, borrowed from this registry.
This is what the loop is given, so the manifest’s description and schema
travel with the tool rather than being read off the registry here. A
second path that built a ToolDef from the same manifest is a second
answer to the same question, and it is the one that went unread.
Sourcepub fn register(&mut self, manifest: ToolInfo) -> Result<()>
pub fn register(&mut self, manifest: ToolInfo) -> Result<()>
Register a tool, called from Lua by a script.
§Errors
Error::BadArgs when the four fields are missing, and
Error::Malformed when a script tries to take over a built-in.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !UnwindSafe for Registry
impl Forget for Registry
impl Freeze for Registrywhere
*const ArcInner<ReentrantMutex<RawMutex, RawThreadId, RawLua>> is !null: Freeze,
PhantomData<ArcInner<ReentrantMutex<RawMutex, RawThreadId, RawLua>>>: Freeze,
*const LeafNode<String, ToolInfo> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, ToolInfo)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Hook>: Freeze,
*const ArcInner<Mutex<ExecutionBudget>> is !null: Freeze,
PhantomData<ArcInner<Mutex<ExecutionBudget>>>: Freeze,
impl Move for Registry
impl Send for Registrywhere
Arc<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Send,
NodeRef<Owned, String, ToolInfo, LeafOrInternal>: Send,
BoxRaw<(String, ToolInfo)>: Send,
RawVecInner: Send,
Weak<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Send,
Atomic<*mut ()>: Send,
Arc<Mutex<ExecutionBudget>>: Send,
impl Sync for Registrywhere
Arc<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Sync,
NodeRef<Owned, String, ToolInfo, LeafOrInternal>: Sync,
BoxRaw<(String, ToolInfo)>: Sync,
RawVecInner: Sync,
Weak<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Sync,
Atomic<*mut ()>: Sync,
Arc<Mutex<ExecutionBudget>>: Sync,
impl Unpin for Registrywhere
Arc<ReentrantMutex<RawMutex, RawThreadId, RawLua>>: Unpin,
*const LeafNode<String, ToolInfo> is !null: Unpin,
Box<(String, ToolInfo)>: Unpin,
*const u8 is !null: Unpin,
*const ArcInner<ReentrantMutex<RawMutex, RawThreadId, RawLua>> is !null: Unpin,
Align8<*mut ()>: Unpin,
Arc<Mutex<ExecutionBudget>>: Unpin,
impl UnsafeUnpin for Registrywhere
*const ArcInner<ReentrantMutex<RawMutex, RawThreadId, RawLua>> is !null: UnsafeUnpin,
PhantomData<ArcInner<ReentrantMutex<RawMutex, RawThreadId, RawLua>>>: UnsafeUnpin,
*const LeafNode<String, ToolInfo> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, ToolInfo)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Hook>: UnsafeUnpin,
*const ArcInner<Mutex<ExecutionBudget>> is !null: UnsafeUnpin,
PhantomData<ArcInner<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
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> ⓘ
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> ⓘ
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