pub struct AgentContext {
pub mesh_name: String,
/* private fields */
}Fields§
§mesh_name: StringThe name of the mesh this agent is running in.
Implementations§
Source§impl AgentContext
impl AgentContext
Sourcepub fn new(mesh_name: String, request_queue: Option<Arc<RequestQueue>>) -> Self
pub fn new(mesh_name: String, request_queue: Option<Arc<RequestQueue>>) -> Self
Create a new agent context.
§Arguments
mesh_name- Name of the meshrequest_queue- Optional request queue for request/response pattern
Sourcepub fn report_result(&self, request_id: &str, response: String)
pub fn report_result(&self, request_id: &str, response: String)
Report a result for a pending request.
Call this to send a response back to the requester when handling a message with a correlation ID.
Sourcepub fn has_request_queue(&self) -> bool
pub fn has_request_queue(&self) -> bool
Check if this context has a request queue available.
Sourcepub fn listen(&mut self, callback: impl Fn(&AgentEvent) + Send + Sync + 'static)
pub fn listen(&mut self, callback: impl Fn(&AgentEvent) + Send + Sync + 'static)
Register an event listener.
Sourcepub fn emit(&self, event: AgentEvent)
pub fn emit(&self, event: AgentEvent)
Emit an event to all listeners.
Auto Trait Implementations§
impl Freeze for AgentContext
impl !RefUnwindSafe for AgentContext
impl Send for AgentContext
impl Sync for AgentContext
impl Unpin for AgentContext
impl !UnwindSafe for AgentContext
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