pub struct StandardHost { /* private fields */ }Expand description
Standard host for running Nybl programs in a normal OS process.
Implementations§
Source§impl StandardHost
impl StandardHost
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a host that resolves filesystem modules relative to the current working directory.
Sourcepub fn with_module_root(self, root: impl Into<PathBuf>) -> Self
pub fn with_module_root(self, root: impl Into<PathBuf>) -> Self
Configure the root directory for module resolution. An
use foo.bar then maps to <root>/foo/bar.nybl.
Sourcepub fn is_broken_pipe(&self) -> bool
pub fn is_broken_pipe(&self) -> bool
Whether stdout’s reader closed while this host was printing.
Command-line entry points use this to distinguish normal pipeline termination from other stdout failures after the runtime unwinds.
Trait Implementations§
Source§impl Clone for StandardHost
impl Clone for StandardHost
Source§impl Debug for StandardHost
impl Debug for StandardHost
Source§impl Default for StandardHost
impl Default for StandardHost
Source§impl NyblHost for StandardHost
impl NyblHost for StandardHost
Source§fn resolve_module(&mut self, name: &str) -> Option<Result<String, NyblError>>
fn resolve_module(&mut self, name: &str) -> Option<Result<String, NyblError>>
Resolve use foo.bar.baz:
- Stdlib first — when the
nybl-stdfeature is on (default),std.*names hitnybl::stdlib::resolve, which returns bundled Nybl source. Stdlib modules never touch the filesystem, so they work in every host (including ones that set amodule_rootpointed at a directory with no stdlib). When the feature is off the step is skipped, sostd.*falls through to the filesystem like any other name. - Filesystem fallback — the rest map to
<root>/foo/bar/baz.nybl. Missing files returnNoneso the runtime can raise a clean module not found error; I/O errors (e.g. permissions) are surfaced asSome(Err(...)).
Source§fn call(
&mut self,
name: &str,
args: &[Value],
line: u32,
) -> Option<Result<Value, NyblError>>
fn call( &mut self, name: &str, args: &[Value], line: u32, ) -> Option<Result<Value, NyblError>>
Called for unknown function names. Return
None = not handled.Source§fn print_error(&self, line: u32) -> Option<NyblError>
fn print_error(&self, line: u32) -> Option<NyblError>
Report a failure from the most recent
Self::on_print call. 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 StandardHost
impl RefUnwindSafe for StandardHost
impl Send for StandardHost
impl Sync for StandardHost
impl Unpin for StandardHost
impl UnsafeUnpin for StandardHost
impl UnwindSafe for StandardHost
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