Trait mlua_extras::extras::LuaExtras

source ·
pub trait LuaExtras {
Show 17 methods // Required methods fn path(&self) -> Result<String>; fn cpath(&self) -> Result<String>; fn prepend_path<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn prepend_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn append_path<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn append_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn set_path<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn set_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn prepend_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn prepend_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn append_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn append_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn set_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>; fn set_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>; fn set_global<'lua, K, V>(&'lua self, key: K, value: V) -> Result<()> where K: IntoLua<'lua>, V: IntoLua<'lua>; fn set_global_function<'lua, K, A, R, F>( &'lua self, key: K, value: F, ) -> Result<()> where K: IntoLua<'lua>, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>, F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static; fn require<'lua, R: FromLua<'lua>>( &'lua self, path: impl AsRef<str>, ) -> Result<R>;
}
Expand description

Adds quality of life helper methods to the Lua type

Helpers:

  • path and cpath manipulation
  • Shorthand for lua.globals().set that include adding any value and adding rust functions skipping create_function
  • A require method that is similar to the Require traits. Allows for lua style require

Required Methods§

source

fn path(&self) -> Result<String>

Get the package.path value

This is the value used by the lua engine to resolve require calls on lua files. see:

source

fn cpath(&self) -> Result<String>

Get the package.cpath value

This is the value used by the lua engine to resolve require calls on lib files. see:

source

fn prepend_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

Prepend a path tothe package.path value

This is the value used by the lua engine to resolve require calls. see:

source

fn prepend_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Prepend paths to the package.path value

This is the value used by the lua engine to resolve require calls. see:

source

fn append_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

Append a path tothe package.path value

This is the value used by the lua engine to resolve require calls. see:

source

fn append_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Append paths to the package.path value

This is the value used by the lua engine to resolve require calls. see:

source

fn set_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

Set the package.path value

This is the value used by the lua engine to resolve require calls. see:

source

fn set_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Set the package.path values

This is the value used by the lua engine to resolve require calls. see:

source

fn prepend_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

Prepend a path tothe package.cpath value

This is the value used by the lua engine to resolve require calls. see:

source

fn prepend_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Prepend paths to the package.cpath value

This is the value used by the lua engine to resolve require calls. see:

source

fn append_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

Append a path to the package.cpath value

This is the value used by the lua engine to resolve require calls. see:

source

fn append_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Append paths to the package.cpath value

This is the value used by the lua engine to resolve require calls. see:

source

fn set_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

Set the package.cpath value

This is the value used by the lua engine to resolve require calls. see:

source

fn set_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

Set the package.cpath values

This is the value used by the lua engine to resolve require calls. see:

source

fn set_global<'lua, K, V>(&'lua self, key: K, value: V) -> Result<()>
where K: IntoLua<'lua>, V: IntoLua<'lua>,

Set a global variable

source

fn set_global_function<'lua, K, A, R, F>( &'lua self, key: K, value: F, ) -> Result<()>
where K: IntoLua<'lua>, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>, F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,

source

fn require<'lua, R: FromLua<'lua>>( &'lua self, path: impl AsRef<str>, ) -> Result<R>

Fetch a nested lua value starting from lua’s globals

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl LuaExtras for Lua

source§

fn set_global<'lua, K, V>(&'lua self, key: K, value: V) -> Result<()>
where K: IntoLua<'lua>, V: IntoLua<'lua>,

source§

fn set_global_function<'lua, K, A, R, F>( &'lua self, key: K, value: F, ) -> Result<()>
where K: IntoLua<'lua>, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>, F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,

source§

fn path(&self) -> Result<String>

source§

fn cpath(&self) -> Result<String>

source§

fn set_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn set_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn prepend_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn prepend_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn append_path<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn append_paths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn set_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn set_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn prepend_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn prepend_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn append_cpath<S: AsRef<Path>>(&self, path: S) -> Result<()>

source§

fn append_cpaths<S: AsRef<Path>>( &self, paths: impl IntoIterator<Item = S>, ) -> Result<()>

source§

fn require<'lua, R: FromLua<'lua>>( &'lua self, path: impl AsRef<str>, ) -> Result<R>

Implementors§