Skip to main content

DataFrame

Enum DataFrame 

Source
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

§bytes: Arc<[u8]>

Raw PCM bytes.

§sample_rate: u32

Samples per second (e.g. 16 000 for 16 kHz).

§num_channels: u16

Number of audio channels (1 = mono, 2 = stereo).

§

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

Source

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 Clone for DataFrame

Source§

fn clone(&self) -> DataFrame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<DispatchFrame> for DataFrame

Source§

impl From<ModelFrame> for DataFrame

Source§

fn from(frame: ModelFrame) -> Self

Source§

impl From<ToolCall> for DataFrame

Source§

fn from(call: ToolCall) -> Self

Wrap a complete ToolCall as a DataFrame::Model.

Source§

impl From<Transcript> for DataFrame

Source§

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.