From b76f0dcc4b169f404cbabd265a79d4e06d9569c2 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sun, 5 Jul 2026 03:36:20 -0400 Subject: [PATCH] fix(trunk): trait imports + remove unused (AudioSink/AudioSource) in session tests (T4 cleanup) Signed-off-by: Aaron D. Lee --- crates/rutster-trunk/src/loop_driver.rs | 31 ++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/crates/rutster-trunk/src/loop_driver.rs b/crates/rutster-trunk/src/loop_driver.rs index 4c4d739..17386c0 100644 --- a/crates/rutster-trunk/src/loop_driver.rs +++ b/crates/rutster-trunk/src/loop_driver.rs @@ -21,9 +21,10 @@ use std::time::{Duration, Instant}; +use rutster_media::{AudioSink, AudioSource}; use tracing::{info, warn}; -use crate::session::{TrunkSession, IDLE_TIMEOUT, OUTBOUND_TICK}; +use crate::session::{IDLE_TIMEOUT, OUTBOUND_TICK, TrunkSession}; /// One iteration of the trunk-leg driver. Mirrors `rutster_media::loop_driver::drive` /// minus str0m. Returns the sleep-until-next-tick budget. @@ -56,11 +57,7 @@ pub fn drive( // Brain reply PCM; push to the WSS pump task for ยต-law encode // + Twilio Media Streams JSON "media" frame emission. try_send; // drop + observe on full (hot-path policy). - if session - .outbound_to_twilio_tx - .try_send(reply_frame) - .is_err() - { + if session.outbound_to_twilio_tx.try_send(reply_frame).is_err() { warn!( channel_id = %session.channel.id, "outbound_to_twilio_tx full; dropping brain reply frame" @@ -98,8 +95,7 @@ mod tests { // Given: a TrunkSession with an EchoAudioPipe inner + an inbound // mpsc carrying one PCM frame. let now = Instant::now(); - let (mut session, inbound_tx, _out_rx) = - trunk_session_with_echo_pipe_and_mpsc(now); + let (mut session, inbound_tx, _out_rx) = trunk_session_with_echo_pipe_and_mpsc(now); let mut frame = PcmFrame::zeroed(); frame.samples[0] = 4242; @@ -121,7 +117,10 @@ mod tests { // The EchoAudioPipe holds exactly one frame (the one we pushed). // If the tick route worked, we get Some back; if the inbound // mpsc was never drained, we get None (the echopipe is empty). - assert!(out_frame.is_some(), "tick must drain inbound mpsc to the pipe"); + assert!( + out_frame.is_some(), + "tick must drain inbound mpsc to the pipe" + ); } #[tokio::test] @@ -130,8 +129,7 @@ mod tests { // holds a frame (pushed via on_pcm_frame), and the outbound mpsc // ready to receive. let now = Instant::now(); - let (mut session, _in_tx, mut out_rx) = - trunk_session_with_echo_pipe_and_mpsc(now); + let (mut session, _in_tx, mut out_rx) = trunk_session_with_echo_pipe_and_mpsc(now); // Prime the inner echo pipe with a frame. let mut frame = PcmFrame::zeroed(); @@ -146,15 +144,17 @@ mod tests { // Then: outbound mpsc has the frame (try_recv returns it). let drained = out_rx.try_recv(); - assert!(drained.is_ok(), "tick must push brain reply PCM to outbound mpsc"); + assert!( + drained.is_ok(), + "tick must push brain reply PCM to outbound mpsc" + ); } #[tokio::test] async fn idle_timeout_closes_session_after_60s_silence() { // Given: a session whose last_idle_rx is 90s in the past. let now = Instant::now(); - let (mut session, _in_tx, _out_rx) = - trunk_session_with_echo_pipe_and_mpsc(now); + let (mut session, _in_tx, _out_rx) = trunk_session_with_echo_pipe_and_mpsc(now); session.last_idle_rx = now - Duration::from_secs(90); // When: drive() runs one tick. @@ -174,8 +174,7 @@ mod tests { // Given: a TrunkSession with an inbound frame ready; last_idle_rx // is currently in the past. let now = Instant::now(); - let (mut session, inbound_tx, _out_rx) = - trunk_session_with_echo_pipe_and_mpsc(now); + let (mut session, inbound_tx, _out_rx) = trunk_session_with_echo_pipe_and_mpsc(now); session.last_idle_rx = now - Duration::from_secs(30); inbound_tx.send(PcmFrame::zeroed()).await.unwrap();