Skip to content

EldarErel/norm-rust

Repository files navigation

NORM Rust Bindings

Safe Rust bindings to the NORM (NACK-Oriented Reliable Multicast) C library.

Features

  • Safe, idiomatic Rust API
  • Automatic C library compilation via build.rs
  • Cross-platform support (Linux, macOS, Windows)
  • Type-safe enums for NORM events and configuration
  • Zero-copy data access

Quick Start

git submodule update --init --recursive
cargo build
cargo run --example hello

Usage

use norm::{NormInstance, NormEventType, Result, object_get_data};

fn main() -> Result<()> {
    let instance = NormInstance::new()?;
    
    // Create sender
    let sender = instance.create_session("224.1.2.3", 6003, 1)?;
    sender.set_multicast_loopback(true)?;
    sender.start_sender(1, 1024 * 1024, 1400, 64, 16, 2)?;
    sender.data_enqueue(b"Hello, World!", b"")?;
    
    // Create receiver
    let receiver = instance.create_session("224.1.2.3", 6003, 2)?;
    receiver.start_receiver(1024 * 1024)?;
    
    // Process events
    while let Some(event) = instance.get_next_event(false) {
        if let Some(event_type) = NormEventType::from_raw(event.type_) {
            if event_type == NormEventType::RxObjectCompleted {
                if let Some(data) = unsafe { object_get_data(event.object) } {
                    println!("Received: {:?}", data);
                }
            }
        }
    }
    
    Ok(())
}

Examples

  • hello - Basic send/receive example
  • async - Descriptor-based I/O with select()

Run with: cargo run --example <name>

Requirements

  • Rust 1.70+
  • C++ compiler (g++, clang++, or MSVC)
  • libclang (for bindgen)

Platform Support

  • Linux: Full support (epoll-based I/O)
  • macOS: Full support (kqueue-based I/O)
  • Windows: Partial support (requires Windows-specific NORM sources)

Development

make all        # Format, lint, test, and build
make test       # Run tests
make lint       # Run linter

Project Structure

norm/           # High-level safe Rust API
norm-sys/       # Low-level FFI bindings
examples/       # Example applications

License

MIT License for Rust bindings. The bundled NORM C library is licensed under the NRL (Naval Research Laboratory) license. See LICENSE for details.

About

Safe Rust bindings for NORM (NACK-Oriented Reliable Multicast)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors