| Crates.io | actor-core-client |
| lib.rs | actor-core-client |
| version | 0.9.0-rc.1 |
| created_at | 2025-03-21 09:02:42.612196+00 |
| updated_at | 2025-05-23 03:53:50.603039+00 |
| description | Rust client for ActorCore - the Stateful Serverless Framework for building AI agents, realtime apps, and game servers |
| homepage | https://actorcore.org |
| repository | https://github.com/rivet-gg/actor-core |
| max_upload_size | |
| id | 1600322 |
| size | 111,053 |
The Rust client for ActorCore, the Stateful Serverless Framework
Use this client to connect to ActorCore services from Rust applications.
Add to your Cargo.toml:
[dependencies]
actor-core-client = "0.1.0"
use actor_core_client::{client::{Client, GetOptions}, drivers::TransportKind, encoding::EncodingKind};
use serde_json::json;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a client connected to your ActorCore manager
let client = Client::new(
"http://localhost:6420".to_string(),
TransportKind::Sse,
EncodingKind::Json
);
// Connect to a chat room actor
let chat_room = client.get("chat-room", GetOptions::default()).await?;
// Listen for new messages
chat_room.on_event("newMessage", |args| {
let username = args[0].as_str().unwrap();
let message = args[1].as_str().unwrap();
println!("Message from {}: {}", username, message);
}).await;
// Send message to room
chat_room.action("sendMessage", vec![
json!("william"),
json!("All the world's a stage.")
]).await?;
// When finished
chat_room.disconnect().await;
Ok(())
}
The Rust client supports multiple transport methods:
TransportKind::Sse: Server-Sent EventsTransportKind::Ws: WebSocketsThe Rust client supports multiple encoding formats:
EncodingKind::Json: JSON encodingEncodingKind::Cbor: CBOR binary encodingApache 2.0