pub struct Thread { /* private fields */ }Expand description
A handle to a Lua thread (coroutine). Mirrors mlua::Thread.
Under the send feature it is Send but never Sync — see
[crate::sync::NotSync].
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn state(&self) -> *mut lua_State
pub fn state(&self) -> *mut lua_State
The raw coroutine state pointer. Mirrors mlua::Thread::state.
Sourcepub fn resume<R: FromLuaMulti>(&self, args: impl IntoLuaMulti) -> Result<R>
pub fn resume<R: FromLuaMulti>(&self, args: impl IntoLuaMulti) -> Result<R>
Resume the coroutine, passing args and converting its yielded/returned
values to R. Mirrors mlua::Thread::resume.
Returns Error::CoroutineUnresumable if the thread has finished,
errored, or is otherwise not resumable.
Sourcepub fn resume_error<R: FromLuaMulti>(&self, error: impl IntoLua) -> Result<R>
pub fn resume_error<R: FromLuaMulti>(&self, error: impl IntoLua) -> Result<R>
Resume the coroutine, immediately raising error inside it.
Mirrors mlua::Thread::resume_error (a Luau extension).
Sourcepub fn status(&self) -> ThreadStatus
pub fn status(&self) -> ThreadStatus
The thread’s status. Mirrors mlua::Thread::status.
Sourcepub fn is_resumable(&self) -> bool
pub fn is_resumable(&self) -> bool
Whether the thread can be resumed. Mirrors mlua::Thread::is_resumable.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the thread is currently running. Mirrors mlua::Thread::is_running.
Sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
Whether the thread is active but not running. Mirrors
mlua::Thread::is_normal.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the thread has finished executing. Mirrors
mlua::Thread::is_finished.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Whether the thread raised an error. Mirrors mlua::Thread::is_error.
Sourcepub fn reset(&self, func: Function) -> Result<()>
pub fn reset(&self, func: Function) -> Result<()>
Reset the thread to a fresh state and install func as its body.
Mirrors mlua::Thread::reset (Luau semantics: any non-running thread can
be reset).
Sourcepub fn to_pointer(&self) -> *const c_void
pub fn to_pointer(&self) -> *const c_void
A raw pointer identifying this thread. Mirrors mlua::Thread::to_pointer.
Trait Implementations§
Source§impl FromLua for Thread
impl FromLua for Thread
Source§fn from_lua_arg(
arg: Value,
_i: usize,
_to: Option<&str>,
lua: &Lua,
) -> Result<Self>
fn from_lua_arg( arg: Value, _i: usize, _to: Option<&str>, lua: &Lua, ) -> Result<Self>
i. The default forwards to
FromLua::from_lua; specific impls can produce nicer messages.
Mirrors mlua::FromLua::from_lua_arg.