Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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§