No description
  • TypeScript 51.2%
  • Rust 48.2%
  • Nix 0.6%
Find a file
2026-06-09 20:06:35 +02:00
core [Clean] 2026-04-28 16:33:12 +02:00
native Fix a lot of stuff 2026-06-09 19:35:23 +02:00
tauri Update stuff 2026-06-09 20:06:35 +02:00
web Update stuff 2026-06-09 20:06:35 +02:00
.gitignore Added base web project, removed wasm, optimized gitignore 2026-02-25 19:25:11 +01:00
bun.lock (feat): add tauri package & adjust web package to it 2026-06-09 18:21:01 +02:00
Cargo.lock Fix a lot of stuff 2026-06-09 19:35:23 +02:00
Cargo.toml (feat): add tauri package & adjust web package to it 2026-06-09 18:21:01 +02:00
eslint.config.ts Added ttp web 2026-04-13 16:44:35 +02:00
flake.lock (feat): add tauri package & adjust web package to it 2026-06-09 18:21:01 +02:00
flake.nix (feat): add tauri package & adjust web package to it 2026-06-09 18:21:01 +02:00
LICENSE Create LICENSE 2026-02-25 10:08:49 +01:00
package.json Update stuff 2026-06-09 20:06:35 +02:00
README.md (feat): add tauri package & adjust web package to it 2026-06-09 18:21:01 +02:00
tsconfig.build.json [feat] Add built version of ttp web implementation 2026-04-13 17:23:16 +02:00
tsconfig.json [feat] Add built version of ttp web implementation 2026-04-13 17:23:16 +02:00
ttp-codec.json Global Settings 2026-06-03 15:55:24 +02:00

TTP

Tensamin Transport Protocol

TTP is a transport-layer library.

Project overview

  • TTP defines lightweight transport primitives and reference behavior for message delivery, connection management, and optional congestion control features.
  • The repository separates concerns:
    • protocol core logic (pure Rust, platform-agnostic)
    • native / platform-specific integration code (FFI, platform APIs, or optimizations)

Repository structure

  • core/ core protocol implementation
  • native/ platform/native integrations
  • cli/ in progress CLI to en-/decode TTP messages
  • tauri/ Tauri v2 plugin that exposes a long-lived native TTP connection to Rust and the frontend
  • web/ web & node implementation

Core

The core section consists of Communication Value encoding. A Communication Value consists of:

  • a Communication Type,
  • an optional sender ID,
  • an optional receiver ID,
  • an optional Message ID,
  • a Data Value of type Conatiner.

A DataValue may be:

  • a Container,
    • consists of DataTypes mapped to DataValues
  • an Array,
    • consists of DataValues
  • a Boolean,
  • a Number (rust i64),
  • a String,
  • Null.

A DataType is a 1 byte number, arbitrarily mapped to a defined name. The list of standart DataTypes mapped to their binary value can be found at core/src/data_types.rs.

Native

The Native crate creates basic communication via WTransport. It allows for communication between the Tensamin Processes.

It consists of the Connection, the Host and the Client.

The Connection is split into the Sender and Receiver. Messages can be send from one Partys Sender to the other Partys Receiver.

The Host accepts Client connection requests. The Hosts .next() function repeatedly produces Senders and Receivers when Clients connect.

The Client produces a Sender and Receiver when the .connect() function is called.

Tauri

The tauri/ crate is a Tauri v2 plugin. It creates one native TTP connection in the Tauri backend and exposes it to both Rust and the frontend.

Runtime behavior:

  • Browser or Node frontend: createTransportClient uses WebTransport directly.
  • Tauri frontend: createTransportClient detects Tauri and uses the Rust-owned backend connection through Tauri commands and a Channel.
  • Tauri backend: Rust code can access the same connection with ttp_tauri::client(...), send messages, and subscribe to specific message types.

Add the plugin to your Tauri app

Add the plugin crate to src-tauri/Cargo.toml:

[dependencies]
ttp-tauri = { path = "../path/to/ttp/tauri" }
ttp-core = { path = "../path/to/ttp/core" }

Register the plugin in src-tauri/src/main.rs:

fn main() {
    tauri::Builder::default()
        .plugin(ttp_tauri::init())
        .setup(|app| {
            let ttp = ttp_tauri::client(app.handle());

            let subscription = ttp.subscribe(
                ttp_core::CommunicationType::push_notification,
                |message| {
                    // This runs for backend-side push_notification messages.
                    println!("received push notification: {:?}", message);
                },
            );

            // Keep the subscription alive for the app lifetime.
            app.manage(subscription);

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Connect from backend Rust when you want the permanent native connection to start:

let ttp = ttp_tauri::client(app.handle());
ttp.connect("https://example.com:4433", None).await?;

Send from backend Rust:

let message = ttp_core::CommunicationValue::new(ttp_core::CommunicationType::ping);
ttp.send(message).await?;

Frontend usage

Frontend code does not need a separate Tauri-specific client. Use the normal web package API:

import { createTransportClient } from "@tensamin/ttp-core";

const client = createTransportClient(schemas, { url: "https://example.com:4433" });
await client.connect();

client.subscribePush((message) => {
  console.log("push", message);
});

When this runs inside Tauri, it uses the backend Rust connection. When it runs in a browser or Node, it uses WebTransport directly.

Tauri permissions

Allow the plugin commands in your Tauri v2 capability file, for example src-tauri/capabilities/default.json:

{
  "identifier": "default",
  "description": "Default app capability",
  "windows": ["main"],
  "permissions": [
    "ttp:allow-connect",
    "ttp:allow-send",
    "ttp:allow-close",
    "ttp:allow-ready-state"
  ]
}