tokio_ipc 0.1.0

Multi-protocol RPC framework built on top of tokio
Documentation
// tokio_socket/src/rpc2/protocol_id.rs - Protocol ID generation using const hashing

/// FNV-1a hash function that works in const context
pub const fn fnv1a_hash(bytes: &[u8]) -> u64 {
    let mut hash = 0xcbf29ce484222325u64; // FNV offset basis
    let mut i = 0;
    while i < bytes.len() {
        hash ^= bytes[i] as u64;
        hash = hash.wrapping_mul(0x100000001b3u64); // FNV prime
        i += 1;
    }
    hash
}

/// Generate a stable protocol ID from name and version
/// Uses top 48 bits for hash, bottom 16 bits for version
pub const fn protocol_id(name: &str, version: u32) -> u64 {
    let hash = fnv1a_hash(name.as_bytes());
    // Use top 48 bits for hash, bottom 16 bits for version
    (hash & 0xFFFFFFFF_FFFF0000) | (version as u64 & 0xFFFF)
}

/// Trait that protocols implement to provide metadata
pub trait ProtocolMetadata {
    const PROTOCOL_ID: u64;
    const PROTOCOL_NAME: &'static str;
    const PROTOCOL_CRATE: &'static str;
    const PROTOCOL_VERSION: u32;
}