Skip to main content

Lua

Struct Lua 

Source
pub struct Lua<'lua> { /* private fields */ }
Expand description

A Lua state with the standard libraries installed.

The 'lua parameter mirrors hlua’s signature so consumer code that writes Lua<'a> keeps compiling; the shim itself owns its state outright.

Implementations§

Source§

impl<'lua> Lua<'lua>

Source

pub fn new() -> Lua<'lua>

Create a new Lua state with the standard libraries installed. Panics only on allocation failure, matching the effective behaviour of hlua::Lua::new().

Source

pub fn open_string(&mut self)

Open the string library. lua-rs already opens the full standard library at construction, so this is a no-op kept for API compatibility.

Source

pub fn execute<T: FromExec>(&mut self, code: &str) -> Result<T, LuaError>

Load and run a chunk of Lua source.

Source

pub fn set<V: SetValue>(&mut self, name: &str, value: V)

Set a global. Accepts the functionN wrappers from this crate.

Source

pub fn get<'l, V>(&'l mut self, name: &str) -> Option<V>
where V: FromLuaGlobal<'l>,

Read a global by name. The value type is chosen by the caller, e.g. lua.get::<StringInLua<_>, _>("descr").

Trait Implementations§

Source§

impl Default for Lua<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Lua<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'lua> Freeze for Lua<'lua>

§

impl<'lua> !RefUnwindSafe for Lua<'lua>

§

impl<'lua> !Send for Lua<'lua>

§

impl<'lua> !Sync for Lua<'lua>

§

impl<'lua> Unpin for Lua<'lua>

§

impl<'lua> UnsafeUnpin for Lua<'lua>

§

impl<'lua> !UnwindSafe for Lua<'lua>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.