1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Server-side SDK for managing [Onwardz](https://onwardz.com) 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
//!
//! ```no_run
//! use onwardz::{OnwardzClient, CreateRoomOptions};
//!
//! # async fn run() -> Result<(), onwardz::OnwardzError> {
//! 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).
//! # Ok(())
//! # }
//! ```
//!
//! # Error handling
//!
//! Calls return [`OnwardzError`]. Match [`OnwardzError::rpc_code`] against
//! [`RpcErrorCode`] to handle known server conditions by name:
//!
//! ```no_run
//! # use onwardz::{OnwardzClient, RpcErrorCode};
//! # async fn f(onwardz: OnwardzClient, room_id: &str) {
//! match onwardz.delete_room(room_id).await {
//! Ok(()) => {}
//! Err(e) if e.rpc_code() == Some(RpcErrorCode::RoomNotFound) => { /* already gone */ }
//! Err(e) => eprintln!("{e}"),
//! }
//! # }
//! ```
pub use ;
pub use ;
pub use ;