Skip to main content

Hook

Type Alias Hook 

Source
pub type Hook = extern "C-unwind" fn(lua: LuaState, info: &mut DebugInfo);
Expand description

Debugging function that is called by specified HookEvents.

See LuaState::set_hook for more information on how to enable an Hook. There can only be one Hook enabled at a time.

When called, info can be used to retrieve the HookEvent that called the hook (see DebugInfo::event).

If HookEvent::Line is the event that called the Hook, DebugInfo::current_line will also be set.

To get more information about the function that was running at the time, LuaState::get_info can be called using info without needing to specify a function using LuaState::get_stack.

While the current Hook is running, it cannot be called again. Which means it is possible to call other functions from within the hook itself without issues.

Just like CFunction, this type is technically a subset of lua_Hook, as it only allows safe functions. Different methods will use either lua_Hook or Hook based on if they work with only safe functions or not.

Trait Implementations§

Source§

impl SafeFn for Hook

Source§

type RawFn = unsafe extern "C-unwind" fn(*mut lua_State, *mut lua_Debug)

The raw version of this function type.
Source§

unsafe fn from_raw(raw: lua_Hook) -> Self

Converts the given raw function into their safe version. Read more
Source§

fn to_raw(self) -> lua_Hook

Converts this function into their raw version. Read more