Skip to main content

StandardHost

Struct StandardHost 

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

Standard host for running Nybl programs in a normal OS process.

Implementations§

Source§

impl StandardHost

Source

pub fn new() -> Self

Create a host that resolves filesystem modules relative to the current working directory.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StandardHost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StandardHost

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl NyblHost for StandardHost

Source§

fn resolve_module(&mut self, name: &str) -> Option<Result<String, NyblError>>

Resolve use foo.bar.baz:

  1. Stdlib first — when the nybl-std feature is on (default), std.* names hit nybl::stdlib::resolve, which returns bundled Nybl source. Stdlib modules never touch the filesystem, so they work in every host (including ones that set a module_root pointed at a directory with no stdlib). When the feature is off the step is skipped, so std.* falls through to the filesystem like any other name.
  2. Filesystem fallback — the rest map to <root>/foo/bar/baz.nybl. Missing files return None so the runtime can raise a clean module not found error; I/O errors (e.g. permissions) are surfaced as Some(Err(...)).
Source§

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 on_print(&mut self, message: &str)

Called by print().
Source§

fn print_error(&self, line: u32) -> Option<NyblError>

Report a failure from the most recent Self::on_print call. Read more
Source§

fn function_hint(&self) -> &str

Hint text for “function not found” errors.
Source§

fn call_method( &mut self, receiver: &HostValue, method: &str, args: &[Value], line: u32, ) -> Option<Result<Value, NyblError>>

Called for a non-common method on an opaque HostValue. Return None when this host does not implement the method. Read more
Source§

fn on_tick(&mut self) -> Result<(), NyblError>

Called each tick. Return Err to halt execution.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.