use mlua::{FromLua, IntoLua, Lua, Value}; use yazi_core::which::WhichOpt; use yazi_shared::event::ActionCow; #[derive(Clone, Debug)] pub struct ActivateForm { pub opt: WhichOpt, } impl From for ActivateForm { fn from(opt: WhichOpt) -> Self { Self { opt } } } impl TryFrom for ActivateForm { type Error = anyhow::Error; fn try_from(mut a: ActionCow) -> Result { Ok(Self { opt: if let Some(opt) = a.take_any("opt") { opt } else { a.try_into()? } }) } } impl FromLua for ActivateForm { fn from_lua(value: Value, lua: &Lua) -> mlua::Result { Ok(Self { opt: WhichOpt::from_lua(value, lua)? }) } } impl IntoLua for ActivateForm { fn into_lua(self, lua: &Lua) -> mlua::Result { self.opt.into_lua(lua) } }