Skip to main content

Crate onwardz

Crate onwardz 

Source
Expand description

Server-side SDK for managing Onwardz rooms.

Use this in your backend to create rooms, issue short-lived join tokens, and manage room settings. It pairs with the browser SDK (@onwardz/js): your backend mints a token, the browser joins with it — no API key in the client.

Never use this crate in client-side code. It requires your API key, which must stay on the server.

§Quick start

use onwardz::{OnwardzClient, CreateRoomOptions};

let onwardz = OnwardzClient::new(std::env::var("ONWARDZ_API_KEY").unwrap());

// Create a room and mint a token for a browser client.
let room = onwardz.create_room(CreateRoomOptions { max_participants: Some(10), ..Default::default() }).await?;
let token = onwardz.issue_token(&room.room_id, None).await?;

// Pass room.room_id + token.token to the browser (@onwardz/js).

§Error handling

Calls return OnwardzError. Match OnwardzError::rpc_code against RpcErrorCode to handle known server conditions by name:

match onwardz.delete_room(room_id).await {
    Ok(()) => {}
    Err(e) if e.rpc_code() == Some(RpcErrorCode::RoomNotFound) => { /* already gone */ }
    Err(e) => eprintln!("{e}"),
}

Structs§

ConfigureRoomOptions
Options for OnwardzClient::configure_room.
CreateRoomOptions
Options for OnwardzClient::create_room.
CreateRoomResponse
Returned by OnwardzClient::create_room.
IssueTokenResponse
Returned by OnwardzClient::issue_token.
OnwardzClient
Authenticated client for the Onwardz server API.
OnwardzClientBuilder
Builder for OnwardzClient.
Room
A room owned by the account, as returned by OnwardzClient::list_rooms.
Theme
Curated look-and-feel for the embedded <onwardz-room> element. All fields are optional; anything unset falls back to the built-in defaults. Mirrors the 5 keys validated server-side and mapped in @onwardz/js.

Enums§

OnwardzError
An error returned by an OnwardzClient call.
RpcErrorCode
Named JSON-RPC error codes returned by the Onwardz server, mirroring the RpcErrors constants in @onwardz/node.

Constants§

DEFAULT_SERVER_URL
The default Onwardz API endpoint.

Type Aliases§

Result
Convenience alias for results returned by this crate.