pub struct ScriptProviderLayer { /* private fields */ }Expand description
Lazy, hot-reloading resolver for script providers.
Implementations§
Source§impl ScriptProviderLayer
impl ScriptProviderLayer
Sourcepub fn new(
dir: PathBuf,
overrides: HashMap<String, ScriptProviderSpec>,
default_caps: HashMap<String, ModelCapabilities>,
request_timeout_secs: Option<u64>,
env_allowlist: Vec<String>,
) -> Self
pub fn new( dir: PathBuf, overrides: HashMap<String, ScriptProviderSpec>, default_caps: HashMap<String, ModelCapabilities>, request_timeout_secs: Option<u64>, env_allowlist: Vec<String>, ) -> Self
Build a layer over dir, with per-provider overrides, global model
capability overrides, and the global request timeout.
Sourcepub fn get_or_load(&self, name: &str) -> Option<Arc<dyn Provider>>
pub fn get_or_load(&self, name: &str) -> Option<Arc<dyn Provider>>
Get (or lazily load / reload) the provider named name, or None when
there is no such script or it fails to load.
The cache lock is taken three times - a read, then a write on whichever
arm the compile lands on - and is never held across
RhaiProvider::from_script, which parses and initializes an arbitrary
user-authored .rhai file. That call is the slowest and least
trustworthy thing this layer does; holding a process-wide lock across it
serialized every agent’s provider lookup behind one compile, and a panic
inside it poisoned the cache for the whole daemon.
The cost is that two callers racing on the same cold name may both
compile it. Both get a working provider and the later insert wins -
wasted work, never a wrong answer, and it self-corrects on the next
lookup because entries are validated by mtime.
Auto Trait Implementations§
impl !Freeze for ScriptProviderLayer
impl RefUnwindSafe for ScriptProviderLayer
impl Send for ScriptProviderLayer
impl Sync for ScriptProviderLayer
impl Unpin for ScriptProviderLayer
impl UnsafeUnpin for ScriptProviderLayer
impl UnwindSafe for ScriptProviderLayer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.