- TypeScript 51.2%
- Rust 48.2%
- Nix 0.6%
| core | ||
| native | ||
| tauri | ||
| web | ||
| .gitignore | ||
| bun.lock | ||
| Cargo.lock | ||
| Cargo.toml | ||
| eslint.config.ts | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| ttp-codec.json | ||
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 implementationnative/platform/native integrationscli/in progress CLI to en-/decode TTP messagestauri/Tauri v2 plugin that exposes a long-lived native TTP connection to Rust and the frontendweb/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:
createTransportClientuses WebTransport directly. - Tauri frontend:
createTransportClientdetects Tauri and uses the Rust-owned backend connection through Tauri commands and aChannel. - 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"
]
}