Struct hlua_badtouch::LuaCodeFromReader
[−]
[src]
pub struct LuaCodeFromReader<R>(pub R);
Wrapper around a Read
object. When pushed, the content will be parsed as Lua code and turned
into a function.
Since pushing this value can fail in case of a reading error or a parsing error, you must use
the checked_set
method instead of set
.
Example: returning a Lua function from a Rust function
use std::io::Cursor; let mut lua = hlua::Lua::new(); lua.set("call_rust", hlua::function0(|| -> hlua::LuaCodeFromReader<Cursor<String>> { let lua_code = "return 18;"; return hlua::LuaCodeFromReader(Cursor::new(lua_code.to_owned())); })); let r: i32 = lua.execute("local lua_func = call_rust(); return lua_func();").unwrap(); assert_eq!(r, 18);
Trait Implementations
impl<R: Debug> Debug for LuaCodeFromReader<R>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'lua, L, R> Push<L> for LuaCodeFromReader<R> where
L: AsMutLua<'lua>,
R: Read,
[src]
L: AsMutLua<'lua>,
R: Read,
type Err = LuaError
Error that can happen when pushing a value.
fn push_to_lua(self, lua: L) -> Result<PushGuard<L>, (LuaError, L)>
[src]
Pushes the value on the top of the stack. Read more
fn push_no_err<E>(self, lua: L) -> PushGuard<L> where
Self: Sized,
Self: Push<L, Err = E>,
E: Into<Void>,
[src]
Self: Sized,
Self: Push<L, Err = E>,
E: Into<Void>,
Same as push_to_lua
but can only succeed and is only available if Err
is Void
.
impl<'lua, L, R> PushOne<L> for LuaCodeFromReader<R> where
L: AsMutLua<'lua>,
R: Read,
[src]
L: AsMutLua<'lua>,
R: Read,
Auto Trait Implementations
impl<R> Send for LuaCodeFromReader<R> where
R: Send,
R: Send,
impl<R> Sync for LuaCodeFromReader<R> where
R: Sync,
R: Sync,