VLC 4.0.0-dev
|
libvlccore provide Rust bindings so as to interface with the core implementation in C and implement VLC plugins in Rust as a crate.
The bindings are located in the src/rust/
folder for everything which is mapping headers from include/vlc_*.h
. There's no module-specific crate for now, but those would be located in modules/
.
New core crate needs to be placed into the src/rust/
directory. They usually match with another C vlc_*.h
header. For instance vlc_tick.h
will match with the src/rust/vlcrs-tick
crate.
Cargo manifest for the workspace at src/rust/Cargo.toml
needs to be updated to account for the new crate.
A core crate might depend on another core crate, in particular when a vlc_*.h
header is depending on another header or uses forward declarations.
In that case, the Cargo.toml from this crate should directly reference the other crate using a path locator.
Finally, if the new crate is meant to be available from modules, it should also be added to the modules/Cargo.toml
workspace file using a path locator, inside the workspace dependencies.
To create a new module, create a new crate inside the relevant moduledir
folder from modules/
folder using Cargo, ending with -rs
and without version control creation given that VLC sources are already versioned:
For instance, a new video filter would be created with:
Then, you can modify the Cargo.toml file to include the different crates the module will be using from the workspace.
The module will need to be listed into modules/Cargo.toml
members:
Then you can add the plugin to the buildsystems. For automake, check the parent Makefile.am or create a new one depending on how crowded it is, and add:
For meson, you will use the vlc_rust_modules
dictionary from the parent meson.build file:
Creating a new plugin requires the definition of the plugin manifest to expose the different modules from there. This is done through the module!{}
macro: