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§
- Configure
Room Options - Options for
OnwardzClient::configure_room. - Create
Room Options - Options for
OnwardzClient::create_room. - Create
Room Response - Returned by
OnwardzClient::create_room. - Issue
Token Response - Returned by
OnwardzClient::issue_token. - Onwardz
Client - Authenticated client for the Onwardz server API.
- Onwardz
Client Builder - 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§
- Onwardz
Error - An error returned by an
OnwardzClientcall. - RpcError
Code - Named JSON-RPC error codes returned by the Onwardz server, mirroring the
RpcErrorsconstants in@onwardz/node.
Constants§
- DEFAULT_
SERVER_ URL - The default Onwardz API endpoint.
Type Aliases§
- Result
- Convenience alias for results returned by this crate.