5 unstable releases

0.3.0 Dec 7, 2025
0.2.0 Nov 1, 2025
0.1.2 Apr 30, 2024
0.1.1 Jan 10, 2024
0.1.0 Aug 7, 2023

#235 in Audio

42 downloads per month
Used in conformal_vst_wrapper

MIT/Apache

725KB
16K SLoC

vst3-rs

Cargo Docs

The vst3 crate provides Rust bindings for the VST 3 API, generated from the original C++ headers. Abstractions are provided for manipulating COM objects and implementing COM interfaces from Rust. Beyond that, however, these bindings are unsafe, and no attempt is made to abstract over the VST 3 API itself.

Usage

Add vst3 as a dependency to your Cargo.toml:

[dependencies]
vst3 = "0.3.0"

License

This project is distributed under the terms of both the MIT license and the Apache license, version 2.0. Contributions are accepted under the same terms.


lib.rs:

The vst3 crate provides Rust bindings for the VST 3 API, generated from the original C++ headers. Abstractions are provided for manipulating COM objects and implementing COM interfaces from Rust. Beyond that, however, these bindings are unsafe, and no attempt is made to abstract over the VST 3 API itself.

Bindings

Generated bindings are primarily located in the Steinberg module. In addition to the COM interfaces, bindings include struct definitions, type aliases, constants, and enums. The module structure of the bindings mirrors the namespace structure of the original headers, with minor differences where necessary (e.g., definitions which are nested inside a C++ type SomeType will be found inside a SomeType_ module in the generated bindings).

For each COM interface IInterface in the C++ headers, the bindings include a corresponding Rust type IInterface, a virtual table struct IInterfaceVtbl, and a trait IInterfaceTrait (excluding FUnknown, for which no trait is generated). Each IInterface type also implements the Interface trait, which holds an associated constant Interface::IID specifying the GUID corresponding to that interface.

Interacting with COM objects

The ComPtr and ComRef smart pointers are provided for interacting with COM objects. These types make it safer and more convenient to call methods, cast between interfaces, and manage reference counts.

For an overview of how to properly manage ownership and reference counts using ComPtr and ComRef, see the com-scrape-types documentation.

Implementing COM interfaces from Rust

COM classes can be defined in Rust using the Class trait and the interface traits generated from the VST 3 headers, and objects of these classes can be instantiated using the ComWrapper smart pointer:

struct MyClass;

impl Class for MyClass {
    type Interfaces = (IPluginBase,);
}

impl IPluginBaseTrait for MyClass {
    unsafe fn initialize(&self, context: *mut FUnknown) -> tresult {
        kResultOk
    }

    unsafe fn terminate(&self) -> tresult {
        kResultOk
    }
}

let my_obj = ComWrapper::new(MyClass);
let ptr = my_obj.to_com_ptr::<IPluginBase>().unwrap();

For more detail on implementing COM interfaces from rust, see the com-scrape-types documentation.

Dependencies