Skip to content

Commit

Permalink
fix: implement FromLua for Cha instead of AnyUserData
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Nov 13, 2024
1 parent 0048652 commit 0d2e2b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
prefix-key: rust
shared-key: ubuntu-latest@debug

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Clippy
Expand All @@ -50,7 +50,7 @@ jobs:
prefix-key: rust
shared-key: ubuntu-latest@debug

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Rustfmt
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
prefix-key: rust
shared-key: ${{ matrix.target }}@release

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Build
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
prefix-key: rust
shared-key: ${{ matrix.target }}@release

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Build
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
prefix-key: rust
shared-key: ${{ matrix.target }}@release

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Build
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
prefix-key: rust
shared-key: ${{ matrix.target }}@release

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
prefix-key: rust
shared-key: ${{ matrix.os }}@debug

- name: Run sccache-cache
- name: Run sccache
uses: mozilla-actions/sccache-action@v0.0.6

- name: Build
Expand Down
3 changes: 2 additions & 1 deletion yazi-plugin/src/bindings/cha.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::{ops::Deref, time::{Duration, SystemTime, UNIX_EPOCH}};

use mlua::{ExternalError, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, UserDataMethods};
use yazi_shared::fs::ChaKind;

use crate::RtRef;

#[derive(Clone, Copy, FromLua)]
pub struct Cha(yazi_shared::fs::Cha);

impl Deref for Cha {
Expand Down
4 changes: 2 additions & 2 deletions yazi-plugin/src/file/file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use mlua::{AnyUserData, Lua, Table, UserDataRef};

use crate::{bindings::Cast, impl_file_fields, impl_file_methods};
use crate::{bindings::{Cast, Cha}, impl_file_fields, impl_file_methods};

pub type FileRef = UserDataRef<yazi_shared::fs::File>;

Expand All @@ -21,7 +21,7 @@ impl File {
lua.create_function(|lua, t: Table| {
Self::cast(lua, yazi_shared::fs::File {
url: t.raw_get::<AnyUserData>("url")?.take()?,
cha: t.raw_get::<AnyUserData>("cha")?.take()?,
cha: *t.raw_get::<Cha>("cha")?,
..Default::default()
})
})?,
Expand Down

0 comments on commit 0d2e2b5

Please sign in to comment.