hiroz 0.2.0

Native Rust ROS 2 implementation using Zenoh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use hiroz::{
    Builder, Result,
    context::{ZContext, ZContextBuilder},
};

pub fn init() {
    zenoh::init_log_from_env_or("error");
}

/// Build a context connected to a Zenoh router.
///
/// Pass an explicit endpoint (from `--endpoint`) or fall back to `tcp/127.0.0.1:7447`.
pub fn create_context(endpoint: Option<String>) -> Result<ZContext> {
    let ep = endpoint.unwrap_or_else(|| "tcp/127.0.0.1:7447".to_string());
    ZContextBuilder::default()
        .with_connect_endpoints([ep])
        .build()
}