StreamAdapter trait defines the interface for real-time stream storage and synchronization in the iii framework. Adapters handle CRUD operations, event broadcasting, and WebSocket subscriptions.
Location
src/modules/stream/adapters/mod.rs
Trait Definition
Required Methods
set
&str
required
The stream identifier
&str
required
The group/collection within the stream
&str
required
The unique item identifier
Value
required
The item data as a JSON value
anyhow::Result<SetResult>
Result indicating whether item was created or updated
get
&str
required
The stream identifier
&str
required
The group/collection within the stream
&str
required
The unique item identifier
anyhow::Result<Option<Value>>
The item data if found, None otherwise
delete
&str
required
The stream identifier
&str
required
The group/collection within the stream
&str
required
The unique item identifier
anyhow::Result<DeleteResult>
Result indicating success or failure
get_group
&str
required
The stream identifier
&str
required
The group/collection within the stream
anyhow::Result<Vec<Value>>
Vector of all items in the group
list_groups
&str
required
The stream identifier
anyhow::Result<Vec<String>>
Vector of group identifiers
list_all_stream
anyhow::Result<Vec<StreamMetadata>>
Vector of stream metadata objects
emit_event
StreamWrapperMessage
required
The event message to broadcast
anyhow::Result<()>
Returns Ok(()) on success or an error
subscribe
String
required
Unique connection identifier
Arc<dyn StreamConnection>
required
The WebSocket connection handler
anyhow::Result<()>
Returns Ok(()) on success or an error
unsubscribe
String
required
Connection identifier to remove
anyhow::Result<()>
Returns Ok(()) on success or an error
watch_events
anyhow::Result<()>
Returns Ok(()) on success or an error
destroy
anyhow::Result<()>
Returns Ok(()) on success or an error
update
&str
required
The stream identifier
&str
required
The group/collection within the stream
&str
required
The unique item identifier
Vec<UpdateOp>
required
Vector of atomic update operations to apply
anyhow::Result<UpdateResult>
The updated value or an error
Implementation Example
Related Types
StreamMetadata
StreamWrapperMessage
StreamConnection
UpdateOp
From theiii_sdk crate - represents atomic JSON operations:
- Set a field
- Delete a field
- Append to array
- Remove from array
- Increment/decrement numbers
Registration Example
See Also
- Module - Base module trait
- QueueAdapter - Trait for queue adapters
- Stream Module - Stream module implementation