Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

The embedded VM and everything registered against it.

Implementations§

Source§

impl Registry

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn hooks(&self) -> &[Hook]

The hooks an extension registered, in load order.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub const fn lua(&self) -> &Lua

The VM, for a caller that needs to read a value out.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Registry

§

impl !UnwindSafe for Registry

§

impl Forget for Registry

§

impl Freeze for Registry
where *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 Registry
where 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 Registry
where 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 Registry
where 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 Registry

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> 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, 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.