Initial upgrade to mlua 0.10
This commit is contained in:
parent
d11e79cdfa
commit
ae2c27551f
34
Cargo.lock
generated
34
Cargo.lock
generated
|
@ -930,6 +930,15 @@ dependencies = [
|
|||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
|
@ -990,9 +999,9 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
|||
|
||||
[[package]]
|
||||
name = "lua-src"
|
||||
version = "546.0.2"
|
||||
version = "547.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2da0daa7eee611a4c30c8f5ee31af55266e26e573971ba9336d2993e2da129b2"
|
||||
checksum = "1edaf29e3517b49b8b746701e5648ccb5785cde1c119062cbabbc5d5cd115e42"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
@ -1062,17 +1071,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua"
|
||||
version = "0.9.7"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d9bed6bce296397a9d6a86f995dd10a547a4e6949825d45225906bdcbfe7367"
|
||||
checksum = "0ae9546e4a268c309804e8bbb7526e31cbfdedca7cd60ac1b987d0b212e0d876"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"either",
|
||||
"erased-serde",
|
||||
"futures-util",
|
||||
"mlua-sys",
|
||||
"mlua_derive",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde-value",
|
||||
|
@ -1080,9 +1090,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua-sys"
|
||||
version = "0.5.2"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d16a9ba1dd2c6ac971b204262d434c24d65067038598f0638b64e5dca28d52b8"
|
||||
checksum = "efa6bf1a64f06848749b7e7727417f4ec2121599e2a10ef0a8a3888b0e9a5a0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
|
@ -1093,11 +1103,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mlua_derive"
|
||||
version = "0.9.2"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aaade5f94e5829db58791664ba98f35fea6a3ffebc783becb51dc97c7a21abee"
|
||||
checksum = "2cfc5faa2e0d044b3f5f0879be2920e0a711c97744c42cf1c295cb183668933e"
|
||||
dependencies = [
|
||||
"itertools 0.12.1",
|
||||
"itertools 0.13.0",
|
||||
"once_cell",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
|
@ -1523,9 +1533,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
|
|||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
|
|
|
@ -4,7 +4,12 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
members = ["automation_macro", "automation_cast", "google_home/google_home", "google_home/google_home_macro"]
|
||||
members = [
|
||||
"automation_macro",
|
||||
"automation_cast",
|
||||
"google_home/google_home",
|
||||
"google_home/google_home_macro",
|
||||
]
|
||||
|
||||
|
||||
[dependencies]
|
||||
|
@ -43,7 +48,7 @@ enum_dispatch = "0.3.12"
|
|||
indexmap = { version = "2.0.0", features = ["serde"] }
|
||||
serde_yaml = "0.9.27"
|
||||
tokio-cron-scheduler = "0.9.4"
|
||||
mlua = { version = "0.9.7", features = [
|
||||
mlua = { version = "0.10.1", features = [
|
||||
"lua54",
|
||||
"vendored",
|
||||
"macros",
|
||||
|
|
|
@ -261,8 +261,8 @@ pub fn impl_lua_device_config_macro(ast: &DeriveInput) -> TokenStream {
|
|||
.collect();
|
||||
|
||||
let impl_from_lua = quote! {
|
||||
impl<'lua> mlua::FromLua<'lua> for #name {
|
||||
fn from_lua(value: mlua::Value<'lua>, lua: &'lua mlua::Lua) -> mlua::Result<Self> {
|
||||
impl mlua::FromLua for #name {
|
||||
fn from_lua(value: mlua::Value, lua: &mlua::Lua) -> mlua::Result<Self> {
|
||||
if !value.is_table() {
|
||||
panic!("Expected table");
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ fn run_schedule(
|
|||
pool.spawn_pinned(move || async move {
|
||||
let lua = LUA.lock().await;
|
||||
let f: mlua::Function = lua.named_registry_value(uuid.to_string().as_str()).unwrap();
|
||||
f.call_async::<_, ()>(()).await.unwrap();
|
||||
f.call_async::<()>(()).await.unwrap();
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -160,7 +160,7 @@ fn run_schedule(
|
|||
}
|
||||
|
||||
impl mlua::UserData for DeviceManager {
|
||||
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_async_method("add", |_lua, this, device: Box<dyn Device>| async move {
|
||||
this.add(device).await;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use async_trait::async_trait;
|
|||
use automation_cast::Cast;
|
||||
use dyn_clone::DynClone;
|
||||
use google_home::traits::OnOff;
|
||||
use mlua::AnyUserDataExt;
|
||||
use mlua::ObjectLike;
|
||||
|
||||
pub use self::air_filter::AirFilter;
|
||||
pub use self::audio_setup::AudioSetup;
|
||||
|
@ -56,7 +56,7 @@ macro_rules! register_device {
|
|||
macro_rules! impl_device {
|
||||
($device:ty) => {
|
||||
impl mlua::UserData for $device {
|
||||
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_async_function("new", |_lua, config| async {
|
||||
let device: $device = crate::devices::LuaDeviceCreate::create(config)
|
||||
.await
|
||||
|
@ -70,7 +70,7 @@ macro_rules! impl_device {
|
|||
Ok(b)
|
||||
});
|
||||
|
||||
methods.add_async_method("get_id", |_lua, this, _: ()| async { Ok(this.get_id()) });
|
||||
methods.add_async_method("get_id", |_lua, this, _: ()| async move { Ok(this.get_id()) });
|
||||
|
||||
if impls::impls!($device: OnOff) {
|
||||
methods.add_async_method("set_on", |_lua, this, on: bool| async move {
|
||||
|
@ -145,14 +145,14 @@ pub trait Device:
|
|||
fn get_id(&self) -> String;
|
||||
}
|
||||
|
||||
impl<'lua> mlua::FromLua<'lua> for Box<dyn Device> {
|
||||
fn from_lua(value: mlua::Value<'lua>, _lua: &'lua mlua::Lua) -> mlua::Result<Self> {
|
||||
impl mlua::FromLua for Box<dyn Device> {
|
||||
fn from_lua(value: mlua::Value, _lua: &mlua::Lua) -> mlua::Result<Self> {
|
||||
match value {
|
||||
mlua::Value::UserData(ud) => {
|
||||
let ud = if ud.is::<Box<dyn Device>>() {
|
||||
ud
|
||||
} else {
|
||||
ud.call_method::<_, mlua::AnyUserData>("__box", ())?
|
||||
ud.call_method::<_>("__box", ())?
|
||||
};
|
||||
|
||||
let b = ud.borrow::<Self>()?.clone();
|
||||
|
|
Loading…
Reference in New Issue
Block a user