Module event

Module event 

Source
Expand description

Event system for agent communication.

This module provides the core event types that agents use to communicate. Events are the fundamental unit of information exchange in the agent system.

§Examples

use mojentic::event::Event;
use serde::{Deserialize, Serialize};
use std::any::Any;

#[derive(Debug, Clone, Serialize, Deserialize)]
struct MyCustomEvent {
    source: String,
    correlation_id: Option<String>,
    data: String,
}

impl Event for MyCustomEvent {
    fn source(&self) -> &str {
        &self.source
    }

    fn correlation_id(&self) -> Option<&str> {
        self.correlation_id.as_deref()
    }

    fn set_correlation_id(&mut self, id: String) {
        self.correlation_id = Some(id);
    }

    fn as_any(&self) -> &dyn Any {
        self
    }

    fn clone_box(&self) -> Box<dyn Event> {
        Box::new(self.clone())
    }
}

Structs§

TerminateEvent
A special event type that signals the dispatcher to terminate

Traits§

Event
Base trait for all events in the agent system.