Struct rlua::Scope[][src]

pub struct Scope<'scope> { /* fields omitted */ }

Constructed by the Lua::scope method, allows temporarily passing to Lua userdata that is !Send, and callbacks that are !Send and not 'static.

See Lua::scope for more details.

Methods

impl<'scope> Scope<'scope>
[src]

Wraps a Rust function or closure, creating a callable Lua function handle to it.

This is a version of Lua::create_function that creates a callback which expires on scope drop. See Lua::scope for more details.

Since the provided function does not have to be 'static, it is easy to capture outer variables in the provided callback. However, you must not use Lua handle values (Table, Function etc) or a Lua instance that you have captured from an outer level inside such a callback. It is always a logic error to access a Lua instance or handle value from an "outer" callback level inside an "inner" callback level, Lua does stack protection during callbacks that makes the outer instances unusable until the callback returns. This is true regardless of the use of Lua::scope, but it is very difficult (though not impossible!) to run into unless you can create callbacks that are non-'static.

If you do access outer Lua instances or handles inside an inner callback, this will result in a panic. You can instead use either RegistryKey values or Function::bind to pass values to callbacks without error.

Wraps a Rust mutable closure, creating a callable Lua function handle to it.

This is a version of Lua::create_function_mut that creates a callback which expires on scope drop. See Lua::scope and Scope::create_function for more details.

Create a Lua userdata object from a custom userdata type.

This is a version of Lua::create_userdata that creates a userdata which expires on scope drop, and does not require that the userdata type be Send. See Lua::scope for more details.

Trait Implementations

impl<'scope> Drop for Scope<'scope>
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'scope> !Send for Scope<'scope>

impl<'scope> !Sync for Scope<'scope>