motorcortex-rust 0.5.0

Motorcortex Rust: a Rust client for the Motorcortex Core real-time control system (async + blocking).
Documentation
use nng_c_sys::nng_init_set_parameter;
pub mod nng_init_parameter {
    pub type Type = core::ffi::c_int;
    pub const NNG_INIT_NUM_TASK_THREADS: Type = 1;
    pub const NNG_INIT_NUM_EXPIRE_THREADS: Type = 2;
    pub const NNG_INIT_NUM_POLLER_THREADS: Type = 3;
    pub const NNG_INIT_NUM_RESOLVER_THREADS: Type = 4;
    pub const NNG_INIT_MAX_TASK_THREADS: Type = 5;
    pub const NNG_INIT_MAX_EXPIRE_THREADS: Type = 6;
    pub const NNG_INIT_MAX_POLLER_THREADS: Type = 7;
}
pub fn init_threads(
    task_threads: u64,
    expire_threads: u64,
    poller_threads: u64,
    resolver_threads: u64,
) {
    // SAFETY: `nng_init_set_parameter` writes to NNG's global init
    // table. Must be called *before* the first NNG usage (otherwise
    // it's a no-op); we take `u64` values that can't violate any
    // type invariants on the C side.
    unsafe {
        nng_init_set_parameter(nng_init_parameter::NNG_INIT_NUM_TASK_THREADS, task_threads);
        nng_init_set_parameter(
            nng_init_parameter::NNG_INIT_NUM_EXPIRE_THREADS,
            expire_threads,
        );
        nng_init_set_parameter(
            nng_init_parameter::NNG_INIT_NUM_POLLER_THREADS,
            poller_threads,
        );
        nng_init_set_parameter(
            nng_init_parameter::NNG_INIT_NUM_RESOLVER_THREADS,
            resolver_threads,
        );
    }
}

pub fn init_threads_with_defaults() {
    init_threads(2, 1, 1, 1); // Minimal default values
}