pub enum DataFrame {
InputAudio {
bytes: Arc<[u8]>,
sample_rate: u32,
num_channels: u16,
},
Transcript(Transcript),
Audio(AudioChunk),
SpeechStarted,
SpeechStopped,
Model(ModelFrame),
Dispatch(DispatchFrame),
Custom(Arc<dyn CustomFrame>),
}Expand description
Data frames: everything flowing downstream (source → sink) in FIFO order — the media payload, the in-band voice-activity edges, and the native model/dispatch protocol frames that must stay ordered with it.
Model and Dispatch frames ride
this lane, not the system lane, because their order carries meaning; see
ModelFrame for the ordering contract.
Immutable: don’t try to make mutable frames. Instead, aggregate frames and produce a new one when you’re ready.
Variants§
InputAudio
Input audio from a transport source. Survives an interrupt flush so that
a barge-in utterance is not clipped; see DataFrame::survives_flush.
Fields
Transcript(Transcript)
A piece of conversation text: STT output, LM output, or text bound for
TTS. See Transcript for the role and finality it carries.
Audio(AudioChunk)
A chunk of f32 PCM audio carrying its own AudioFormat.
SpeechStarted
Voice-activity detection observed the user start speaking: the
silence→speech edge, emitted by the VAD stage at onset and followed by the
utterance’s Audio frames.
SpeechStopped
Voice-activity detection observed the user stop speaking: the
speech→silence edge, emitted by the VAD stage after the utterance’s last
Audio frame.
Model(ModelFrame)
Native language-model protocol frame; see ModelFrame.
Dispatch(DispatchFrame)
Native asynchronous-dispatch protocol frame; see DispatchFrame.
Custom(Arc<dyn CustomFrame>)
Application-defined payload; see CustomFrame. Model and dispatch are
native variants and need no escape hatch.
Implementations§
Source§impl DataFrame
impl DataFrame
Sourcepub fn survives_flush(&self) -> bool
pub fn survives_flush(&self) -> bool
True for frames that outlive an interrupt’s data-queue flush, false for
those belonging to the interrupted turn. Survivors:
InputAudio (don’t clip the new utterance),
Model(Input), Model(ToolCall),
and every Dispatch frame. Dropped: voice edges,
generated Transcripts, and the generation boundaries.
use std::sync::Arc;
use pipecrab_core::{
AudioChunk, AudioFormat, DataFrame, DispatchEvent, DispatchFrame, ModelFrame,
ToolCall, Transcript,
};
let input = DataFrame::InputAudio {
bytes: Arc::from(&[0u8; 4][..]),
sample_rate: 16_000,
num_channels: 1,
};
assert!(input.survives_flush());
assert!(!DataFrame::from(Transcript::agent_final("hi")).survives_flush());
let audio = AudioChunk::new(Arc::from(&[0.0f32][..]), AudioFormat::new(48_000, 1));
assert!(!DataFrame::Audio(audio).survives_flush());
// Tool calls and dispatch frames survive; generation boundaries don't.
let call = ToolCall {
id: Arc::from("call-1"),
name: Arc::from("lookup"),
arguments_json: Arc::from("{}"),
};
assert!(DataFrame::from(call).survives_flush());
assert!(!DataFrame::Model(ModelFrame::GenerationStarted).survives_flush());
let event = DispatchEvent::Progress { task_id: Arc::from("t1"), message: Arc::from("50%") };
assert!(DataFrame::from(DispatchFrame::from(event)).survives_flush());Trait Implementations§
Source§impl From<DispatchFrame> for DataFrame
impl From<DispatchFrame> for DataFrame
Source§fn from(frame: DispatchFrame) -> Self
fn from(frame: DispatchFrame) -> Self
Wrap a DispatchFrame as a DataFrame::Dispatch.
Source§impl From<ModelFrame> for DataFrame
impl From<ModelFrame> for DataFrame
Source§fn from(frame: ModelFrame) -> Self
fn from(frame: ModelFrame) -> Self
Wrap a ModelFrame as a DataFrame::Model.
Source§impl From<Transcript> for DataFrame
impl From<Transcript> for DataFrame
Source§fn from(transcript: Transcript) -> Self
fn from(transcript: Transcript) -> Self
Wrap a Transcript as a DataFrame::Transcript so a stage can write
Transcript::user_final(text).into() instead of naming the variant.