use mlua::{ExternalError, IntoLua, Lua, Value}; use yazi_shared::{event::CmdCow, url::Url}; #[derive(Debug)] pub struct ToggleAllOpt { pub urls: Vec, pub state: Option, } impl From for ToggleAllOpt { fn from(mut c: CmdCow) -> Self { let mut urls = Vec::with_capacity(c.len()); for i in 0..c.len() { match c.take_url(i) { Some(url) => urls.push(url), None => break, } } Self { urls, state: match c.str("state") { Some("on") => Some(true), Some("off") => Some(false), _ => None, }, } } } impl From> for ToggleAllOpt { fn from(state: Option) -> Self { Self { urls: vec![], state } } } impl IntoLua for &ToggleAllOpt { fn into_lua(self, _: &Lua) -> mlua::Result { Err("unsupported".into_lua_err()) } }