mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Some checks are pending
Cachix / Publish Flake (push) Waiting to run
Check / clippy (push) Waiting to run
Check / rustfmt (push) Waiting to run
Check / stylua (push) Waiting to run
Draft / build-unix (gcc-aarch64-linux-gnu, ubuntu-latest, aarch64-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-i686-linux-gnu, ubuntu-latest, i686-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-riscv64-linux-gnu, ubuntu-latest, riscv64gc-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (gcc-sparc64-linux-gnu, ubuntu-latest, sparc64-unknown-linux-gnu) (push) Waiting to run
Draft / build-unix (macos-latest, aarch64-apple-darwin) (push) Waiting to run
Draft / build-unix (macos-latest, x86_64-apple-darwin) (push) Waiting to run
Draft / build-unix (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Waiting to run
Draft / build-windows (windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Draft / build-windows (windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Draft / build-musl (aarch64-unknown-linux-musl) (push) Waiting to run
Draft / build-musl (x86_64-unknown-linux-musl) (push) Waiting to run
Draft / build-snap (amd64, ubuntu-latest) (push) Waiting to run
Draft / build-snap (arm64, ubuntu-24.04-arm) (push) Waiting to run
Draft / snap (push) Blocked by required conditions
Draft / draft (push) Blocked by required conditions
Draft / nightly (push) Blocked by required conditions
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use mlua::{Lua, Table, UserData};
|
|
use yazi_codegen::FromLuaOwned;
|
|
use yazi_macro::impl_data_any;
|
|
use yazi_shared::url::UrlBuf;
|
|
|
|
#[derive(Clone, FromLuaOwned, UserData)]
|
|
pub(super) struct FilesOp(yazi_fs::FilesOp);
|
|
|
|
impl_data_any!(FilesOp => yazi_fs::FilesOp; from_into_lua = inherit);
|
|
|
|
impl From<FilesOp> for yazi_fs::FilesOp {
|
|
fn from(op: FilesOp) -> Self { op.0 }
|
|
}
|
|
|
|
impl AsRef<yazi_fs::FilesOp> for FilesOp {
|
|
fn as_ref(&self) -> &yazi_fs::FilesOp { &self.0 }
|
|
}
|
|
|
|
impl FilesOp {
|
|
pub(super) fn part(_: &Lua, t: Table) -> mlua::Result<Self> {
|
|
let id = t.raw_get("id")?;
|
|
let url = t.raw_get("url")?;
|
|
let files: Table = t.raw_get("files")?;
|
|
|
|
Ok(Self(yazi_fs::FilesOp::Part(
|
|
url,
|
|
files.sequence_values().collect::<mlua::Result<Vec<_>>>()?,
|
|
id,
|
|
)))
|
|
}
|
|
|
|
pub(super) fn done(_: &Lua, t: Table) -> mlua::Result<Self> {
|
|
let id = t.raw_get("id")?;
|
|
let file = t.raw_get("file")?;
|
|
|
|
Ok(Self(yazi_fs::FilesOp::Done(file, id)))
|
|
}
|
|
|
|
pub(super) fn size(_: &Lua, t: Table) -> mlua::Result<Self> {
|
|
let url: UrlBuf = t.raw_get("url")?;
|
|
let sizes: Table = t.raw_get("sizes")?;
|
|
|
|
Ok(Self(yazi_fs::FilesOp::Size(url, sizes.pairs().collect::<mlua::Result<_>>()?)))
|
|
}
|
|
}
|