[−][src]Struct emacs::GlobalRef
A "global reference" that can live outside the scope of an Env
. This is useful for sharing
an otherwise short-lived Lisp Value
across multiple invocations of Rust functions defined
with defun
. Examples include efficient access to interned symbols or Lisp functions, and
Rust-based multi-threading.
Implementation
Cloning this struct requires an Env
, so it doesn't implement Clone
.
free_global_ref
requires an Env
. Therefore, to avoid leaking the underlying Value
,
free
should be used to free a global reference, instead of drop
. For the use case of
accessing interned symbols and Lisp functions, this is a non-issue, as the values are
supposed to be "static" anyway.
The above is a shortcoming in the design of emacs-module. There are 2 possible ways to fix it:
- Make
free_global_ref
work without an env, like Erlang'senif_release_resource
. - Allow
user_ptr
's finalizer to access the env, to properly free associated global refs.
Implementations
impl GlobalRef
[src]
pub fn call<'e, A>(&'e self, env: &'e Env, args: A) -> Result<Value<'_>> where
A: IntoLispArgs<'e>,
[src]
A: IntoLispArgs<'e>,
Calls this reference's value with the given arguments. An error is signaled if it is actually not a Lisp's callable.
args
should be an array/slice of Value
, or a tuple of different types, each implementing
IntoLisp
.
pub unsafe fn call_unprotected<'e, A>(
&'e self,
env: &'e Env,
args: A
) -> Result<Value<'_>> where
A: IntoLispArgs<'e>,
[src]
&'e self,
env: &'e Env,
args: A
) -> Result<Value<'_>> where
A: IntoLispArgs<'e>,
impl GlobalRef
[src]
pub fn new(value: Value<'_>) -> Self
[src]
Creates a new global reference for the given Value
.
pub fn free(self, env: &Env) -> Result<()>
[src]
Frees this global reference.
pub fn bind<'e, 'g: 'e>(&'g self, env: &'e Env) -> Value<'e>
[src]
pub fn clone(&self, env: &Env) -> Self
[src]
Returns a copy of this global reference.
Trait Implementations
impl Debug for GlobalRef
[src]
impl<'e> FromLisp<'e> for GlobalRef
[src]
impl<'e> IntoLisp<'e> for &'e GlobalRef
[src]
impl Send for GlobalRef
[src]
impl Sync for GlobalRef
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,