Struct rlua::Scope[][src]

pub struct Scope<'lua, 'scope> { /* fields omitted */ }
Expand description

Constructed by the Context::scope method, allows temporarily creating Lua userdata and callbacks that are not required to be Send or ’static.

See Context::scope for more details.

Implementations

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

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

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

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

Create a Lua userdata object from a custom userdata type.

This is a version of Context::create_userdata that creates a userdata which expires on scope drop, and does not require that the userdata type be Send (but still requires that the UserData be ’static). See Context::scope for more details.

Create a Lua userdata object from a custom userdata type.

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

Lifting the requirement that the UserData type be ’static comes with some important limitations, so if you only need to eliminate the Send requirement, it is probably better to use Scope::create_static_userdata instead.

The main limitation that comes from using non-’static userdata is that the produced userdata will no longer have a TypeId associated with it, becuase TypeId can only work for ’static types. This means that it is impossible, once the userdata is created, to get a reference to it back out of an AnyUserData handle. This also implies that the “function” type methods that can be added via UserDataMethods (the ones that accept AnyUserData as a first parameter) are vastly less useful. Also, there is no way to re-use a single metatable for multiple non-’static types, so there is a higher cost associated with creating the userdata metatable each time a new userdata is created.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.