pub struct NativeFn {
pub name: Arc<str>,
pub arity: Arity,
pub func: NativeFnFunc,
pub blocking_func: Option<NativeFnFunc>,
}Fields§
§name: Arc<str>§arity: Arity§func: NativeFnFunc§blocking_func: Option<NativeFnFunc>Optional adapter that marshals owned inputs and offloads native work.
Implementations§
Source§impl NativeFn
impl NativeFn
Sourcepub fn new(name: impl Into<Arc<str>>, arity: Arity, func: NativeFnPtr) -> Self
pub fn new(name: impl Into<Arc<str>>, arity: Arity, func: NativeFnPtr) -> Self
Create from a bare function pointer (backwards-compatible).
Sourcepub fn with_closure(
name: impl Into<Arc<str>>,
arity: Arity,
func: impl Fn(&[Value]) -> ValueResult<Value> + 'static,
) -> Self
pub fn with_closure( name: impl Into<Arc<str>>, arity: Arity, func: impl Fn(&[Value]) -> ValueResult<Value> + 'static, ) -> Self
Create from a closure or any Fn(&[Value]) -> ValueResult<Value>.
Sourcepub fn with_blocking(
name: impl Into<Arc<str>>,
arity: Arity,
func: impl Fn(&[Value]) -> ValueResult<Value> + 'static,
blocking_func: impl Fn(&[Value]) -> ValueResult<Value> + 'static,
) -> Self
pub fn with_blocking( name: impl Into<Arc<str>>, arity: Arity, func: impl Fn(&[Value]) -> ValueResult<Value> + 'static, blocking_func: impl Fn(&[Value]) -> ValueResult<Value> + 'static, ) -> Self
Create a native function with a separate owned-work blocking adapter. The adapter must keep managed conversions on the caller’s isolate.
Sourcepub fn call_blocking(&self, args: &[Value]) -> ValueResult<Value>
pub fn call_blocking(&self, args: &[Value]) -> ValueResult<Value>
Call the blocking adapter. Reject unsupported functions before execution.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NativeFn
impl !Send for NativeFn
impl !Sync for NativeFn
impl !UnwindSafe for NativeFn
impl Freeze for NativeFn
impl Unpin for NativeFn
impl UnsafeUnpin for NativeFn
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