pub struct AnyTerm<'id> { /* private fields */ }Expand description
The bare term word, carrying only the brand 'id — the env is not stored.
The fastest term representation: no enif_term_type call has been made and no
data has been read off the BEAM heap. Resolve it to a known type with
resolve(env) (yielding a TypedTerm), or decode it directly.
#[repr(transparent)] over the raw word (the brand is a ZST), so a
&[RawTerm] can be viewed in place as &[AnyTerm<'id>] (used by
TupleView).
Implementations§
Source§impl<'id> AnyTerm<'id>
impl<'id> AnyTerm<'id>
Sourcepub fn resolve(self, env: impl Env<'id>) -> Option<TypedTerm<'id>>
pub fn resolve(self, env: impl Env<'id>) -> Option<TypedTerm<'id>>
Resolve to a typed TypedTerm (enif_term_type). Exactly one NIF call.
None for a type code this otter build does not recognize (a newer-OTP
type); the original AnyTerm is still usable.
The fallible counterpart is the Decoder impl
for TypedTerm, which maps the None case to
CodecError::UnknownTermType.
Trait Implementations§
impl<'id> Copy for AnyTerm<'id>
Source§impl<'id> Encoder<'id> for AnyTerm<'id>
Encodes for free by rewrapping the term’s own machine word — an otter
term is already an Erlang term. Never fails.
impl<'id> Encoder<'id> for AnyTerm<'id>
Encodes for free by rewrapping the term’s own machine word — an otter term is already an Erlang term. Never fails.
Source§impl<'id> Term<'id> for AnyTerm<'id>
impl<'id> Term<'id> for AnyTerm<'id>
Source§fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>where
Self: Sized,
fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>where
Self: Sized,
enif_make_copy), producing a
term branded to the destination. The general cross-env copy — distinct
from same-brand Encoder (which wraps for free)
and from OwnedEnvArena copy_out (the arena exit).