Skip to content

docs(eventhubs): add C++ FFI interop guide#4614

Draft
j7nw4r wants to merge 1 commit into
Azure:mainfrom
j7nw4r:eventhubs-cpp-interop-doc
Draft

docs(eventhubs): add C++ FFI interop guide#4614
j7nw4r wants to merge 1 commit into
Azure:mainfrom
j7nw4r:eventhubs-cpp-interop-doc

Conversation

@j7nw4r

@j7nw4r j7nw4r commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Adds sdk/eventhubs/azure_messaging_eventhubs/docs/cpp_interop.md, a reference guide for consuming the Rust Event Hubs SDK from a modern C++ (C++20) application through a Rust extern "C" FFI shim.

Motivation

azure_messaging_eventhubs is a pure-Rust crate with an async API and no C ABI, so it cannot be linked from C++ directly. There was no documentation describing the FFI path. The guide fills that gap and serves as a template for building such a shim.

Changes

  • New doc with eight sections: why a shim is required, architecture, the Rust FFI shim crate, cbindgen header generation, the modern C++ RAII wrapper, a complete sample program, build/link (CMake) instructions, and a safety/threading/lifetime contract.
  • Shim covers the producer (open/send_event/close), consumer, and receiver paths against the real crate API, including a process-wide Tokio runtime, opaque handles, an errno-style thread-local error channel, and catch_unwind panic guards.
  • Documents the self-referential receiver problem (stream_events(&self) borrows the receiver) and a sound resolution via boxing plus struct field drop order, with ouroboros/self_cell noted as safe alternatives.
  • C++ layer uses unique_ptr RAII handles, status-codes-to-exceptions, std::string_view in and std::span<const std::byte> out.

Documentation only; no code or build changes.

@j7nw4r j7nw4r force-pushed the eventhubs-cpp-interop-doc branch from fc1daad to 9ff9c76 Compare June 17, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant