Async Rust client for the Rust+ Game API. Connect to Rust game servers, control smart devices, monitor team chat, and receive real-time events through the official companion app protocol.
⚠️ Unofficial library. Not affiliated with Facepunch Studios.
- 🔌 WebSocket connection with automatic reconnect-friendly design
- 📦 Type-safe wrappers around protobuf messages
- 🎯 Typed event system (chat, team changes, entity updates)
- ⏱️ Built-in dual-tier rate limiter (server + socket level)
- 🔁 Automatic retry on
rate_limiterrors - 🚀 Builder pattern for clean configuration
- ⚡ Async/await with Tokio
[dependencies]
rustplus = "0.1"
tokio = { version = "1", features = ["full"] }use rustplus::RustSocket;
#[tokio::main]
async fn main() -> Result<(), rustplus::Error> {
let mut socket = RustSocket::builder()
.ip("YOUR_SERVER_IP") // String
.port(28082) // u16
.player_id(76561199000000000) // u64
.player_token(123456) // i32
.build()?;
socket.connect().await?;
// Get server info
let info = socket.get_info().await?;
println!("Server: {} ({}/{})", info.name, info.players, info.max_players);
// Send a team chat message
socket.send_team_message("Hello from Rust!".to_string()).await?;
// Listen for events
let mut events = socket.events();
while let Some(event) = events.next().await {
match event {
rustplus::RustEvent::TeamMessage(msg) => {
println!("[CHAT] {}: {}", msg.name, msg.message);
}
rustplus::RustEvent::EntityChanged { entity_id, payload } => {
println!("Entity {} -> value={}", entity_id, payload.value);
}
_ => {}
}
}
Ok(())
}To use this library, you will need a player_id (Steam ID) and a player_token.
You can obtain these by pairing with the Rust server via an extension created by the brilliant Ollie. See the pairing guide.
See the examples/ directory for runnable examples:
ws_connection.rs— basic connection andget_infotry_spam.rs— rate limiter demonstration (70 sequential requests)listen_events.rs— listen for real-time team/entity eventscontrol_switch.rs— toggle a Smart Switch device
Run with:
cargo run --example ws_connectionInspired by the Python rustplus library by olijeffers0n. Protocol definitions taken from the official companion app.
Contributions welcome! Please open an issue or PR. By contributing you agree that your contributions will be licensed under the AGPL-3.0.
This project is licensed under the GNU AGPL v3.0 — see the LICENSE file for details.