Skip to main content

hara_native/instrumentation/
native_identity.rs

1//! Trusted host binding for opaque instrumentation target identities.
2//!
3//! Session products such as `LiveSession` expose only a target id and
4//! generation in their bounded reply payloads. This module lets the embedding
5//! host turn that identity back into a fenced native handle without receiving
6//! the evaluator, bytecode machine, or the Runtime-owned hub.
7
8use super::model::TargetHandle;
9use super::native::{NativeInstrumentation, NativeInstrumentationError, NativeTargetHandle};
10
11impl NativeInstrumentation {
12    /// Binds one opaque target identity obtained from a trusted Session surface.
13    ///
14    /// The generation is mandatory: a stale identity must not bind a
15    /// replacement target that later reuses the same id. Resolution still
16    /// applies the service's Runtime and Session fences before returning an
17    /// opaque native target handle.
18    pub fn bind_target_identity(
19        &self,
20        target_id: impl Into<String>,
21        generation: u64,
22    ) -> Result<NativeTargetHandle, NativeInstrumentationError> {
23        self.bind_target(&TargetHandle::new(target_id.into(), generation))
24    }
25}
26
27#[cfg(test)]
28#[path = "native_identity/tests.rs"]
29mod tests;
30
31#[cfg(all(test, feature = "whole-wasm", not(target_arch = "wasm32")))]
32#[path = "native_identity/whole_wasm_tests.rs"]
33mod whole_wasm_tests;