pub struct Client { /* private fields */ }Expand description
Synapse client — connects to a running Synapse runtime over HTTP.
use synapse_client::Client;
#[tokio::main]
async fn main() {
let client = Client::new("http://localhost:8080");
client.emit("save", serde_json::json!({"content": "hello"})).await.unwrap();
let results = client.query("GetAll", serde_json::json!({})).await.unwrap();
}Implementations§
Source§impl Client
impl Client
pub fn new(base_url: &str) -> Self
pub fn with_timeout(base_url: &str, timeout: Duration) -> Self
Sourcepub async fn emit(&self, event: &str, payload: Value) -> Result<Value>
pub async fn emit(&self, event: &str, payload: Value) -> Result<Value>
Emit an event to trigger a handler.
Sourcepub async fn query(&self, query_name: &str, params: Value) -> Result<Value>
pub async fn query(&self, query_name: &str, params: Value) -> Result<Value>
Execute a named query.
Sourcepub async fn health(&self) -> Result<HealthResponse>
pub async fn health(&self) -> Result<HealthResponse>
Health check.
Sourcepub async fn status(&self) -> Result<StatusResponse>
pub async fn status(&self) -> Result<StatusResponse>
Get runtime status.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more