Skip to content

Rust bindings#29

Merged
vt-tv merged 79 commits intodmf-mxl:mainfrom
pac-work:rust-bindings
Nov 7, 2025
Merged

Rust bindings#29
vt-tv merged 79 commits intodmf-mxl:mainfrom
pac-work:rust-bindings

Conversation

@pac-work
Copy link
Contributor

@pac-work pac-work commented Jul 4, 2025

This is a placeholder for potential integration of bindings for the Rust programing language into the main repository. It has to my knowledge not been decided yet whether this is desirable or not. Let this draft merge request serve the purpose of increasing the visibility of ongoing work until a decision how to progress with this is made.

@pac-work pac-work changed the title Rust bindings Draft: Rust bindings Jul 4, 2025
@vt-tv vt-tv moved this to Backlog in MXL TSC Board Jul 7, 2025
@vt-tv vt-tv moved this from Backlog to In progress in MXL TSC Board Jul 7, 2025
@vt-tv vt-tv removed this from MXL TSC Board Jul 7, 2025
@vt-tv vt-tv moved this to In progress in MXL TSC Board Jul 7, 2025
@vt-tv vt-tv removed this from MXL TSC Board Jul 9, 2025
@pac-work pac-work force-pushed the rust-bindings branch 3 times, most recently from dc17eb2 to 153c93d Compare July 11, 2025 12:13
@vt-tv vt-tv moved this to In progress in MXL TSC Board Jul 31, 2025
@pedro-alves-ferreira
Copy link
Contributor

Code-wise, the branch is ready for PR (https://github.com/pac-work/mxl/tree/rust-bindings).

Still, it's missing the integration with GitHub CI.

@cwtchan submitted a PR (pac-work#5) with a proposal for a separate .yml file to build the Rust package. However, it does not run under the same Docker image as the C++ build.
Ideally, we would want the Rust build in the same environment as C++, so I've been trying to use act (https://nektosact.com/) to run the CI locally but, after having dealt with a few hiccups, I still can't get it to work (see below).

@sviengkhou and others: any help is highly appreciated.

|  > [10/13] RUN groupadd --gid "0" "devcontainer"  && useradd --uid "0" --gid "0" -m -s /bin/bash "devcontainer"  && apt-get install -y sudo  && printf '%s ALL=(root) NOPASSWD:ALL\n' "devcontainer" > "/etc/sudoers.d/devcontainer"  && chmod 0440 "/etc/sudoers.d/devcontainer":
| 0.108 groupadd: GID '0' already exists
| ------
| Dockerfile:74
| --------------------
|   73 |     # Create the user
|   74 | >>> RUN groupadd --gid "${USER_GID}" "${USERNAME}" \
|   75 | >>>  && useradd --uid "${USER_UID}" --gid "${USER_GID}" -m -s /bin/bash "${USERNAME}" \
|   76 | >>>  && apt-get install -y sudo \
|   77 | >>>  && printf '%s ALL=(root) NOPASSWD:ALL\n' "${USERNAME}" > "/etc/sudoers.d/${USERNAME}" \
|   78 | >>>  && chmod 0440 "/etc/sudoers.d/${USERNAME}"
|   79 |     
| --------------------
| ERROR: failed to build: failed to solve: process "/bin/sh -c groupadd --gid \"${USER_GID}\" \"${USERNAME}\"  && useradd --uid \"${USER_UID}\" --gid \"${USER_GID}\" -m -s /bin/bash \"${USERNAME}\"  && apt-get install -y sudo  && printf '%s ALL=(root) NOPASSWD:ALL\\n' \"${USERNAME}\" > \"/etc/sudoers.d/${USERNAME}\"  && chmod 0440 \"/etc/sudoers.d/${USERNAME}\"" did not complete successfully: exit code: 4

For some reason USER_GID is expanding to 0.

@felixpou
Copy link
Contributor

felixpou commented Aug 7, 2025

previous comment is from TSC 2025-08-07

@sviengkhou
Copy link

@pedro-alves-ferreira can you share your "act" .env file or the "act" command you are using to launch your local github action?

@pedro-alves-ferreira
Copy link
Contributor

pedro-alves-ferreira commented Aug 15, 2025 via email

@pedro-alves-ferreira
Copy link
Contributor

Hi @sviengkhou! I'm back. When you have some time to go over this, please ping me on Slack. Thanks!

@pac-work pac-work force-pushed the rust-bindings branch 2 times, most recently from 81d6dba to eb83e4e Compare August 22, 2025 10:12
@mlefebvre1
Copy link
Contributor

Is it ready to be properly reviewed or is it still in draft mode waiting for some decisions? I have Rust experience, and I would like to review whenever this is ready.

@pac-work
Copy link
Contributor Author

Is it ready to be properly reviewed or is it still in draft mode waiting for some decisions? I have Rust experience, and I would like to review whenever this is ready.

Hello @mlefebvre1, thanks for the offer and sorry for late response (IBC and stuff...).

It would be great if you can start taking a look at this. It is capable of reading and writing both audio and video, but it is far from providing the full spectrum of the C API. There are some TODOs which probably should be done before merging (like defining a strong type for timestamp), but overall, it shows where this is heading.

Nothing is set in stone, please take it with a grain of salt and look mostly for "this has to change before this can get merged".

In the future, we have hoped for async API to come, but that is really far away at this point.

Copy link
Contributor

@mlefebvre1 mlefebvre1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, there's some clippy warnings here and there you will have to solve.

.mxl_release_flow_reader(self.context.instance, self.reader)
})
{
tracing::error!("Failed to release MXL flow reader: {:?}", err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like using fields to record the error separately from the message like this:

tracing::error!(error = %err, "Failed to release MXL flow reader.")

It makes analysis of large amounts of logs a bit easier if you are set up for structured logging, but that is personal preference.

# Will be used later, when we get to higher level streams based interfaces.
futures = "0.3"
thiserror = "2.0.12"
tracing = { version = "0.1", features = ["log"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I myself am a user of the tracing library, I may not want to have all tracing events to also be emitted as log records. I would suggest to expose this as an optional feature of this library:

[features]
tracing-log = ["tracing/log"]

For this to work, this dependency needs to be moved to the mxl crates Cargo.toml

pedro-alves-ferreira and others added 24 commits October 31, 2025 13:16
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
This feature makes the MXL Rust bindings build skip building the MXL
library itself and uses the one in the main build directory of MXL
instead. It got broken after recent changes.

Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
cargo audit was being installed twice

Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
cargo audit complained about RUSTSEC-2025-0055

Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Asked on Slack for guidance regarding which licenses should be accepted.

Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
The api is now returned as an Arc, which
can be cloned.

Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
Signed-off-by: Pedro Ferreira <pedro@bisect.pt>
- Forks do not have enough permissions to do so.

Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
Signed-off-by: Pavel Cernohorsky <pavel.cernohorsky@appear.net>
@vt-tv vt-tv merged commit 3874cdc into dmf-mxl:main Nov 7, 2025
1 check passed
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.

Implement Rust bindings for MXL

8 participants