Nucom

Nucom provides a cross-platform implementation of the Component Object Model (COM) architecture found on the Windows platform, for C, C++, and Rust.

The project contains C/C++ code, but the Rust crates do not need a C compiler to work. Compiling the C/C++ library however does need a Rust compiler, since the IDL compiler, nuidl, is written in Rust.

Example code: Here's test code to ensure calling methods on COM classes written in C/C++/Rust from those three languages works.

How to use

From C/C++: Use the Nix package manager to get the library. The Nix flake URL for this repository is "git+https://git.dblsaiko.net/nucom". Best support is with the CMake build system, which also provides support to build IDL files, but a pkg-config file is also provided by the Nix package.

From Rust: Add the nucomcore and nuidl crates to your project. To enable auto-detection for IDL include paths, add a build.rs file with this content:

fn main() {
  nuidl::cargo::use_cargo_deps();
}

Why?

Initially this started as part of an effort to port a Windows application heavily using COM interfaces to Linux. It has since outgrown that project.

A full COM implementation is a one-stop shop for these:

Specifically for Rust, this means that in the absence of a stable Rust ABI, it can be used as that, for example as part of a plugin interface. This also doesn't limit plugin implementers to any particular language, rather, anything that can use C types could in theory be used. It's also yet another way to achieve C++ to Rust interop.

(Personally I also just think it's really neat.)

Goals

Undecided

Non-Goals

Related Projects