Skip to content

Refactor COMMS Library into Rust for Custom Binary Protocols #4

@DonavanMartin

Description

@DonavanMartin

Description

This issue proposes refactoring the COMMS Library, a C++11 headers-only library for implementing custom binary communication protocols, into Rust. The goal is to create a Rust-native implementation (comms-rs) that preserves COMMS’s functionality (e.g., declarative protocol definitions, embedded system support) while leveraging Rust’s memory safety, concurrency, and modern ecosystem to enhance reliability and developer experience in industrial and embedded applications.

Motivation

  • No Rust Equivalent: As of June 2025, there is no direct Rust library matching COMMS’s declarative, embedded-focused approach for custom binary protocols.
  • Safety: Rust eliminates C++ issues like undefined behavior, memory leaks, and buffer overflows, critical for reliable protocol implementation in embedded systems.
  • Performance: Rust’s performance is comparable to C++, suitable for resource-constrained environments.
  • Ecosystem: Integration with Rust crates (e.g., byteorder, nom) can modernize COMMS for IoT and industrial use cases.

Goals

  • Develop a Rust-native comms-rs library supporting core COMMS features (e.g., message/field definitions, serialization/deserialization, transport framing).
  • Ensure compatibility with embedded systems using no_std for minimal resource usage.
  • Provide idiomatic Rust APIs that are safe and easy to use.
  • Support cross-platform use (Linux, Windows, RTOS).

Non-Goals

  • Replacing the C++ implementation (Rust version can coexist).
  • Adding new features beyond the current COMMS functionality.

Proposed Approach

Setup:

  • Create a new repo (comms-rs) or Rust submodule in comms.
  • Use cargo and Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license (matching COMMS).

Implementation:

  • Port COMMS’s declarative protocol framework to Rust using macros or DSL-like APIs (e.g., inspired by nom or serde).
  • Implement message parsing, serialization, and transport framing with safe abstractions.
  • Ensure no_std compatibility, avoiding RTTI and exceptions.

Testing:

  • Unit tests with cargo test for protocol logic.
  • Integration tests with sample protocols (e.g., from COMMS examples).

Documentation:

Rustdoc and examples for defining custom binary protocols (e.g., IoT sensor data).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions