pub struct InteractionBridge { /* private fields */ }Expand description
The interaction bridge translating heartbit callbacks to WS frames.
Maintains a map of pending interactions and an outbound channel for pushing events to the WebSocket handler.
Implementations§
Source§impl InteractionBridge
impl InteractionBridge
Sourcepub fn new(outbound: Sender<OutboundMessage>, timeout: Duration) -> Self
pub fn new(outbound: Sender<OutboundMessage>, timeout: Duration) -> Self
Create a new bridge with the given outbound sender and interaction timeout.
Sourcepub fn make_on_text(self: &Arc<Self>, session_id: Uuid) -> Arc<OnText> ⓘ
pub fn make_on_text(self: &Arc<Self>, session_id: Uuid) -> Arc<OnText> ⓘ
Create an OnText callback that forwards text deltas to the outbound channel.
Sourcepub fn make_on_event(self: &Arc<Self>, session_id: Uuid) -> Arc<OnEvent> ⓘ
pub fn make_on_event(self: &Arc<Self>, session_id: Uuid) -> Arc<OnEvent> ⓘ
Create an OnEvent callback that forwards agent events to the outbound channel.
Sourcepub fn make_on_input(self: &Arc<Self>, session_id: Uuid) -> Arc<OnInput> ⓘ
pub fn make_on_input(self: &Arc<Self>, session_id: Uuid) -> Arc<OnInput> ⓘ
Create an OnInput callback using oneshot rendezvous.
When called, sends InputNeeded on the outbound channel and waits
for the client to resolve. Returns None on timeout (SOLICITATION semantic).
Sourcepub fn make_on_approval(self: &Arc<Self>, session_id: Uuid) -> Arc<OnApproval> ⓘ
pub fn make_on_approval(self: &Arc<Self>, session_id: Uuid) -> Arc<OnApproval> ⓘ
Create an OnApproval callback using std::sync::mpsc rendezvous.
OnApproval is synchronous, so we use std::sync::mpsc::recv_timeout()
instead of async oneshot. Returns Deny on timeout (PERMISSION semantic).
Sourcepub fn make_on_question(self: &Arc<Self>, session_id: Uuid) -> Arc<OnQuestion> ⓘ
pub fn make_on_question(self: &Arc<Self>, session_id: Uuid) -> Arc<OnQuestion> ⓘ
Create an OnQuestion callback using oneshot rendezvous.
Returns Error::Channel("timeout") on timeout (CLARIFICATION semantic).
Sourcepub fn resolve_input(
&self,
id: Uuid,
message: Option<String>,
) -> Result<(), Error>
pub fn resolve_input( &self, id: Uuid, message: Option<String>, ) -> Result<(), Error>
Resolve a pending input interaction.
SECURITY (F-AUTH-5): when expected_session is Some, the
resolver checks that the pending entry belongs to that session
before delivering the result. Use this in network handlers where
the resolving frame’s session id is known.
Sourcepub fn resolve_input_for_session(
&self,
expected_session: Option<Uuid>,
id: Uuid,
message: Option<String>,
) -> Result<(), Error>
pub fn resolve_input_for_session( &self, expected_session: Option<Uuid>, id: Uuid, message: Option<String>, ) -> Result<(), Error>
Like [resolve_input] but verifies the interaction belongs to
expected_session before resolving (F-AUTH-5).
Sourcepub fn resolve_approval(
&self,
id: Uuid,
decision: ApprovalDecision,
) -> Result<(), Error>
pub fn resolve_approval( &self, id: Uuid, decision: ApprovalDecision, ) -> Result<(), Error>
Resolve a pending approval interaction.
Sourcepub fn resolve_approval_for_session(
&self,
expected_session: Option<Uuid>,
id: Uuid,
decision: ApprovalDecision,
) -> Result<(), Error>
pub fn resolve_approval_for_session( &self, expected_session: Option<Uuid>, id: Uuid, decision: ApprovalDecision, ) -> Result<(), Error>
Like [resolve_approval] but verifies the interaction belongs to
expected_session (F-AUTH-5).
Sourcepub fn resolve_question(
&self,
id: Uuid,
response: QuestionResponse,
) -> Result<(), Error>
pub fn resolve_question( &self, id: Uuid, response: QuestionResponse, ) -> Result<(), Error>
Resolve a pending question interaction.
Sourcepub fn resolve_question_for_session(
&self,
expected_session: Option<Uuid>,
id: Uuid,
response: QuestionResponse,
) -> Result<(), Error>
pub fn resolve_question_for_session( &self, expected_session: Option<Uuid>, id: Uuid, response: QuestionResponse, ) -> Result<(), Error>
Like [resolve_question] but verifies the interaction belongs to
expected_session (F-AUTH-5).