Skip to content

Rust Core Library (connekt-core) ​

Embed the entire Connekt Hub directly inside any async Rust application (tokio) with zero GUI or CLI overhead.

Installation (crates.io) ​

bash
cargo add connekt-core

Quick Start ​

rust
use std::time::Duration;
use connekt_core::{AdbConfig, ConnektHub, Payload, StreamMeta, UsbmuxConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let hub = ConnektHub::builder()
        .with_adb(AdbConfig::default())
        .with_usbmux(UsbmuxConfig::default())
        .start()
        .await?;

    // Subscribe to incoming messages
    let _msg_sub = hub.channel("telemetry").on_message(|msg| async move {
        println!("[{}] {}", msg.src, msg.payload.as_text());
    }).await;

    // Handle incoming RPC requests from mobile / web peers
    let _req_sub = hub.channel("echo").on_request(|req| async move {
        Ok(Payload::from(format!("rust-echo:{}", req.payload.as_text())))
    }).await;

    // List connected peers
    let peers = hub.list_peers().await;
    if let Some(peer) = peers.first() {
        // 1. Multicast / unicast message
        hub.channel("notice").send(&peer.peer_id, "sync").await?;

        // 2. Request / Response
        let resp = hub
            .channel("ping")
            .request(&peer.peer_id, "hello", Duration::from_secs(5))
            .await?;
        println!("Reply: {}", resp.as_text());

        // 3. Binary Stream
        let meta = StreamMeta::from([("mime".into(), "image/png".into())]);
        let mut stream = hub.channel("files").open_stream(&peer.peer_id, meta).await?;
        stream.write(png_bytes).await?;
        stream.close().await?;
    }

    hub.shutdown();
    Ok(())
}

Standalone Binary (connekt-hub) ​

If you prefer an out-of-process Sidecar or want the built-in Web Debugger, download connekt-hub or connekt-hub-headless from GitHub Releases or build from source:

bash
make server           # Full Hub + Web Debugger (:9527)
make server-headless  # Pure headless Sidecar (--no-default-features)

Released under the MIT License.