Skip to main content

create_message

Function create_message 

Source
pub fn create_message(message_type: impl AsRef<str>) -> EmergentMessage
Expand description

Create a new message with the given type.

This is a convenience factory function that matches the Python and TypeScript SDKs.

§Panics

Panics if the message type is invalid.

§Example

use emergent_client::create_message;
use serde_json::json;

let msg = create_message("timer.tick")
    .with_payload(json!({"count": 1}))
    .with_metadata(json!({"trace_id": "abc123"}));