PolyMeilex / rfd

Rusty File Dialog
MIT License
564 stars 64 forks source link

Reduce or Feature gate dependencies #140

Closed coderedart closed 1 year ago

coderedart commented 1 year ago

I would like to preface this by saying that i am ignorant in this area. So, i apologize in advance if i am asking a dumb question.

But is it possible to put all those async dependencies behind feature flags for async dialogs? or do we need those for the blocking operations too (especially on windows/linux)?

with all features disabled, this is the output of cargo tree :cry: (over 50 deps, mostly from async-io)

└── rfd v0.11.4
    ├── async-io v1.13.0
    │   ├── async-lock v2.8.0
    │   │   └── event-listener v2.5.3
    │   ├── cfg-if v1.0.0
    │   ├── concurrent-queue v2.2.0
    │   │   └── crossbeam-utils v0.8.16
    │   │       └── cfg-if v1.0.0
    │   ├── futures-lite v1.13.0
    │   │   ├── fastrand v1.9.0
    │   │   ├── futures-core v0.3.28
    │   │   ├── futures-io v0.3.28
    │   │   ├── memchr v2.6.1
    │   │   ├── parking v2.1.0
    │   │   ├── pin-project-lite v0.2.13
    │   │   └── waker-fn v1.1.0
    │   ├── log v0.4.20
    │   ├── parking v2.1.0
    │   ├── polling v2.8.0
    │   │   ├── cfg-if v1.0.0
    │   │   ├── libc v0.2.147
    │   │   └── log v0.4.20
    │   │   [build-dependencies]
    │   │   └── autocfg v1.1.0
    │   ├── rustix v0.37.23
    │   │   ├── bitflags v1.3.2
    │   │   ├── io-lifetimes v1.0.11
    │   │   │   └── libc v0.2.147
    │   │   └── linux-raw-sys v0.3.8
    │   ├── slab v0.4.9
    │   │   [build-dependencies]
    │   │   └── autocfg v1.1.0
    │   ├── socket2 v0.4.9
    │   │   └── libc v0.2.147
    │   └── waker-fn v1.1.0
    │   [build-dependencies]
    │   └── autocfg v1.1.0
    ├── futures-util v0.3.28
    │   ├── futures-core v0.3.28
    │   ├── futures-io v0.3.28
    │   ├── futures-task v0.3.28
    │   ├── memchr v2.6.1
    │   ├── pin-project-lite v0.2.13
    │   ├── pin-utils v0.1.0
    │   └── slab v0.4.9 (*)
    ├── log v0.4.20
    └── raw-window-handle v0.5.2

And here i have xdg portal feature enabled for linux :sob: :sob: :sob: (over 150 dependencies, mostly from ashpd. )

rfd v0.11.4
    ├── ashpd v0.4.0
    │   ├── async-std v1.12.0
    │   │   ├── async-channel v1.9.0
    │   │   │   ├── concurrent-queue v2.2.0
    │   │   │   │   └── crossbeam-utils v0.8.16
    │   │   │   │       └── cfg-if v1.0.0
    │   │   │   ├── event-listener v2.5.3
    │   │   │   └── futures-core v0.3.28
    │   │   ├── async-global-executor v2.3.1
    │   │   │   ├── async-channel v1.9.0 (*)
    │   │   │   ├── async-executor v1.5.1
    │   │   │   │   ├── async-lock v2.8.0
    │   │   │   │   │   └── event-listener v2.5.3
    │   │   │   │   ├── async-task v4.4.0
    │   │   │   │   ├── concurrent-queue v2.2.0 (*)
    │   │   │   │   ├── fastrand v1.9.0
    │   │   │   │   ├── futures-lite v1.13.0
    │   │   │   │   │   ├── fastrand v1.9.0
    │   │   │   │   │   ├── futures-core v0.3.28
    │   │   │   │   │   ├── futures-io v0.3.28
    │   │   │   │   │   ├── memchr v2.6.1
    │   │   │   │   │   ├── parking v2.1.0
    │   │   │   │   │   ├── pin-project-lite v0.2.13
    │   │   │   │   │   └── waker-fn v1.1.0
    │   │   │   │   └── slab v0.4.9
    │   │   │   │       [build-dependencies]
    │   │   │   │       └── autocfg v1.1.0
    │   │   │   ├── async-io v1.13.0
    │   │   │   │   ├── async-lock v2.8.0 (*)
    │   │   │   │   ├── cfg-if v1.0.0
    │   │   │   │   ├── concurrent-queue v2.2.0 (*)
    │   │   │   │   ├── futures-lite v1.13.0 (*)
    │   │   │   │   ├── log v0.4.20
    │   │   │   │   │   └── value-bag v1.4.1
    │   │   │   │   ├── parking v2.1.0
    │   │   │   │   ├── polling v2.8.0
    │   │   │   │   │   ├── cfg-if v1.0.0
    │   │   │   │   │   ├── libc v0.2.147
    │   │   │   │   │   └── log v0.4.20 (*)
    │   │   │   │   │   [build-dependencies]
    │   │   │   │   │   └── autocfg v1.1.0
    │   │   │   │   ├── rustix v0.37.23
    │   │   │   │   │   ├── bitflags v1.3.2
    │   │   │   │   │   ├── io-lifetimes v1.0.11
    │   │   │   │   │   │   └── libc v0.2.147
    │   │   │   │   │   └── linux-raw-sys v0.3.8
    │   │   │   │   ├── slab v0.4.9 (*)
    │   │   │   │   ├── socket2 v0.4.9
    │   │   │   │   │   └── libc v0.2.147
    │   │   │   │   └── waker-fn v1.1.0
    │   │   │   │   [build-dependencies]
    │   │   │   │   └── autocfg v1.1.0
    │   │   │   ├── async-lock v2.8.0 (*)
    │   │   │   ├── blocking v1.3.1
    │   │   │   │   ├── async-channel v1.9.0 (*)
    │   │   │   │   ├── async-lock v2.8.0 (*)
    │   │   │   │   ├── async-task v4.4.0
    │   │   │   │   ├── atomic-waker v1.1.1
    │   │   │   │   ├── fastrand v1.9.0
    │   │   │   │   ├── futures-lite v1.13.0 (*)
    │   │   │   │   └── log v0.4.20 (*)
    │   │   │   ├── futures-lite v1.13.0 (*)
    │   │   │   └── once_cell v1.18.0
    │   │   ├── async-io v1.13.0 (*)
    │   │   ├── async-lock v2.8.0 (*)
    │   │   ├── crossbeam-utils v0.8.16 (*)
    │   │   ├── futures-core v0.3.28
    │   │   ├── futures-io v0.3.28
    │   │   ├── futures-lite v1.13.0 (*)
    │   │   ├── kv-log-macro v1.0.7
    │   │   │   └── log v0.4.20 (*)
    │   │   ├── log v0.4.20 (*)
    │   │   ├── memchr v2.6.1
    │   │   ├── once_cell v1.18.0
    │   │   ├── pin-project-lite v0.2.13
    │   │   ├── pin-utils v0.1.0
    │   │   └── slab v0.4.9 (*)
    │   ├── enumflags2 v0.7.7
    │   │   ├── enumflags2_derive v0.7.7 (proc-macro)
    │   │   │   ├── proc-macro2 v1.0.66
    │   │   │   │   └── unicode-ident v1.0.11
    │   │   │   ├── quote v1.0.33
    │   │   │   │   └── proc-macro2 v1.0.66 (*)
    │   │   │   └── syn v2.0.29
    │   │   │       ├── proc-macro2 v1.0.66 (*)
    │   │   │       ├── quote v1.0.33 (*)
    │   │   │       └── unicode-ident v1.0.11
    │   │   └── serde v1.0.188
    │   │       └── serde_derive v1.0.188 (proc-macro)
    │   │           ├── proc-macro2 v1.0.66 (*)
    │   │           ├── quote v1.0.33 (*)
    │   │           └── syn v2.0.29 (*)
    │   ├── futures-channel v0.3.28
    │   │   └── futures-core v0.3.28
    │   ├── futures-util v0.3.28
    │   │   ├── futures-core v0.3.28
    │   │   ├── futures-io v0.3.28
    │   │   ├── futures-macro v0.3.28 (proc-macro)
    │   │   │   ├── proc-macro2 v1.0.66 (*)
    │   │   │   ├── quote v1.0.33 (*)
    │   │   │   └── syn v2.0.29 (*)
    │   │   ├── futures-sink v0.3.28
    │   │   ├── futures-task v0.3.28
    │   │   ├── memchr v2.6.1
    │   │   ├── pin-project-lite v0.2.13
    │   │   ├── pin-utils v0.1.0
    │   │   └── slab v0.4.9 (*)
    │   ├── once_cell v1.18.0
    │   ├── rand v0.8.5
    │   │   ├── libc v0.2.147
    │   │   ├── rand_chacha v0.3.1
    │   │   │   ├── ppv-lite86 v0.2.17
    │   │   │   └── rand_core v0.6.4
    │   │   │       └── getrandom v0.2.10
    │   │   │           ├── cfg-if v1.0.0
    │   │   │           └── libc v0.2.147
    │   │   └── rand_core v0.6.4 (*)
    │   ├── serde v1.0.188 (*)
    │   ├── serde_repr v0.1.16 (proc-macro)
    │   │   ├── proc-macro2 v1.0.66 (*)
    │   │   ├── quote v1.0.33 (*)
    │   │   └── syn v2.0.29 (*)
    │   ├── url v2.4.1
    │   │   ├── form_urlencoded v1.2.0
    │   │   │   └── percent-encoding v2.3.0
    │   │   ├── idna v0.4.0
    │   │   │   ├── unicode-bidi v0.3.13
    │   │   │   └── unicode-normalization v0.1.22
    │   │   │       └── tinyvec v1.6.0
    │   │   │           └── tinyvec_macros v0.1.1
    │   │   ├── percent-encoding v2.3.0
    │   │   └── serde v1.0.188 (*)
    │   └── zbus v3.14.1
    │       ├── async-broadcast v0.5.1
    │       │   ├── event-listener v2.5.3
    │       │   └── futures-core v0.3.28
    │       ├── async-executor v1.5.1 (*)
    │       ├── async-fs v1.6.0
    │       │   ├── async-lock v2.8.0 (*)
    │       │   ├── blocking v1.3.1 (*)
    │       │   └── futures-lite v1.13.0 (*)
    │       │   [build-dependencies]
    │       │   └── autocfg v1.1.0
    │       ├── async-io v1.13.0 (*)
    │       ├── async-lock v2.8.0 (*)
    │       ├── async-recursion v1.0.4 (proc-macro)
    │       │   ├── proc-macro2 v1.0.66 (*)
    │       │   ├── quote v1.0.33 (*)
    │       │   └── syn v2.0.29 (*)
    │       ├── async-task v4.4.0
    │       ├── async-trait v0.1.73 (proc-macro)
    │       │   ├── proc-macro2 v1.0.66 (*)
    │       │   ├── quote v1.0.33 (*)
    │       │   └── syn v2.0.29 (*)
    │       ├── blocking v1.3.1 (*)
    │       ├── byteorder v1.4.3
    │       ├── derivative v2.2.0 (proc-macro)
    │       │   ├── proc-macro2 v1.0.66 (*)
    │       │   ├── quote v1.0.33 (*)
    │       │   └── syn v1.0.109
    │       │       ├── proc-macro2 v1.0.66 (*)
    │       │       ├── quote v1.0.33 (*)
    │       │       └── unicode-ident v1.0.11
    │       ├── enumflags2 v0.7.7 (*)
    │       ├── event-listener v2.5.3
    │       ├── futures-core v0.3.28
    │       ├── futures-sink v0.3.28
    │       ├── futures-util v0.3.28 (*)
    │       ├── hex v0.4.3
    │       ├── nix v0.26.4
    │       │   ├── bitflags v1.3.2
    │       │   ├── cfg-if v1.0.0
    │       │   ├── libc v0.2.147
    │       │   └── memoffset v0.7.1
    │       │       [build-dependencies]
    │       │       └── autocfg v1.1.0
    │       ├── once_cell v1.18.0
    │       ├── ordered-stream v0.2.0
    │       │   ├── futures-core v0.3.28
    │       │   └── pin-project-lite v0.2.13
    │       ├── rand v0.8.5 (*)
    │       ├── serde v1.0.188 (*)
    │       ├── serde_repr v0.1.16 (proc-macro) (*)
    │       ├── sha1 v0.10.5
    │       │   ├── cfg-if v1.0.0
    │       │   ├── cpufeatures v0.2.9
    │       │   └── digest v0.10.7
    │       │       ├── block-buffer v0.10.4
    │       │       │   └── generic-array v0.14.7
    │       │       │       └── typenum v1.16.0
    │       │       │       [build-dependencies]
    │       │       │       └── version_check v0.9.4
    │       │       └── crypto-common v0.1.6
    │       │           ├── generic-array v0.14.7 (*)
    │       │           └── typenum v1.16.0
    │       ├── static_assertions v1.1.0
    │       ├── tracing v0.1.37
    │       │   ├── cfg-if v1.0.0
    │       │   ├── pin-project-lite v0.2.13
    │       │   ├── tracing-attributes v0.1.26 (proc-macro)
    │       │   │   ├── proc-macro2 v1.0.66 (*)
    │       │   │   ├── quote v1.0.33 (*)
    │       │   │   └── syn v2.0.29 (*)
    │       │   └── tracing-core v0.1.31
    │       │       └── once_cell v1.18.0
    │       ├── xdg-home v1.0.0
    │       │   └── nix v0.26.4 (*)
    │       ├── zbus_macros v3.14.1 (proc-macro)
    │       │   ├── proc-macro-crate v1.3.1
    │       │   │   ├── once_cell v1.18.0
    │       │   │   └── toml_edit v0.19.14
    │       │   │       ├── indexmap v2.0.0
    │       │   │       │   ├── equivalent v1.0.1
    │       │   │       │   └── hashbrown v0.14.0
    │       │   │       ├── toml_datetime v0.6.3
    │       │   │       └── winnow v0.5.15
    │       │   ├── proc-macro2 v1.0.66 (*)
    │       │   ├── quote v1.0.33 (*)
    │       │   ├── regex v1.9.4
    │       │   │   ├── aho-corasick v1.0.5
    │       │   │   │   └── memchr v2.6.1
    │       │   │   ├── memchr v2.6.1
    │       │   │   ├── regex-automata v0.3.7
    │       │   │   │   ├── aho-corasick v1.0.5 (*)
    │       │   │   │   ├── memchr v2.6.1
    │       │   │   │   └── regex-syntax v0.7.5
    │       │   │   └── regex-syntax v0.7.5
    │       │   ├── syn v1.0.109 (*)
    │       │   └── zvariant_utils v1.0.1
    │       │       ├── proc-macro2 v1.0.66 (*)
    │       │       ├── quote v1.0.33 (*)
    │       │       └── syn v1.0.109 (*)
    │       ├── zbus_names v2.6.0
    │       │   ├── serde v1.0.188 (*)
    │       │   ├── static_assertions v1.1.0
    │       │   └── zvariant v3.15.0
    │       │       ├── byteorder v1.4.3
    │       │       ├── enumflags2 v0.7.7 (*)
    │       │       ├── libc v0.2.147
    │       │       ├── serde v1.0.188 (*)
    │       │       ├── static_assertions v1.1.0
    │       │       ├── url v2.4.1 (*)
    │       │       └── zvariant_derive v3.15.0 (proc-macro)
    │       │           ├── proc-macro-crate v1.3.1 (*)
    │       │           ├── proc-macro2 v1.0.66 (*)
    │       │           ├── quote v1.0.33 (*)
    │       │           ├── syn v1.0.109 (*)
    │       │           └── zvariant_utils v1.0.1 (*)
    │       └── zvariant v3.15.0 (*)
    ├── async-io v1.13.0 (*)
    ├── futures-util v0.3.28 (*)
    ├── log v0.4.20 (*)
    ├── pollster v0.3.0
    ├── raw-window-handle v0.5.2
    └── urlencoding v2.1.3

gtk is better, but it still adds more than 50 deps. Fortunately, i can already see that we have a zenity/kdialog backend coming soon which won't need any dependencies at all.

PolyMeilex commented 1 year ago

async-io is actually zenity backend & ashpd backend, dependency, so that could be moved under xdg feature

coderedart commented 1 year ago

oh, does zenity need async-io too? I thought it would simply spawn a background thread and block on the commandline result.

PolyMeilex commented 1 year ago

It reads stdout asynchronously, but I guess this could just be moved to a blocking thread, performance does not matter for this anyway, async-io was used for that as zenity is only used for xdg-portal backend for now (for messages dialogs) and async-io is a dep of that backend already anyway.

coderedart commented 1 year ago

zenity is only used for xdg-portal backend for now (for messages dialogs)

hmm. So, when the next version releases, is it possible to use zenity (for open/save file dialogs) without xdg-portal?

PolyMeilex commented 1 year ago

Once zenity backend becomes a thing someday, yes

PolyMeilex commented 1 year ago

Removed all the async related deps from gtk backend: https://github.com/PolyMeilex/rfd/pull/141

PolyMeilex commented 1 year ago

0.12 published with async deps removed from GTK feature gate

(Feel free to reopen if I missed some)