Skip to content

ZettaScaleLabs/zenoh-nostd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zenoh-nostd

Zero Network Overhead. No std. No alloc. Pure Rust.

bare-metalno_stdzenoh

CLA assistant

📦 Overview

⚠️ This project is in early development.

zenoh-nostd is a Rust-native, #![no_std], no_alloc library that provides a zero-overhead network abstraction layer for ultra-constrained and bare-metal environments. In other terms you can run this bare metal on your favourite microcontroller.

⚡ Built on the Zenoh protocol, but stripped to the bone for minimalism and raw performance.


✨ Features

  • #![no_std]: No reliance on the Rust standard library.
  • No dynamic allocation: Fully no_alloc, ideal for bare-metal targets.
  • Deterministic: No heap, no surprises.
  • Safe Rust: Entirely memory-safe.
  • Testable: Supports both embedded and native testing environments.

🚀 Use Cases

Soon.


🔧 Installation

Add this to your Cargo.toml:

[dependencies]
zenoh-nostd = { git = "https://github.com/ZettaScaleLabs/zenoh-nostd" }

For embedded systems, ensure your crate uses #![no_std]:

#![no_std]

🔌 Integration

Minimal Example

Here’s a simple example of sending a payload with zenoh-nostd:

async fn entry(spawner: embassy_executor::Spawner) -> zenoh_nostd::result::ZResult<()> {
    let mut session = zenoh_nostd::open!(
        zenoh_nostd::zconfig!(
                PlatformStd: (spawner, PlatformStd {}),
                TX: 512,
                RX: 512,
                MAX_SUBSCRIBERS: 2
                MAX_QUERIES: 2,
                MAX_QUERYABLES: 2
        ),
        EndPoint::try_from(CONNECT.unwrap_or("tcp/127.0.0.1:7447"))?
    );

    let ke = keyexpr::new("demo/example")?;
    let payload = b"Hello, from std!";

    session.put(ke, payload).await?;
}

🔬 MSRV

🛠️ Minimum Supported Rust Version: Currently 1.90.0


⚠️ Limitations

  • No serial support yet. (#11)
  • No alloc support yet. (#20)

🧪 Building and Testing

This project uses just for task management. Use just clippy to check the project and examples, just test to run the tests and just bench to run the benchmarks.

🔍 Pull requests that slow down the bench should be avoided.

Testing Examples

Use the following command structure:

just <platform> <example> [args]
  • Platforms: std, wasm, esp32s3
  • Examples: z_put, z_pub, z_sub, z_ping, z_pong, z_get, z_queryable

Set the CONNECT=<endpoint> environment variable to specify the endpoint (default is tcp/127.0.0.1:7447).

For esp32s3, you must also provide:

  • WIFI_SSID (default is ZettaScale).
  • WIFI_PASSWORD (no default, must be provided).

See the ESP32 setup documentation for toolchain and target installation.

Example of few commands:

CONNECT=tcp/127.0.0.1:7447 just std z_pub
WIFI_PASSWORD=Abcdef12345 CONNECT=tcp/192.168.21.1:7447 just esp32s3 z_sub

Example: Local TCP

Run a Zenoh router with:

zenohd -l tcp/127.0.0.1:7447

In two terminals:

# Terminal 1
just std z_pub

# Terminal 2
just std z_sub

Example: WebSocket + WASM

Run a Zenoh router with:

zenohd -l tcp/127.0.0.1:7447 -l ws/127.0.0.1:7446

Then:

# Terminal 1 (WASM)
CONNECT=ws/127.0.0.1:7446 just wasm z_pub

# Terminal 2 (STD)
just std z_sub

📦 Note: For WASM, ensure you have:

  • wasm32-unknown-unknown target
  • wasm-bindgen-cli
  • basic-http-server (or similar)

📁 Project Layout

zenoh-nostd/            # Git repository root
├── crates/
│   ├── zenoh-derive/   # Derive macros
│   ├── zenoh-nostd/    # Zenoh with IO, embassy
│   ├── zenoh-proto/    # Zenoh Protocol
│   └── zenoh-sansio/   # Zenoh Sans IO
│       └── examples
│           ├── z_get.rs        # Example without io (example with tcp)
│           ├── z_ping.rs       # Example without io (example with tcp)
│           ├── z_pong.rs       # Example without io (example with tcp)
│           ├── z_put.rs        # Example without io (example with tcp)
│           └── z_sub.rs        # Example without io (example with tcp)
│
├── examples/
│   ├── z_get.rs        # Example with io
│   ├── z_ping.rs       # Example with io
│   ├── z_pong.rs       # Example with io
│   ├── z_pub.rs        # Example with io
│   ├── z_put.rs        # Example with io
│   ├── z_queryable.rs  # Example with io
│   └── z_sub.rs        # Example with io
│
├── platforms/          # Platform-specific implementations
│   ├── zenoh-embassy/  # Embassy platforms (no_std)
│   ├── zenoh-std/      # Standard platforms (std)
│   └── zenoh-wasm/     # WASM32 platforms (wasm)
│
├── Cargo.toml          # Workspace + example package
└── src/
    └── lib.rs          # Example lib.rs

📚 Documentation

The base project has been implemented in (#6)

📖 Note: Docs require rustdoc to be run with --no-default-features.

Build locally with:

cargo doc --no-deps --no-default-features --open

📄 License

Licensed under:

  • ZettaScale Source-Available LICENSE

About

A no-std implementation of Zenoh.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 5