pub struct CallEnv<'id> { /* private fields */ }Expand description
The process-bound environment handed to a NIF call.
Implementations§
Source§impl<'id> CallEnv<'id>
impl<'id> CallEnv<'id>
Sourcepub fn cpu_time(self) -> Result<Tuple<'id>, Raised<'id>>
pub fn cpu_time(self) -> Result<Tuple<'id>, Raised<'id>>
The current logical CPU’s execution time in erlang:timestamp/0 format
(enif_cpu_time). Err(Raised) (badarg) if the OS does not support it.
Sourcepub unsafe fn schedule_nif(
self,
fun_name: &CStr,
flags: i32,
fp: unsafe extern "C" fn(*mut Env, c_int, *const Term) -> Term,
argc: i32,
argv: *const Term,
) -> Result<AnyTerm<'id>, Raised<'id>>
pub unsafe fn schedule_nif( self, fun_name: &CStr, flags: i32, fp: unsafe extern "C" fn(*mut Env, c_int, *const Term) -> Term, argc: i32, argv: *const Term, ) -> Result<AnyTerm<'id>, Raised<'id>>
Reschedule the current NIF to run fp (enif_schedule_nif). The success
value must be returned directly from the NIF; a bad fun_name raises
badarg, surfaced as Err(Raised).
§Safety
fp must be a valid NIF function pointer; argv must point to argc
valid terms.
Source§impl<'id> CallEnv<'id>
impl<'id> CallEnv<'id>
Sourcepub fn raise<T>(self, reason: impl Term<'id>) -> Result<T, Raised<'id>>
pub fn raise<T>(self, reason: impl Term<'id>) -> Result<T, Raised<'id>>
Raise an exception with reason (enif_raise_exception). Always Err,
generic over the success type so it fits any position:
return env.raise(reason).
Trait Implementations§
impl<'id> CallingEnv<'id> for CallEnv<'id>
impl<'id> Copy for CallEnv<'id>
Source§impl<'id> Env<'id> for CallEnv<'id>
impl<'id> Env<'id> for CallEnv<'id>
Source§fn as_any_env(self) -> AnyEnv<'id>
fn as_any_env(self) -> AnyEnv<'id>
The kind-erased handle terms are built against. Every env kind downcasts
to the same
AnyEnv for a given brand.Source§fn term_type(self, term: impl Term<'id>) -> Option<TermType>
fn term_type(self, term: impl Term<'id>) -> Option<TermType>
The dynamic type of
term (enif_term_type). None for a type code
this otter build does not recognize (a newer-OTP type).Source§fn hash(self, algorithm: Hash, term: impl Term<'id>, salt: u64) -> u64
fn hash(self, algorithm: Hash, term: impl Term<'id>, salt: u64) -> u64
Hash a term (
enif_hash). algorithm is Phash2 (portable) or
InternalHash (node-local, faster).Source§fn consume_timeslice(self, percent: i32) -> bool
fn consume_timeslice(self, percent: i32) -> bool
Tell the scheduler how much of the timeslice this NIF used
(
enif_consume_timeslice). true if the timeslice is exhausted.Source§fn is_current_process_alive(self) -> bool
fn is_current_process_alive(self) -> bool
Whether the calling process is still alive
(
enif_is_current_process_alive).Source§fn make_unique_integer(self, properties: UniqueInteger) -> Integer<'id>
fn make_unique_integer(self, properties: UniqueInteger) -> Integer<'id>
Create a unique integer (
enif_make_unique_integer). properties is a
bitmask of UniqueInteger::POSITIVE / MONOTONIC.Auto Trait Implementations§
impl<'id> !Send for CallEnv<'id>
impl<'id> !Sync for CallEnv<'id>
impl<'id> Freeze for CallEnv<'id>
impl<'id> RefUnwindSafe for CallEnv<'id>
impl<'id> Unpin for CallEnv<'id>
impl<'id> UnsafeUnpin for CallEnv<'id>
impl<'id> UnwindSafe for CallEnv<'id>
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