pub struct StringModuleHost {
pub prints: Vec<String>,
/* private fields */
}Expand description
A minimal BopHost that captures print output and serves
modules from an in-memory string table.
Useful for tests, playgrounds, and embedders that want
resolver-backed imports without writing a full BopHost
from scratch. For embedders that only need module resolution
(and have their own print handling), use resolve_from_map
directly inside a custom trait impl instead.
Fields§
§prints: Vec<String>Each print(...) invocation appends one entry. Leave
public so tests can assert on output without going
through an accessor.
Implementations§
Source§impl StringModuleHost
impl StringModuleHost
Sourcepub fn new<I, K, V>(modules: I) -> Self
pub fn new<I, K, V>(modules: I) -> Self
Build a host preloaded with the given module map.
The iterator yields (name, source) pairs. Later entries
with the same name overwrite earlier ones.
Trait Implementations§
Source§impl BopHost for StringModuleHost
impl BopHost for StringModuleHost
Source§fn call(
&mut self,
_name: &str,
_args: &[Value],
_line: u32,
) -> Option<Result<Value, BopError>>
fn call( &mut self, _name: &str, _args: &[Value], _line: u32, ) -> Option<Result<Value, BopError>>
Called for unknown function names. Return
None = not handled.Source§fn resolve_module(&mut self, name: &str) -> Option<Result<String, BopError>>
fn resolve_module(&mut self, name: &str) -> Option<Result<String, BopError>>
Resolve an
use target to Bop source. Read moreSource§fn function_hint(&self) -> &str
fn function_hint(&self) -> &str
Hint text for “function not found” errors.
Auto Trait Implementations§
impl Freeze for StringModuleHost
impl RefUnwindSafe for StringModuleHost
impl Send for StringModuleHost
impl Sync for StringModuleHost
impl Unpin for StringModuleHost
impl UnsafeUnpin for StringModuleHost
impl UnwindSafe for StringModuleHost
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