exoware_sdk_rs/
lib.rs

1//! Rust SDK for the Exoware API.
2
3mod error;
4pub use error::Error;
5pub mod store;
6pub mod stream;
7
8use reqwest::Client as HttpClient;
9use std::sync::Arc;
10
11/// The client for interacting with the Exoware API.
12#[derive(Clone)]
13pub struct Client {
14    http_client: HttpClient,
15    base_url: String,
16    token: Arc<String>,
17}
18
19impl Client {
20    /// Creates a new [Client].
21    ///
22    /// # Arguments
23    ///
24    /// * `base_url` - The base URL of the Exoware server (e.g., `http://localhost:8080`).
25    /// * `token` - The token to use for bearer authentication.
26    pub fn new(base_url: String, token: String) -> Self {
27        Self {
28            http_client: HttpClient::new(),
29            base_url,
30            token: Arc::new(token),
31        }
32    }
33
34    /// Returns a [store::Client] for interacting with the key-value store.
35    pub fn store(&self) -> store::Client {
36        store::Client::new(self.clone())
37    }
38
39    /// Returns a [stream::Client] for interacting with realtime streams.
40    pub fn stream(&self) -> stream::Client {
41        stream::Client::new(self.clone())
42    }
43
44    /// Returns the base URL of the server.
45    pub fn base_url(&self) -> &str {
46        &self.base_url
47    }
48}