Skip to main content

AnyTerm

Struct AnyTerm 

Source
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>

Source

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.

Source§

impl<'id> AnyTerm<'id>

Source

pub fn wrap(raw_term: Term, _env: impl Env<'id>) -> Self

Available on crate feature raw only.

Trait Implementations§

Source§

impl<'id> Clone for AnyTerm<'id>

Source§

fn clone(&self) -> AnyTerm<'id>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'id> Copy for AnyTerm<'id>

Source§

impl<'id> Decoder<'id> for AnyTerm<'id>

The identity decode — any term decodes to itself.

Source§

fn decode(term: AnyTerm<'id>, _env: impl Env<'id>) -> Result<Self, CodecError>

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.

Source§

fn encode(&self, env: impl Env<'id>) -> Result<AnyTerm<'id>, CodecError>

Source§

impl<'id> Term<'id> for AnyTerm<'id>

Source§

fn raw_term(self) -> Term

The raw machine word backing this term.
Source§

fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>
where Self: Sized,

Copy this term into another environment (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).

Auto Trait Implementations§

§

impl<'id> !Send for AnyTerm<'id>

§

impl<'id> !Sync for AnyTerm<'id>

§

impl<'id> Freeze for AnyTerm<'id>

§

impl<'id> RefUnwindSafe for AnyTerm<'id>

§

impl<'id> Unpin for AnyTerm<'id>

§

impl<'id> UnsafeUnpin for AnyTerm<'id>

§

impl<'id> UnwindSafe for AnyTerm<'id>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.