pub struct Handler {
agent_to_block: HashMap<String, String>,
block_to_agent: HashMap<String, String>,
agent_info: HashMap<String, AgentRegistration>,
input_sender: Option<Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>>,
audit_log: Vec<AuditLogEntry>,
rate_limiter: RateLimiter,
include_source_in_message: bool,
}Expand description
Core reactive messaging handler.
Manages agent registrations, rate limiting, message injection, and audit logging.
Fields§
§agent_to_block: HashMap<String, String>§block_to_agent: HashMap<String, String>§agent_info: HashMap<String, AgentRegistration>§input_sender: Option<Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>>§audit_log: Vec<AuditLogEntry>§rate_limiter: RateLimiter§include_source_in_message: boolImplementations§
Source§impl Handler
impl Handler
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new handler without an input sender.
Call set_input_sender before injecting messages.
Sourcepub fn set_input_sender(
&mut self,
sender: Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>,
)
pub fn set_input_sender( &mut self, sender: Arc<dyn Fn(&str, &[u8]) -> Result<(), String> + Send + Sync>, )
Set the input sender function for message injection.
Sourcepub fn set_include_source(&mut self, include: bool)
pub fn set_include_source(&mut self, include: bool)
Set whether to include source agent prefix in injected messages.
Sourcepub fn register_agent(
&mut self,
agent_id: &str,
block_id: &str,
tab_id: Option<&str>,
) -> Result<(), String>
pub fn register_agent( &mut self, agent_id: &str, block_id: &str, tab_id: Option<&str>, ) -> Result<(), String>
Register an agent with a block.
Sourcepub fn unregister_agent(&mut self, agent_id: &str)
pub fn unregister_agent(&mut self, agent_id: &str)
Unregister an agent.
Sourcepub fn unregister_block(&mut self, block_id: &str)
pub fn unregister_block(&mut self, block_id: &str)
Unregister by block ID.
Sourcepub fn update_last_seen(&mut self, agent_id: &str)
pub fn update_last_seen(&mut self, agent_id: &str)
Update the last_seen timestamp for an agent.
Sourcepub fn get_agent(&self, agent_id: &str) -> Option<&AgentRegistration>
pub fn get_agent(&self, agent_id: &str) -> Option<&AgentRegistration>
Get agent registration by agent ID.
Sourcepub fn get_agent_by_block(&self, block_id: &str) -> Option<&AgentRegistration>
pub fn get_agent_by_block(&self, block_id: &str) -> Option<&AgentRegistration>
Get agent registration by block ID.
Sourcepub fn list_agents(&self) -> Vec<AgentRegistration>
pub fn list_agents(&self) -> Vec<AgentRegistration>
List all registered agents.
Sourcepub fn inject_message(&mut self, req: InjectionRequest) -> InjectionResponse
pub fn inject_message(&mut self, req: InjectionRequest) -> InjectionResponse
Inject a message into an agent’s terminal.
Sends message\r as a single payload (required for text display),
then spawns 3 delayed \r sends at 200ms intervals as separate
PTY writes to ensure submission. See specs/jekt-inject-timing.md.
Sourcepub fn get_audit_log(&self, limit: usize) -> Vec<AuditLogEntry>
pub fn get_audit_log(&self, limit: usize) -> Vec<AuditLogEntry>
Get audit log entries, most recent first.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Handler
impl !RefUnwindSafe for Handler
impl Send for Handler
impl Sync for Handler
impl Unpin for Handler
impl !UnwindSafe for Handler
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.