diff --git a/Cargo.lock b/Cargo.lock index a03d6d29..d0aed2e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1247,6 +1247,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" @@ -1394,18 +1403,18 @@ dependencies = [ [[package]] name = "lua-src" -version = "547.0.0" +version = "548.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edaf29e3517b49b8b746701e5648ccb5785cde1c119062cbabbc5d5cd115e42" +checksum = "00bc4bd1f1d5c65b30717333cbec4fa7aa378978940a1bca62f404498d423233" dependencies = [ "cc", ] [[package]] name = "luajit-src" -version = "210.5.12+a4f56a4" +version = "210.6.1+f9140a6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a8e7962a5368d5f264d045a5a255e90f9aa3fc1941ae15a8d2940d42cac671" +checksum = "813bd31f2759443affa687c0d9c5eb5cf6cb0e898810ab197408431d746054bf" dependencies = [ "cc", "which", @@ -1474,9 +1483,9 @@ dependencies = [ [[package]] name = "mlua" -version = "0.10.5" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1f5f8fbebc7db5f671671134b9321c4b9aa9adeafccfd9a8c020ae45c6a35d0" +checksum = "de25fc513588ac1273aa8c6dc0fffee6d32c12f38dc75f5cdc74547121a107ef" dependencies = [ "anyhow", "bstr", @@ -1495,9 +1504,9 @@ dependencies = [ [[package]] name = "mlua-sys" -version = "0.6.8" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380c1f7e2099cafcf40e51d3a9f20a346977587aa4d012eae1f043149a728a93" +checksum = "bcdf7c9e260ca82aaa32ac11148941952b856bb8c69aa5a9e65962f21fcb8637" dependencies = [ "cc", "cfg-if", @@ -1508,11 +1517,11 @@ dependencies = [ [[package]] name = "mlua_derive" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870d71c172fcf491c6b5fb4c04160619a2ee3e5a42a1402269c66bcbf1dd4deb" +checksum = "465bddde514c4eb3b50b543250e97c1d4b284fa3ef7dc0ba2992c77545dbceb2" dependencies = [ - "itertools 0.13.0", + "itertools 0.14.0", "once_cell", "proc-macro-error2", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 89b3e83d..65f26de8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ globset = "0.4.16" indexmap = { version = "2.10.0", features = [ "serde" ] } libc = "0.2.174" lru = "0.16.0" -mlua = { version = "0.10.5", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serialize" ] } +mlua = { version = "0.11.1", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serde" ] } objc = "0.2.7" ordered-float = { version = "5.0.0", features = [ "serde" ] } parking_lot = "0.12.4" diff --git a/yazi-binding/src/elements/bar.rs b/yazi-binding/src/elements/bar.rs index 634c9f87..b079ba74 100644 --- a/yazi-binding/src/elements/bar.rs +++ b/yazi-binding/src/elements/bar.rs @@ -18,7 +18,7 @@ impl Bar { lua.create_function(|_, (_, edge): (Table, Edge)| Ok(Self { edge, ..Default::default() }))?; let bar = lua.create_table()?; - bar.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + bar.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; bar.into_lua(lua) } diff --git a/yazi-binding/src/elements/border.rs b/yazi-binding/src/elements/border.rs index 97e49940..c4a39421 100644 --- a/yazi-binding/src/elements/border.rs +++ b/yazi-binding/src/elements/border.rs @@ -38,7 +38,7 @@ impl Border { ("QUADRANT_OUTSIDE", QUADRANT_OUTSIDE), ])?; - border.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + border.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; border.into_lua(lua) } diff --git a/yazi-binding/src/elements/clear.rs b/yazi-binding/src/elements/clear.rs index d917cade..65b0e8c5 100644 --- a/yazi-binding/src/elements/clear.rs +++ b/yazi-binding/src/elements/clear.rs @@ -17,7 +17,7 @@ impl Clear { let new = lua.create_function(|_, (_, area): (Table, Area)| Ok(Clear { area }))?; let clear = lua.create_table()?; - clear.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + clear.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; clear.into_lua(lua) } diff --git a/yazi-binding/src/elements/gauge.rs b/yazi-binding/src/elements/gauge.rs index b1bdbb0f..3a3bd59e 100644 --- a/yazi-binding/src/elements/gauge.rs +++ b/yazi-binding/src/elements/gauge.rs @@ -19,7 +19,7 @@ impl Gauge { let new = lua.create_function(|_, _: Table| Ok(Gauge::default()))?; let gauge = lua.create_table()?; - gauge.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + gauge.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; gauge.into_lua(lua) } diff --git a/yazi-binding/src/elements/layout.rs b/yazi-binding/src/elements/layout.rs index 1e0ac00e..5449d70e 100644 --- a/yazi-binding/src/elements/layout.rs +++ b/yazi-binding/src/elements/layout.rs @@ -17,7 +17,7 @@ impl Layout { let new = lua.create_function(|_, _: Table| Ok(Self::default()))?; let layout = lua.create_table_from([("HORIZONTAL", HORIZONTAL), ("VERTICAL", VERTICAL)])?; - layout.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + layout.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; layout.into_lua(lua) } diff --git a/yazi-binding/src/elements/line.rs b/yazi-binding/src/elements/line.rs index d584d302..1a48d9c8 100644 --- a/yazi-binding/src/elements/line.rs +++ b/yazi-binding/src/elements/line.rs @@ -36,7 +36,7 @@ impl Line { })?; let line = lua.create_table_from([("parse", parse)])?; - line.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + line.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; line.into_lua(lua) } diff --git a/yazi-binding/src/elements/list.rs b/yazi-binding/src/elements/list.rs index 72b8e157..a955d761 100644 --- a/yazi-binding/src/elements/list.rs +++ b/yazi-binding/src/elements/list.rs @@ -25,7 +25,7 @@ impl List { })?; let list = lua.create_table()?; - list.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + list.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; list.into_lua(lua) } diff --git a/yazi-binding/src/elements/pad.rs b/yazi-binding/src/elements/pad.rs index 3053797b..97c7ecba 100644 --- a/yazi-binding/src/elements/pad.rs +++ b/yazi-binding/src/elements/pad.rs @@ -46,7 +46,7 @@ impl Pad { ), ])?; - pad.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + pad.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; pad.into_lua(lua) } } diff --git a/yazi-binding/src/elements/pos.rs b/yazi-binding/src/elements/pos.rs index 4687e4b5..07304028 100644 --- a/yazi-binding/src/elements/pos.rs +++ b/yazi-binding/src/elements/pos.rs @@ -70,7 +70,7 @@ impl Pos { let new = lua.create_function(|_, (_, t): (Table, Table)| Self::try_from(t))?; let position = lua.create_table()?; - position.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + position.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; position.into_lua(lua) } @@ -85,7 +85,7 @@ impl Pos { impl UserData for Pos { fn add_fields>(fields: &mut F) { // TODO: cache - fields.add_field_method_get(1, |_, me| Ok(me.origin.to_string())); + fields.add_field_method_get("1", |_, me| Ok(me.origin.to_string())); fields.add_field_method_get("x", |_, me| Ok(me.offset.x)); fields.add_field_method_get("y", |_, me| Ok(me.offset.y)); fields.add_field_method_get("w", |_, me| Ok(me.offset.width)); diff --git a/yazi-binding/src/elements/rect.rs b/yazi-binding/src/elements/rect.rs index 9853568a..c265ff66 100644 --- a/yazi-binding/src/elements/rect.rs +++ b/yazi-binding/src/elements/rect.rs @@ -48,7 +48,7 @@ impl Rect { let rect = lua.create_table()?; rect.set_metatable(Some( lua.create_table_from([(MetaMethod::Call.name(), new), (MetaMethod::Index.name(), index)])?, - )); + ))?; rect.into_lua(lua) } diff --git a/yazi-binding/src/elements/row.rs b/yazi-binding/src/elements/row.rs index 378c143d..c088fa22 100644 --- a/yazi-binding/src/elements/row.rs +++ b/yazi-binding/src/elements/row.rs @@ -20,7 +20,7 @@ impl Row { })?; let row = lua.create_table()?; - row.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + row.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; row.into_lua(lua) } diff --git a/yazi-binding/src/elements/span.rs b/yazi-binding/src/elements/span.rs index e7a1ef74..c7bde820 100644 --- a/yazi-binding/src/elements/span.rs +++ b/yazi-binding/src/elements/span.rs @@ -12,7 +12,7 @@ impl Span { let new = lua.create_function(|_, (_, value): (Table, Value)| Span::try_from(value))?; let span = lua.create_table()?; - span.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + span.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; span.into_lua(lua) } diff --git a/yazi-binding/src/elements/table.rs b/yazi-binding/src/elements/table.rs index 2160692b..4007bf41 100644 --- a/yazi-binding/src/elements/table.rs +++ b/yazi-binding/src/elements/table.rs @@ -43,7 +43,7 @@ impl Table { })?; let table = lua.create_table()?; - table.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + table.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; table.into_lua(lua) } diff --git a/yazi-binding/src/elements/text.rs b/yazi-binding/src/elements/text.rs index 73e921db..20f6a275 100644 --- a/yazi-binding/src/elements/text.rs +++ b/yazi-binding/src/elements/text.rs @@ -28,7 +28,7 @@ impl Text { })?; let text = lua.create_table_from([("parse", parse)])?; - text.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + text.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; text.into_lua(lua) } diff --git a/yazi-binding/src/style.rs b/yazi-binding/src/style.rs index c81c8cf1..3403619e 100644 --- a/yazi-binding/src/style.rs +++ b/yazi-binding/src/style.rs @@ -8,7 +8,7 @@ impl Style { let new = lua.create_function(|_, (_, value): (Table, Value)| Self::try_from(value))?; let style = lua.create_table()?; - style.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + style.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; style.into_lua(lua) } diff --git a/yazi-plugin/src/isolate/peek.rs b/yazi-plugin/src/isolate/peek.rs index 028007d2..431c1b1b 100644 --- a/yazi-plugin/src/isolate/peek.rs +++ b/yazi-plugin/src/isolate/peek.rs @@ -81,7 +81,7 @@ fn peek_async( Ok(VmState::Continue) } }, - ); + )?; let plugin = LOADER.load_once(&lua, &cmd.name)?; let job = lua.create_table_from([ diff --git a/yazi-plugin/src/isolate/preload.rs b/yazi-plugin/src/isolate/preload.rs index 8351a30b..a61b8d76 100644 --- a/yazi-plugin/src/isolate/preload.rs +++ b/yazi-plugin/src/isolate/preload.rs @@ -29,7 +29,7 @@ pub async fn preload( Ok(VmState::Continue) } }, - ); + )?; let plugin = LOADER.load_once(&lua, &cmd.name)?; let job = lua.create_table_from([ diff --git a/yazi-plugin/src/isolate/spot.rs b/yazi-plugin/src/isolate/spot.rs index cc910288..cf8d2283 100644 --- a/yazi-plugin/src/isolate/spot.rs +++ b/yazi-plugin/src/isolate/spot.rs @@ -29,7 +29,7 @@ pub fn spot(cmd: &'static Cmd, file: yazi_fs::File, mime: SStr, skip: usize) -> Ok(VmState::Continue) } }, - ); + )?; let plugin = LOADER.load_once(&lua, &cmd.name)?; let job = lua.create_table_from([ diff --git a/yazi-plugin/src/loader/chunk.rs b/yazi-plugin/src/loader/chunk.rs index c84b43af..af133795 100644 --- a/yazi-plugin/src/loader/chunk.rs +++ b/yazi-plugin/src/loader/chunk.rs @@ -65,8 +65,13 @@ impl From> for Chunk { fn from(b: Vec) -> Self { Self::from(Cow::Owned(b)) } } -impl<'a> AsChunk<'a> for &'a Chunk { - fn source(self) -> std::io::Result> { Ok(Cow::Borrowed(&self.bytes)) } - +impl AsChunk for &Chunk { fn mode(&self) -> Option { Some(self.mode) } + + fn source<'a>(&self) -> std::io::Result> + where + Self: 'a, + { + Ok(Cow::Borrowed(&self.bytes)) + } } diff --git a/yazi-plugin/src/loader/require.rs b/yazi-plugin/src/loader/require.rs index fcb3a707..2daee6cb 100644 --- a/yazi-plugin/src/loader/require.rs +++ b/yazi-plugin/src/loader/require.rs @@ -63,7 +63,7 @@ impl Require { ])?; let ts = lua.create_table_from([("__mod", r#mod)])?; - ts.set_metatable(Some(mt)); + ts.set_metatable(Some(mt))?; Ok(ts) } diff --git a/yazi-plugin/src/process/command.rs b/yazi-plugin/src/process/command.rs index f1d2c57c..ac66cd71 100644 --- a/yazi-plugin/src/process/command.rs +++ b/yazi-plugin/src/process/command.rs @@ -33,7 +33,7 @@ impl Command { ("INHERIT", INHERIT), ])?; - command.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?)); + command.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; lua.globals().raw_set("Command", command) }