wasmcloud_actor_eventstreams/lib.rs
1//! # Event Streams wasmCloud Actor Interface
2//!
3//! This crate provides an abstraction over the `wasmcloud:eventstreams` contract. This allows
4//! actors to write immutable events to a stream, receive events from a stream,
5//! and query events from a stream.
6//!
7//! # Example:
8//! ```
9//! extern crate wasmcloud_actor_core as actor;
10//! extern crate wasmcloud_actor_eventstreams as streams;
11//! extern crate wasmcloud_actor_http_server as http;
12//!
13//! use wapc_guest::HandlerResult;
14//! use streams::*;
15//! use std::collections::HashMap;
16//!
17//! #[actor::init]
18//! fn init() {
19//! http::Handlers::register_handle_request(handle_request);
20//! }
21//!
22//! fn handle_request(_req: http::Request) -> HandlerResult<http::Response> {
23//! // process event, query streams, or send new events...
24//! let _evts_so_far = streams::default()
25//! .query_stream(StreamQuery{
26//! stream_id: "hello_stream".to_string(),
27//! range: None,
28//! count: 0
29//! });
30//! let ack = streams::default().write_event("hello_stream".to_string(),
31//! HashMap::new())?;
32//! Ok(http::Response::ok())
33//! }
34//! ```
35
36#[allow(dead_code)]
37mod generated;
38
39pub use generated::*;
40
41pub const OP_WRITE_EVENT: &str = "WriteEvent";
42pub const OP_QUERY_STREAM: &str = "QueryStream";