Skip to main content

open_session

Function open_session 

Source
pub fn open_session(
    locator: &str,
    mode: SessionMode,
    domain_id: u32,
    node_name: &str,
    rmw: Option<&str>,
) -> Result<RmwSession, TransportError>
Expand description

Open a new middleware session.

Wraps the backend-specific session constructor behind a common signature. Used by the C API (nros-c); Rust users should prefer Executor::open().

Phase 156 — takes an explicit primary backend by name, mirroring what Executor::open does for Rust callers. Without it, C bridges built with two linked backends (e.g. xrce + dds) get whichever ctor fires first — non-deterministic across link orderings, and often the wrong backend for the bridge’s intended primary.

Issue 1050 defect (3) — rmw is the RESOLVED selector, not a second reading of the environment. This function used to consult rmw_selector() itself, which made it the tree’s second answer to “which backend?” and blind to every rung but the environment: a C image with a BAKED selector had it discarded here. The caller resolves the whole ladder (env > baked > none) through ExecutorConfig and passes the result; None means the registry must hold exactly one backend, which nros_rmw_cffi::get_vtable now enforces rather than assumes.