Skip to main content

FlowEffects

Trait FlowEffects 

Source
pub trait FlowEffects: Send {
    // Required methods
    fn speak<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        prompt: &'life1 Prompt,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn collect_digit<'life0, 'async_trait>(
        &'life0 mut self,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Digit>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ring_human<'life0, 'async_trait>(
        &'life0 mut self,
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<RingOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_message<'life0, 'async_trait>(
        &'life0 mut self,
        tone: MessageTone,
        max: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transfer<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        target: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn hangup<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        prompt: Option<&'life1 Prompt>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn now(&self) -> OffsetDateTime;

    // Provided method
    fn on_enter(&mut self, _node: &NodeId, _kind: &'static str) { ... }
}
Expand description

The side effects the components need. The engine calls these; the impl performs the telephony/audio. &mut self because a real impl holds the live call. Methods return anyhow::Result so the daemon impl can surface call-dropped / device errors uniformly; the engine treats any Err as “the call is gone” and aborts with a trace.

Required Methods§

Source

fn speak<'life0, 'life1, 'async_trait>( &'life0 mut self, prompt: &'life1 Prompt, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Play a prompt (TTS text or an audio asset) to the caller, returning when playback finishes.

Source

fn collect_digit<'life0, 'async_trait>( &'life0 mut self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<Digit>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Wait up to timeout for one DTMF digit. Ok(None) means the window elapsed with no press (distinct from an error).

Source

fn ring_human<'life0, 'async_trait>( &'life0 mut self, timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<RingOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Ring the human for up to timeout.

Source

fn record_message<'life0, 'async_trait>( &'life0 mut self, tone: MessageTone, max: Duration, ) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record a voicemail: play tone (the caller’s record-start cue), then capture up to max. The node’s prompt has already been spoken via FlowEffects::speak — the engine traces it as its own step. Returns the seconds actually captured (for the trace).

Source

fn transfer<'life0, 'life1, 'async_trait>( &'life0 mut self, target: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Blind-transfer the call to target.

Source

fn hangup<'life0, 'life1, 'async_trait>( &'life0 mut self, prompt: Option<&'life1 Prompt>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Speak an optional goodbye and end the call.

Source

fn now(&self) -> OffsetDateTime

The current instant, for hours evaluation. Injectable so tests pin a fixed time and the schedule is deterministic.

Provided Methods§

Source

fn on_enter(&mut self, _node: &NodeId, _kind: &'static str)

Called once as the engine enters a node, before that node’s own effects run — carries the node’s id and its component kind (Node::kind, e.g. "greeting", "menu"). Lets a live consumer light up which node is executing right now, and accumulate the path the caller has taken, without waiting for the run-end trace.

Default no-op: the durable, ordered per-node record is the trace (Trace); a consumer that only reads results at run end ignores this. Fires for every visited node including hours (which runs no other effect) and a node re-entered by a menu loop.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§