pub struct LuaHook { /* private fields */ }Expand description
A hook backed by a Lua function.
The handler function is stored in Lua’s registry via mlua::RegistryKey.
A cloned Lua handle provides thread-safe access to the same Lua state
(mlua uses internal locking with the send feature).
Thread-safety: Mutex<Lua> is Send + Sync because Lua: Send.
Implementations§
Source§impl LuaHook
impl LuaHook
Sourcepub fn new(
id: String,
fql: FqlPattern,
point: HookPoint,
priority: i32,
lua: &Lua,
func: &Function,
) -> Result<Self, Error>
pub fn new( id: String, fql: FqlPattern, point: HookPoint, priority: i32, lua: &Lua, func: &Function, ) -> Result<Self, Error>
Creates a new LuaHook.
Stores func in Lua’s registry and clones the Lua handle
for later invocation from any thread.
§Errors
Returns an error if the function cannot be stored in the registry.
Trait Implementations§
Source§impl Hook for LuaHook
impl Hook for LuaHook
Source§fn fql_pattern(&self) -> &FqlPattern
fn fql_pattern(&self) -> &FqlPattern
FQL pattern this hook matches.
Source§fn hook_point(&self) -> HookPoint
fn hook_point(&self) -> HookPoint
Which lifecycle point this hook fires on.
Source§fn execute(&self, ctx: HookContext) -> HookAction
fn execute(&self, ctx: HookContext) -> HookAction
Execute the hook with the given context. Read more
Auto Trait Implementations§
impl !Freeze for LuaHook
impl !RefUnwindSafe for LuaHook
impl Send for LuaHook
impl Sync for LuaHook
impl Unpin for LuaHook
impl UnsafeUnpin for LuaHook
impl !UnwindSafe for LuaHook
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more