[−][src]Trait emacs::Transfer
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.
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".