pub struct ScopedExpr { /* private fields */ }Expand description
Shape 2 — a polydat expression bound to a parent
kernel’s lexical scope. Compiled into a sub-context whose named
output is the expression, evaluable many times against injected
inputs. The return is whatever Wire type the bound stub was
qualified with (ExprStub::returning::<T>), or its natural
truthiness (is_true). A general-purpose, scope-bound, callable
expression holder.
Implementations§
Source§impl ScopedExpr
impl ScopedExpr
Sourcepub fn bind(
parent: &dyn Kernel,
output: impl Into<String>,
matter: GraphMatter,
) -> Result<Self, String>
pub fn bind( parent: &dyn Kernel, output: impl Into<String>, matter: GraphMatter, ) -> Result<Self, String>
Bind matter — which must define the named output (plus any
extern wires it reads) — into a sub-context of parent, on
parent’s engine. The expression is compiled once; call it
repeatedly via eval / is_true after set-ing its inputs.
Sourcepub fn set(&mut self, name: &str, value: Value) -> Result<&mut Self, WriteError>
pub fn set(&mut self, name: &str, value: Value) -> Result<&mut Self, WriteError>
Set a runtime input wire by name before evaluating, converted to
the wire’s type by the one conversion rule
(crate::convert::to_port).
Refused with the error Kernel::set_input
gives: WriteError::UnknownWire for a
name the expression has no input for,
WriteError::CoordinateSlot for a
coordinate, WriteError::TypeMismatch
for a value that does not convert to the wire’s type, and
WriteError::ConstSlot for a const.
Auto Trait Implementations§
impl !RefUnwindSafe for ScopedExpr
impl !UnwindSafe for ScopedExpr
impl Freeze for ScopedExpr
impl Send for ScopedExpr
impl Sync for ScopedExpr
impl Unpin for ScopedExpr
impl UnsafeUnpin for ScopedExpr
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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