Source package · Trusted Rust host
Learn CoAkka Runtime with Rust + Tauri
Rust owns the runtime and typed outcomes. In Tauri, the WebView only sends a bounded intent; the trusted Rust host authorizes, admits and calls CoAkka Runtime. Both 3.3.2 archives are checksum-pinned source packages, not crates.io packages.
Beginner · 01 / 03
Install the verified Rust source package
The archive carries crate source, a lockfile and five Core images. Keep --locked; do not turn it into a crates.io dependency that does not exist. The learning project sits beside the archive and uses a path dependency so the original package stays unchanged.
rustc --version
cargo --versioncurl -fL -o coakka-runtime-rs-3.3.2.tar.gz \
'https://raw.githubusercontent.com/phuong-tran/coakka-publish/2698310797bc1b95e3820382ea17e446ed1f7310/coakka-runtime/rust/releases/3.3.2%2B16bdd692faf918d1a959c073ad20318392659f4b/coakka-runtime-rs-3.3.2.tar.gz'
printf '%s %s\n' \
'aa0be816a4876887b386c329f4659dbc60e1e8f4e689fa2b19f36e56eeb5f1e0' \
'coakka-runtime-rs-3.3.2.tar.gz' | shasum -a 256 -c -
tar -xzf coakka-runtime-rs-3.3.2.tar.gz[package]
name = "coakka-rust-demo"
version = "0.1.0"
edition = "2021"
rust-version = "1.77.2"
publish = false
[dependencies]
coakka-runtime-rs = { path = "../coakka-runtime-rs-3.3.2" }
Package 3.3.2 uses Core 3.3, connector revision 2, and declares Rust 1.77.2 as its MSRV.
Beginner · 02 / 03
Register a handler and ask in one process
Create coakka-rust-demo/src/bin alongside the extracted archive directory. Put Cargo.toml at the project root and save first_run.rs in src/bin. Run the commands from the directory containing the project. RuntimeHost is the owner; when its last owner drops, the connector stops the native runtime.
use std::time::Duration;
use coakka_runtime::{ConnectorStartSpec, DeliveryHint, PayloadIdentity, RouteSpec, RuntimeHost};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let target = "hello.accept";
let mut spec = ConnectorStartSpec::new("hello-rust", "hello-rust-1");
spec.routes = vec![RouteSpec::single_local(target, "127.0.0.1", 19_191)];
let runtime = RuntimeHost::start(spec)?;
runtime.register_handler(target, |request| {
RuntimeHost::make_json_reply_from_request_identity(
&request,
"hello.accept",
r#"{"accepted":true}"#,
)
.ok()
})?;
let reply = runtime.ask_json(
"hello-client",
target,
r#"{"message":"hello"}"#,
PayloadIdentity::json("hello.accept.request.v1", 1),
Duration::from_secs(2),
"accept",
DeliveryHint::RequireLocal,
)?;
println!("{}", reply.payload_utf8());
Ok(())
}
cd coakka-rust-demo
cargo generate-lockfile --offline
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) COAKKA_PLATFORM=macos-aarch64 ;;
Linux-aarch64|Linux-arm64) COAKKA_PLATFORM=linux-aarch64 ;;
Linux-x86_64) COAKKA_PLATFORM=linux-x86_64 ;;
*) echo "Use the platform recipe in CONSUMING.md"; exit 1 ;;
esac
export CARGO_TARGET_DIR="$(pwd)/target"
cargo build --locked --release --bin first_run
if [ ! -d "$CARGO_TARGET_DIR/release/native/$COAKKA_PLATFORM" ]; then
python3 ../coakka-runtime-rs-3.3.2/tools/package_tools.py deploy \
../coakka-runtime-rs-3.3.2 "$CARGO_TARGET_DIR/release/first_run" \
"$COAKKA_PLATFORM"
fi
"$CARGO_TARGET_DIR/release/first_run"Expected result
{"accepted":true}PayloadIdentity::json- Message type, schema version and JSON format travel with the payload.
DeliveryHint::RequireLocal- The Embedded lesson's intent; it is not a route strategy or retry policy.
Duration- A monotonic boundary wait window; terminal matching remains Core-owned.
Beginner · 03 / 03
Read a typed deadletter
Do not parse error text. Match CoAkkaError::Deadletter, then read the Core-issued reason and original envelope.
use std::time::Duration;
use coakka_runtime::{CoAkkaError, ConnectorStartSpec, DeliveryHint, PayloadIdentity, RuntimeHost};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let runtime = RuntimeHost::start(ConnectorStartSpec::new("orders-rust", "orders-rust-1"))?;
let result = runtime.ask_json(
"checkout",
"orders.missing",
r#"{"quantity":2}"#,
PayloadIdentity::json("orders.quote.request.v1", 1),
Duration::from_secs(2),
"quote",
DeliveryHint::RequireLocal,
);
match result {
Err(CoAkkaError::Deadletter(deadletter)) => {
println!(
"deadletter reason={} target={}",
deadletter.reason, deadletter.original.target
);
Ok(())
}
Err(error) => Err(error.into()),
Ok(_) => Err("expected route-miss deadletter".into()),
}
}
cd coakka-rust-demo
cargo generate-lockfile --offline
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) COAKKA_PLATFORM=macos-aarch64 ;;
Linux-aarch64|Linux-arm64) COAKKA_PLATFORM=linux-aarch64 ;;
Linux-x86_64) COAKKA_PLATFORM=linux-x86_64 ;;
*) echo "Use the platform recipe in CONSUMING.md"; exit 1 ;;
esac
export CARGO_TARGET_DIR="$(pwd)/target"
cargo build --locked --release --bin route_miss
if [ ! -d "$CARGO_TARGET_DIR/release/native/$COAKKA_PLATFORM" ]; then
python3 ../coakka-runtime-rs-3.3.2/tools/package_tools.py deploy \
../coakka-runtime-rs-3.3.2 "$CARGO_TARGET_DIR/release/route_miss" \
"$COAKKA_PLATFORM"
fi
"$CARGO_TARGET_DIR/release/route_miss"Expected result
deadletter reason=DEADLETTER_REASON_ROUTE_MISS target=orders.missing
Advanced · 04
Put the Tauri WebView behind an intent boundary
Download and verify the Tauri archive. Create coakka-tauri-demo/src alongside the extracted directory. Save Cargo.toml at the project root and the sample as src/main.rs. Run the commands from the directory containing the project. The WebView receives no raw runtime handle, file path or bearer grant.
curl -fL -o coakka-runtime-tauri-intents-3.3.2-source.tar.gz \
'https://raw.githubusercontent.com/phuong-tran/coakka-publish/cedac82c4346b1a219cb5428474984fb2afaeb88/coakka-runtime/tauri/releases/3.3.2%2B16bdd692faf918d1a959c073ad20318392659f4b/coakka-runtime-tauri-intents-3.3.2-source.tar.gz'
printf '%s %s\n' \
'ffe3a7621b2f3522b0a175063e4141f9e8369dd26a11d4c562be8fbee472f29d' \
'coakka-runtime-tauri-intents-3.3.2-source.tar.gz' | shasum -a 256 -c -
tar -xzf coakka-runtime-tauri-intents-3.3.2-source.tar.gz[package]
name = "coakka-tauri-demo"
version = "0.1.0"
edition = "2021"
rust-version = "1.77.2"
publish = false
[dependencies]
coakka-runtime-rs = { path = "../coakka-runtime-tauri-intents-3.3.2-source/rust" }
coakka-tauri-intents = { path = "../coakka-runtime-tauri-intents-3.3.2-source/tauri-intents" }
serde_json = "=1.0.151"
use coakka_runtime::{ConnectorStartSpec, RouteSpec};
use coakka_tauri_intents::{
coakka_ask_intent_command, IntentEnvelope, IntentPayloadIdentity, RuntimeIntentDispatcher,
};
use serde_json::json;
use std::collections::HashMap;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let target = "desktop.quote";
let mut spec = ConnectorStartSpec::new("desktop", "desktop-1");
spec.routes = vec![RouteSpec::single_local(target, "127.0.0.1", 19_411)];
let dispatcher = RuntimeIntentDispatcher::start(spec)?;
dispatcher.register_json_handler(target, |request| {
let quantity = request.payload["quantity"].as_u64().unwrap_or(0);
Ok(json!({"quote": quantity * 120_000, "currency": "VND"}))
})?;
let result = coakka_ask_intent_command(
&dispatcher,
IntentEnvelope {
intent_id: "quote-1".into(),
source: "trusted-main-window".into(),
target: target.into(),
operation: "quote".into(),
payload: json!({"quantity": 2}),
payload_identity: IntentPayloadIdentity::json("desktop.quote.request.v1", 1),
timeout_ms: Some(2_000),
headers: HashMap::new(),
},
)?;
println!("{}", result.payload);
Ok(())
}
cp coakka-runtime-tauri-intents-3.3.2-source/tauri-intents/Cargo.lock \
coakka-tauri-demo/Cargo.lock
cd coakka-tauri-demo
cargo update --workspace
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) COAKKA_PLATFORM=macos-aarch64 ;;
Linux-aarch64|Linux-arm64) COAKKA_PLATFORM=linux-aarch64 ;;
Linux-x86_64) COAKKA_PLATFORM=linux-x86_64 ;;
*) echo "Use the platform recipe in rust/CONSUMING.md"; exit 1 ;;
esac
export CARGO_TARGET_DIR="$(pwd)/target"
cargo build --locked --release
python3 ../coakka-runtime-tauri-intents-3.3.2-source/rust/tools/package_tools.py deploy \
../coakka-runtime-tauri-intents-3.3.2-source/rust \
"$CARGO_TARGET_DIR/release/coakka-tauri-demo" "$COAKKA_PLATFORM"
"$CARGO_TARGET_DIR/release/coakka-tauri-demo"Expected result
{"currency":"VND","quote":240000}A real command authorizes the window/frame, bounds concurrent operations, runs blocking asks off the UI thread, and joins accepted work before dropping the dispatcher.
Advanced · 05
Read the support tuple accurately
Rust execution evidence covers macOS ARM64, Pi Linux ARM64, WSL2 Linux x64, Windows x64 and Windows ARM64 UTM. The Portal’s Tauri exercise runs the command from a Rust program. For the WebView and platform checks, see the Tauri 3.3.2 release record.
File Lane and Stream Lane stay in the trusted Rust host. The WebView intent API exposes no path, callback or owner grant.