Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] misc/io_utils.rs: add rust impl of atomic file save #15934

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kasper93
Copy link
Contributor

@kasper93 kasper93 commented Feb 21, 2025

Not much to say, just Rust. It turns out to be relatively simple to integrate. Dependencies need to be manually added as subprojects. I specifically tested this on file IO with external tempfile crate and its dependencies.

This is PoC of visibility of Rust in mpv and of course will not happen for such small functionality, but if there would be good reason to use it, why not? Maybe it will bring some new contributors.

I know some people will get really mad at this PR :^)

(don't judge my rust code, I only wanted to try how it integrates in mpv)

EDIT:

I wanted a trial by fire and use heavy file io and fs functions. Works well on Windows and Linux with hardcoded flags for rustix, but to support also macos build, it needs more magic in meson. Though this is good exercise to know what are the challenges. More standalone examples works fine. We obviously are not merging this, it's more of a research of feasibility.

@kasper93 kasper93 force-pushed the mpv-rs branch 2 times, most recently from 3e72cf3 to b29330e Compare February 21, 2025 19:47
@llyyr
Copy link
Contributor

llyyr commented Feb 21, 2025

I like the idea of moving to a language safer and easier to write than C. Avoids problems mentioned in recent PRs about talloc/bstr functions being too hard to use correctly, and I much prefer Rust over Lua if we want to avoid C going into the future.

@Andarwinux
Copy link
Contributor

This will bring some compatibility issues.

  1. If mpv's dependencies also include rust dependencies such as libdovi (libplacebo's dependency), there will be conflicts or duplications between the rust-std of the two.

  2. It brings inconvenience to special targets. If there are some targets that rust only supports as a Tier 3, or enable hardening features such as cfguard, then we must use cargo build-std. Does rust in meson support this?

@kasper93 kasper93 marked this pull request as draft February 22, 2025 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants