[][src]Trait emacs::Transfer

pub trait Transfer: Sized + 'static {
    fn type_name() -> &'static str;
}

Allowing a type to be exposed to Lisp, where its values appear as opaque objects, or "embedded user pointers" (printed as #<user-ptr ...>).

When a (boxed) value of this type is transferred to Lisp, the GC becomes its owner. Afterwards, module code can only access it through immutable references.

The 'static bound disallows transferring short-lived references, which can become invalid while still being held by the Lisp runtime.

This works, because the returned string is copied into the Lisp runtime.

use emacs::{defun, Result};

#[defun]
fn foo(s: &String) -> Result<&str> {
    Ok(s)
}

This doesn't work, because the function attempts to give the Lisp runtime a temporary reference.

This example deliberately fails to compile
use emacs::{defun, Result};

#[defun(user_ptr)]
fn foo(s: &String) -> Result<&str> {
    Ok(s)
}

Required methods

fn type_name() -> &'static str

Returns the name of this type. This is used to report runtime type error, when a function expects this type, but some Lisp code passes a different type of "user pointer".

Loading content...

Implementations on Foreign Types

impl<T: 'static> Transfer for RefCell<T>[src]

impl<T: 'static> Transfer for Mutex<T>[src]

impl<T: 'static> Transfer for RwLock<T>[src]

impl<T: 'static> Transfer for Rc<T>[src]

impl<T: 'static> Transfer for Arc<T>[src]

Loading content...

Implementors

Loading content...