Platform Compatibility
Relevant source files
The following files were used as context for generating this wiki page:
The Tauri Centrifugo plugin is designed as a cross-platform bridge between a Tauri application (frontend and backend) and a Centrifugo server. It leverages the Rust-based tokio-centrifuge library to provide real-time WebSocket communication across desktop and mobile environments.
The scope of compatibility encompasses the Rust backend implementation, which handles the core protocol logic, and the JavaScript/TypeScript API, which provides a unified interface for the frontend regardless of the underlying operating system.
Sources: README.md:14-22, src/lib.rs:5-15
Supported Platforms
The plugin supports all major operating systems supported by the Tauri framework. This is made possible by the use of cross-platform Rust dependencies like tokio and serde.
| Platform | Supported |
|---|---|
| Linux | ✓ |
| Windows | ✓ |
| macOS | ✓ |
| Android | ✓ |
| iOS | ✓ |
Sources: README.md:58-64, CHANGELOG.md:14-14
Architecture for Cross-Platform Support
The plugin's architecture ensures compatibility by abstracting Centrifugo's complex WebSocket and protocol logic into a Rust-based core. This core interacts with the Tauri Manager to broadcast events to the frontend across different platform runtimes.
The diagram shows the flow of data from the platform-agnostic frontend through the Rust-based plugin core to the external Centrifugo server.
Sources: src/lib.rs:18-24, src/lib.rs:77-80
Backend Compatibility (Rust)
The backend is built using tauri version 2.6.2 and requires rust-version 1.77.2 or higher. It utilizes tokio for asynchronous task management, which provides a high-performance abstraction over platform-specific async IO.
Key dependencies facilitating cross-platform usage:
- tokio-centrifuge (0.2.6): Handles the raw Centrifugo protocol.
- serde (1.0): Ensures data structures are serialized consistently into JSON for the frontend.
- thiserror (2): Standardizes error reporting across platforms.
Sources: Cargo.toml:7-22, src/lib.rs:27-33
Frontend Compatibility (JavaScript/TypeScript)
The JavaScript API (tauri-plugin-centrifugo-api) is distributed as an NPM package compatible with both ESM and CommonJS modules. It requires @tauri-apps/api version 2.0.0-beta.6 or higher.
| Element | Description |
|---|---|
| Package Type | Module (ESM) |
| Main Entry | ./dist-js/index.cjs (CJS) |
| Module Entry | ./dist-js/index.js (ESM) |
| Typings | ./dist-js/index.d.ts |
Sources: package.json:17-26, package.json:36-38
Protocol Compatibility
The plugin maintains compatibility with Centrifugo servers by supporting both JSON and Protobuf protocols. This selection is configurable at runtime via the StartConfig model, allowing developers to optimize for performance (Protobuf) or ease of debugging (JSON) on different devices.
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct StartConfig {
pub url: String,
pub token: Option<String>,
pub channels: Vec<String>,
pub use_protobuf: bool, // Toggle for protocol selection
pub read_timeout: Option<u64>,
}
Sources: src/models.rs:46-59, CHANGELOG.md:11-11
Conclusion
The Tauri Centrifugo plugin provides a robust, cross-platform solution for real-time messaging. By leveraging Tauri's ability to interface between Rust and various platform-specific Webview runtimes, it ensures consistent behavior across Linux, Windows, macOS, Android, and iOS. This unified architecture allows developers to write real-time logic once and deploy it across the entire range of Tauri-supported devices.