actor-core-client

Crates.ioactor-core-client
lib.rsactor-core-client
version0.9.0-rc.1
created_at2025-03-21 09:02:42.612196+00
updated_at2025-05-23 03:53:50.603039+00
descriptionRust client for ActorCore - the Stateful Serverless Framework for building AI agents, realtime apps, and game servers
homepagehttps://actorcore.org
repositoryhttps://github.com/rivet-gg/actor-core
max_upload_size
id1600322
size111,053
Nathan Flurry (NathanFlurry)

documentation

README

ActorCore Rust Client

The Rust client for ActorCore, the Stateful Serverless Framework

Use this client to connect to ActorCore services from Rust applications.

Resources

Getting Started

Step 1: Installation

Add to your Cargo.toml:

[dependencies]
actor-core-client = "0.1.0"

Step 2: Connect to Actor

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(())
}

Supported Transport Methods

The Rust client supports multiple transport methods:

  • TransportKind::Sse: Server-Sent Events
  • TransportKind::Ws: WebSockets

Supported Encodings

The Rust client supports multiple encoding formats:

  • EncodingKind::Json: JSON encoding
  • EncodingKind::Cbor: CBOR binary encoding

Community & Support

License

Apache 2.0

Commit count: 369

cargo fmt