pub struct MessageEngine {
pub store: CommStore,
}Expand description
Unified message processing engine that wraps CommStore and provides
a higher-level pipeline for sending and querying messages.
The engine adds validation, trust checking, and consent enforcement as a composable layer on top of the raw store operations.
Fields§
§store: CommStoreThe underlying communication store.
Implementations§
Source§impl MessageEngine
impl MessageEngine
Sourcepub fn from_store(store: CommStore) -> Self
pub fn from_store(store: CommStore) -> Self
Create an engine from an existing CommStore.
Sourcepub fn process_message(
&mut self,
channel_id: u64,
sender: &str,
content: &str,
message_type: &str,
) -> Result<u64, String>
pub fn process_message( &mut self, channel_id: u64, sender: &str, content: &str, message_type: &str, ) -> Result<u64, String>
Process an inbound message through the full pipeline.
Steps:
- Parse the message type from a string.
- Validate sender trust level (must be at least
Basic). - Check consent for the SendMessages scope.
- Send the message via the underlying store.
- Return the new message ID.
Sourcepub fn query(&self, query_type: &str, params: &Value) -> Result<Value, String>
pub fn query(&self, query_type: &str, params: &Value) -> Result<Value, String>
Unified query dispatcher.
Supported query_type values:
-
"channel_messages"— returns messages for a channel. Params:{ "channel_id": <u64> } -
"message"— returns a single message by ID. Params:{ "message_id": <u64> } -
"stats"— returns store-level statistics. Params:{}(none required) -
"semantic_search"— returns semantically similar messages. Params:{ "embedding": [f32, ...], "top_k": <usize> }
Trait Implementations§
Source§impl Clone for MessageEngine
impl Clone for MessageEngine
Source§fn clone(&self) -> MessageEngine
fn clone(&self) -> MessageEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more