High-performance data bridge for Tauri apps. Data transfer between Rust and JavaScript.
A memio region is the shared data area that Memio creates between the Rust backend and the WebView frontend.
The implementation varies by platform (for example, /dev/shm on Linux, ASharedMemory on Android, or a Windows file mapping / SharedBuffer), but the API stays the same.
See Building and Running for complete setup instructions.
| Platform | Supported |
|---|---|
| Linux | ✓ |
| Windows | ✓ |
| Android | ✓ |
| macOS | x |
| iOS | x |
Quick install:
# src-tauri/Cargo.toml
[dependencies]
memio = { path = "path/to/memioTauri/crates/memio" }// package.json
{
"dependencies": {
"memio-client": "file:path/to/memioTauri/guest-js/memio-client"
}
}Rust:
use memio::prelude::*;
// Create memio buffer
let manager = MemioManager::new()?;
manager.create_buffer("state", 1024 * 1024)?; // 1MB
// Write data (version provided by caller)
let data = b"Hello from Rust!";
manager.write("state", 1, data)?;JavaScript:
import { MemioClient } from 'memio-client';
const memio = new MemioClient();
// Wait for buffer to be ready
await memio.waitForSharedMemory('state');
// Read data (async for Android, sync for desktop)
const snapshot = await memio.readSharedStateAsync();
if (snapshot) {
console.log('Version:', snapshot.version);
console.log('Data:', new TextDecoder().decode(snapshot.data));
}JavaScript:
import { MemioClient } from 'memio-client';
const memio = new MemioClient();
// Write data to memio region
const data = new TextEncoder().encode('Hello from JS!');
memio.writeSharedState(data);Rust:
use memio::prelude::*;
let manager = MemioManager::new()?;
// Read data written by frontend
let result = manager.read("state")?;
println!("Version: {}", result.version);
println!("Data: {:?}", String::from_utf8_lossy(&result.data));The goal is: the client only enables the Memio plugin, and Memio handles the platform-specific details (Android vs desktop).
- Register the plugin in your Rust app:
tauri::Builder::default()
.plugin(memio::plugin::init())
.invoke_handler(tauri::generate_handler![
// your app commands...
])
.run(tauri::generate_context!())?;- Allow only the Memio plugin in capabilities:
// src-tauri/capabilities/default.json
[
{
"identifier": "desktop",
"description": "Desktop permissions for the app",
"windows": ["main"],
"local": true,
"remote": {
"urls": ["http://tauri.localhost/*", "https://tauri.localhost/*"]
},
"permissions": ["memio:default"],
"platforms": ["linux", "windows", "macOS"]
},
{
"identifier": "android",
"description": "Android permissions for the app (about:* webview bootstrap)",
"windows": ["main"],
"local": true,
"remote": {
"urls": ["about:*"]
},
"permissions": ["memio:default"],
"platforms": ["android"]
}
]- Reference the capabilities in
tauri.conf.json:
{
"app": {
"security": {
"capabilities": ["desktop", "android"]
}
}
}This keeps the client config minimal while still allowing the Android WebView
bootstrap URL (about:blank) to access the Memio commands.
- Building and Running - Setup and installation
- Linux Architecture - WebKit extension + mmap
- Android Architecture - memio:// protocol + JNI
- Architecture Overview - Technical details
MIT