Struct rustler::NifEnv
[−]
[src]
pub struct NifEnv<'a> { /* fields omitted */ }
On each NIF call, a NifEnv is passed in. The NifEnv is used for most operations that involve communicating with the BEAM, like decoding and encoding terms.
There is no way to allocate a NifEnv at the moment, but this may be possible in the future.
Methods
impl<'a> NifEnv<'a>
[src]
fn pid(self) -> NifPid
[src]
Return the calling process's pid.
Panics
Panics if this environment is process-independent. (The only way to get such an
environment is to use OwnedEnv
. The NifEnv
that Rustler passes to NIFs when they're
called is always associated with the calling Erlang process.)
impl<'a> NifEnv<'a>
[src]
fn send(self, pid: &NifPid, message: NifTerm<'a>)
[src]
Send a message to a process.
The Erlang VM imposes some odd restrictions on sending messages. You can send messages in either of these situations:
The current thread is managed by the Erlang VM, and
self
is the environment of the calling process (that is, the environment that Rustler passed in to your NIF); orThe current thread is not managed by the Erlang VM.
Panics
Panics if the above rules are broken (by trying to send a message from
an OwnedEnv
on a thread that's managed by the Erlang VM).
fn binary_to_term(self, data: &[u8]) -> Option<(NifTerm<'a>, usize)>
[src]
Decodes binary data to a term.
Follows the erlang External Term Format.
unsafe fn binary_to_term_trusted(
self,
data: &[u8]
) -> Option<(NifTerm<'a>, usize)>
[src]
self,
data: &[u8]
) -> Option<(NifTerm<'a>, usize)>
Like binary_to_term
, but can only be called on valid
and trusted data.
impl<'a> NifEnv<'a>
[src]
fn as_c_arg(&self) -> NIF_ENV
[src]
fn error_tuple<T>(self, reason: T) -> NifTerm<'a> where
T: NifEncoder,
[src]
T: NifEncoder,
Convenience method for building a tuple {error, Reason}
.
Trait Implementations
impl<'a> Clone for NifEnv<'a>
[src]
fn clone(&self) -> NifEnv<'a>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Copy for NifEnv<'a>
[src]
impl<'a, 'b> PartialEq<NifEnv<'b>> for NifEnv<'a>
[src]
Two environments are equal if they're the same NIF_ENV
value.
A NifEnv<'a>
is equal to a NifEnv<'b>
iff 'a
and 'b
are the same lifetime.