Struct janetrs::JanetFunction
source · pub struct JanetFunction<'data> { /* private fields */ }
Expand description
A representation of a Janet function defined at the Janet side.
Implementations§
source§impl<'data> JanetFunction<'data>
impl<'data> JanetFunction<'data>
sourcepub const unsafe fn from_raw(raw: *mut CJanetFunction) -> Self
pub const unsafe fn from_raw(raw: *mut CJanetFunction) -> Self
Create a new JanetFunction
with a raw
pointer.
§Safety
This function do not check if the given raw
is NULL
or not. Use at your
own risk.
sourcepub fn call(
&mut self,
args: impl AsRef<[Janet]>
) -> Result<Janet, CallError<'data>>
pub fn call( &mut self, args: impl AsRef<[Janet]> ) -> Result<Janet, CallError<'data>>
Execute the JanetFunction
with the given arguments.
This function may trigger a GC collection.
If the executions was successful returns the output, otherwise return the
CallError
with information returned by the call.
sourcepub fn call_with_fiber<'fiber>(
&mut self,
fiber: JanetFiber<'fiber>,
args: impl AsRef<[Janet]>
) -> Result<Janet, CallError<'fiber>>
pub fn call_with_fiber<'fiber>( &mut self, fiber: JanetFiber<'fiber>, args: impl AsRef<[Janet]> ) -> Result<Janet, CallError<'fiber>>
Execute the JanetFunction
with the given arguments wising the given fiber
.
This function may trigger the a GC collection.
If the executions was successful returns the output, otherwise return the
CallError
with information returned by the call.
sourcepub fn call_or_panic(&mut self, args: impl AsRef<[Janet]>) -> Janet
pub fn call_or_panic(&mut self, args: impl AsRef<[Janet]>) -> Janet
Execute the JanetFunction
with the given arguments.
This function can not trigger GC collection.
§Janet Panics
Panics if anything goes wrong trying to call the function.
sourcepub const fn as_raw(&self) -> *const CJanetFunction
pub const fn as_raw(&self) -> *const CJanetFunction
Return a raw pointer to the function raw structure.
The caller must ensure that the function outlives the pointer this function returns, or else it will end up pointing to garbage.
sourcepub fn as_mut_raw(&mut self) -> *mut CJanetFunction
pub fn as_mut_raw(&mut self) -> *mut CJanetFunction
Return a raw mutable pointer to the function raw structure.
The caller must ensure that the function outlives the pointer this function returns, or else it will end up pointing to garbage.
Trait Implementations§
source§impl<'data> Clone for JanetFunction<'data>
impl<'data> Clone for JanetFunction<'data>
source§fn clone(&self) -> JanetFunction<'data>
fn clone(&self) -> JanetFunction<'data>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for JanetFunction<'_>
impl Debug for JanetFunction<'_>
source§impl From<&JanetFunction<'_>> for Janet
impl From<&JanetFunction<'_>> for Janet
source§fn from(val: &JanetFunction<'_>) -> Self
fn from(val: &JanetFunction<'_>) -> Self
source§impl From<JanetFunction<'_>> for Janet
impl From<JanetFunction<'_>> for Janet
source§fn from(val: JanetFunction<'_>) -> Self
fn from(val: JanetFunction<'_>) -> Self
source§impl JanetTypeName for JanetFunction<'_>
impl JanetTypeName for JanetFunction<'_>
source§impl<'data> Ord for JanetFunction<'data>
impl<'data> Ord for JanetFunction<'data>
source§fn cmp(&self, other: &JanetFunction<'data>) -> Ordering
fn cmp(&self, other: &JanetFunction<'data>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'data> PartialEq for JanetFunction<'data>
impl<'data> PartialEq for JanetFunction<'data>
source§fn eq(&self, other: &JanetFunction<'data>) -> bool
fn eq(&self, other: &JanetFunction<'data>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'data> PartialOrd for JanetFunction<'data>
impl<'data> PartialOrd for JanetFunction<'data>
source§fn partial_cmp(&self, other: &JanetFunction<'data>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetFunction<'data>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more