pub struct Function<'host> { /* private fields */ }Expand description
An function which is callable by espy or its host.
This differs from Program in that it may accept an argument;
use Function::pipe or Function::piped to provide one,
and Function::eval to evaluate the function.
To instead provide a Rust function to espy, use Function::borrow or
Function::owned with the ExternFn and ExternFnOwned traits,
respectively.
Implementations§
Source§impl<'host> Function<'host>
impl<'host> Function<'host>
pub fn borrow(external: &'host dyn ExternFn) -> Self
pub fn owned(external: Rc<dyn ExternFnOwned>) -> Self
pub fn to_static(&self) -> Option<StaticFunction>
Sourcepub fn eval(self) -> Result<Value<'host>, Error>
pub fn eval(self) -> Result<Value<'host>, Error>
§Errors
Returns an error if evaluating the function results in an error
Sourcepub fn pipe(&mut self, argument: Value<'host>)
pub fn pipe(&mut self, argument: Value<'host>)
Concatentes the function’s argument list with argument.
pub fn piped(self, argument: Value<'host>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl<'host> Freeze for Function<'host>
impl<'host> !RefUnwindSafe for Function<'host>
impl<'host> !Send for Function<'host>
impl<'host> !Sync for Function<'host>
impl<'host> Unpin for Function<'host>
impl<'host> !UnwindSafe for Function<'host>
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