pub struct AgentKernel<H>where
H: AgentMessageHandler + 'static,{ /* private fields */ }Expand description
Core runtime that wires lifecycle, scheduler, and MXP handlers.
Implementations§
Source§impl<H> AgentKernel<H>where
H: AgentMessageHandler + 'static,
impl<H> AgentKernel<H>where
H: AgentMessageHandler + 'static,
Sourcepub fn new(agent_id: AgentId, handler: Arc<H>, scheduler: TaskScheduler) -> Self
pub fn new(agent_id: AgentId, handler: Arc<H>, scheduler: TaskScheduler) -> Self
Creates a new agent kernel with the provided handler and scheduler.
Sourcepub fn set_registry<R>(
&mut self,
registry: Arc<R>,
manifest: AgentManifest,
config: RegistrationConfig,
)where
R: AgentRegistry + 'static,
pub fn set_registry<R>(
&mut self,
registry: Arc<R>,
manifest: AgentManifest,
config: RegistrationConfig,
)where
R: AgentRegistry + 'static,
Provides registry integration for mesh discovery and heartbeat management.
Sourcepub fn state(&self) -> AgentState
pub fn state(&self) -> AgentState
Returns the current lifecycle state.
Sourcepub fn transition(&mut self, event: LifecycleEvent) -> KernelResult<AgentState>
pub fn transition(&mut self, event: LifecycleEvent) -> KernelResult<AgentState>
Applies a lifecycle event, returning the new state on success.
§Errors
Returns LifecycleError when the transition is
not permitted from the current state.
Sourcepub async fn handle_message(&self, message: Message) -> HandlerResult
pub async fn handle_message(&self, message: Message) -> HandlerResult
Handles an MXP message immediately on the current task.
§Errors
Propagates any error returned by the message handler implementation.
Sourcepub fn schedule_message(
&self,
message: Message,
) -> SchedulerResult<JoinHandle<HandlerResult>>
pub fn schedule_message( &self, message: Message, ) -> SchedulerResult<JoinHandle<HandlerResult>>
Enqueues an MXP message for asynchronous processing via the scheduler.
§Errors
Returns SchedulerError when the scheduler has been closed.
Sourcepub fn scheduler(&self) -> &TaskScheduler
pub fn scheduler(&self) -> &TaskScheduler
Returns a reference to the underlying scheduler.
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for AgentKernel<H>
impl<H> !RefUnwindSafe for AgentKernel<H>
impl<H> Send for AgentKernel<H>
impl<H> Sync for AgentKernel<H>
impl<H> Unpin for AgentKernel<H>
impl<H> !UnwindSafe for AgentKernel<H>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more