use crate::error::IsleError;
use crate::runtime::{self, Vm};
use mlua::debug::Debug;
use mlua::{HookTriggers, Lua, VmState};
#[deprecated(since = "0.8.0", note = "use `mlua_isle::runtime::HookId`")]
pub type HookId = runtime::HookId;
#[deprecated(since = "0.8.0", note = "use `mlua_isle::runtime::Config`")]
pub type CancelConfig = runtime::Config;
#[deprecated(
since = "0.8.0",
note = "use `mlua_isle::runtime::Vm::attach(lua, config)`"
)]
pub fn install(lua: &Lua) -> Result<(), IsleError> {
Vm::attach(lua, crate::hub::config(lua)).map(drop)
}
#[deprecated(since = "0.8.0", note = "use `mlua_isle::runtime::Vm::add_hook`")]
pub fn add_hook<F>(
lua: &Lua,
triggers: HookTriggers,
callback: F,
) -> Result<runtime::HookId, IsleError>
where
F: Fn(&Lua, &Debug) -> mlua::Result<VmState> + 'static,
{
runtime::of_or_attach(lua)?;
crate::hub::add_hook(lua, triggers, callback)
}
#[deprecated(since = "0.8.0", note = "use `mlua_isle::runtime::Vm::remove_hook`")]
pub fn remove_hook(lua: &Lua, id: runtime::HookId) -> Result<bool, IsleError> {
crate::hub::remove_hook(lua, id)
}
#[deprecated(
since = "0.8.0",
note = "use `mlua_isle::runtime::Vm::set_config` (or pass the config to `Vm::attach`)"
)]
pub fn configure(lua: &Lua, config: runtime::Config) {
match Vm::of(lua) {
Some(vm) => vm.set_config(config),
None => crate::hub::set_config(lua, config),
}
}
#[deprecated(since = "0.8.0", note = "use `mlua_isle::runtime::Vm::config`")]
pub fn config(lua: &Lua) -> runtime::Config {
match Vm::of(lua) {
Some(vm) => vm.config(),
None => crate::hub::config(lua),
}
}