motorcortex-rust 0.5.0

Motorcortex Rust: a Rust client for the Motorcortex Core real-time control system (async + blocking).
Documentation
/// Represents a trait for associating a unique, compile-time constant hash with a type.
pub trait Hash {
    const HASH: u32;
}

/// Retrieve a compile-time constant hash for a message type.
///
/// This hash uniquely identifies the type and can be used for version tracking,
/// serialization metadata, or message validation in distributed environments.
///
/// Usage:
/// ```
/// use motorcortex_rust::get_hash;
/// use motorcortex_rust::SessionTokenMsg;
///
/// fn main() {
///     let hash = get_hash::<SessionTokenMsg>();
///     println!("Hash for SessionTokenMsg: {hash:#x}");
/// }
/// ```
pub fn get_hash<T: Hash>() -> u32 {
    T::HASH
}

/// Retrieve the size, in bytes, of a compile-time constant hash used in the system.
///
/// # Returns
/// - A `u32` value representing the size of the constant hash (currently always 4).
///
/// # Usage
/// ```
/// use motorcortex_rust::get_hash_size;
///
/// fn main() {
///     let size = get_hash_size();
///     println!("Hash size: {size} bytes");
/// }
/// ```
pub fn get_hash_size() -> usize {
    size_of::<u32>()
}