yazi/yazi-runner/src/previewer/job.rs
2026-06-18 15:06:31 +08:00

46 lines
1.1 KiB
Rust

use mlua::{IntoLua, Lua, Value};
use yazi_binding::elements::Rect;
use yazi_config::{LAYOUT, plugin::PreviewerArc};
use yazi_fs::file::File;
use yazi_shared::{data::Sendable, pool::Symbol};
#[derive(Clone, Debug)]
pub struct PeekJob {
pub previewer: PreviewerArc,
pub file: File,
pub mime: Symbol<str>,
pub skip: usize,
}
impl IntoLua for PeekJob {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
lua
.create_table_from([
("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
("args", Sendable::args_to_table_ref(lua, &self.previewer.args)?.into_lua(lua)?),
("file", self.file.into_lua(lua)?),
("mime", self.mime.into_lua(lua)?),
("skip", self.skip.into_lua(lua)?),
])?
.into_lua(lua)
}
}
// --- Seek
#[derive(Clone, Debug)]
pub struct SeekJob {
pub file: File,
pub units: i16,
}
impl IntoLua for SeekJob {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
lua
.create_table_from([
("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
("file", self.file.into_lua(lua)?),
("units", self.units.into_lua(lua)?),
])?
.into_lua(lua)
}
}