mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-23 15:51:03 +00:00
32 lines
842 B
Rust
32 lines
842 B
Rust
use std::borrow::Cow;
|
|
|
|
use mlua::{IntoLua, Lua, Value};
|
|
use serde::{Deserialize, Serialize};
|
|
use yazi_shared::url::UrlBuf;
|
|
|
|
use super::Ember;
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
pub struct EmberDelete<'a> {
|
|
pub urls: Cow<'a, Vec<UrlBuf>>,
|
|
}
|
|
|
|
impl<'a> EmberDelete<'a> {
|
|
pub fn borrowed(urls: &'a Vec<UrlBuf>) -> Ember<'a> { Self { urls: Cow::Borrowed(urls) }.into() }
|
|
}
|
|
|
|
impl EmberDelete<'static> {
|
|
pub fn owned(urls: Vec<UrlBuf>) -> Ember<'static> { Self { urls: Cow::Owned(urls) }.into() }
|
|
}
|
|
|
|
impl<'a> From<EmberDelete<'a>> for Ember<'a> {
|
|
fn from(value: EmberDelete<'a>) -> Self { Self::Delete(value) }
|
|
}
|
|
|
|
impl IntoLua for EmberDelete<'_> {
|
|
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
|
let urls = lua.create_sequence_from(self.urls.into_owned())?;
|
|
|
|
lua.create_table_from([("urls", urls)])?.into_lua(lua)
|
|
}
|
|
}
|