pub enum NativeCallable {
Sync(Rc<dyn Fn(Vec<ApplyArgument>, &Runtime) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError>>),
Async(Rc<dyn Fn(Vec<ApplyArgument>, &Runtime) -> Pin<Box<dyn Future<Output = Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError>> + 'static>>>),
}Variants§
Sync(Rc<dyn Fn(Vec<ApplyArgument>, &Runtime) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError>>)
Async(Rc<dyn Fn(Vec<ApplyArgument>, &Runtime) -> Pin<Box<dyn Future<Output = Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError>> + 'static>>>)
Implementations§
Source§impl NativeCallable
impl NativeCallable
pub fn new_sync( function: impl Fn(Vec<ApplyArgument>, &Runtime) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError> + 'static, ) -> Self
pub fn new_async( function: impl Fn(Vec<ApplyArgument>, &Runtime) -> Pin<Box<dyn Future<Output = Result<(Option<ValueContainer>, Vec<ValueContainer>), CallableError>> + 'static>> + 'static, ) -> Self
Trait Implementations§
Source§impl Apply for NativeCallable
impl Apply for NativeCallable
Source§fn try_apply_sync(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
fn try_apply_sync( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Applies multiple ValueContainer arguments to self
Returns an Error if the value does not support sync apply.
The return value is a tuple of the return value of the apply operation,
and a vector containing all value containers for apply arguments that were passed as local references.
Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§async fn try_apply_async(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
async fn try_apply_async( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Applies multiple ValueContainer arguments to self on a sync or async callable.
The return value is a tuple of the return value of the apply operation,
and a vector containing all value containers for apply arguments that were passed as local references.
Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§fn try_apply_sync_checked(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
fn try_apply_sync_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Calls the [try_apply_sync] method and checks that the number of returned local references
matches the number of arguments that were passed as local references.
Source§async fn try_apply_async_checked(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
async fn try_apply_async_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Calls the [try_apply_async] method and checks that the number of returned local references
matches the number of arguments that were passed as local references.
Source§impl Clone for NativeCallable
impl Clone for NativeCallable
Source§impl Debug for NativeCallable
impl Debug for NativeCallable
impl Eq for NativeCallable
Source§impl Hash for NativeCallable
impl Hash for NativeCallable
Auto Trait Implementations§
impl !RefUnwindSafe for NativeCallable
impl !Send for NativeCallable
impl !Sync for NativeCallable
impl !UnwindSafe for NativeCallable
impl Forget for NativeCallable
impl Freeze for NativeCallable
impl Move for NativeCallable
impl Unpin for NativeCallable
impl UnsafeUnpin for NativeCallable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> ⓘ
Converts
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> ⓘ
Converts
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 moreSource§impl<T, U> TypeSubset<U> for Twhere
U: TypeSuperset<T>,
impl<T, U> TypeSubset<U> for Twhere
U: TypeSuperset<T>,
Source§fn is_subset_of(&self, other: &U) -> bool
fn is_subset_of(&self, other: &U) -> bool
Returns whether self is a subset of type