Skip to main content

forge_server/surface/
voice.rs

1//! `voices()`: the speaking role's switch and model directory, and the
2//! release a dropped connection owes every seat it was listening to.
3
4use forge_primitives::SessionSlot;
5
6use super::ViewSurface;
7
8impl ViewSurface {
9    /// The `[tts]` section's own read: on or off, and where its model lands.
10    /// No seat, because neither fact varies by one.
11    pub fn voices(&self) -> forge_workspace::TtsView {
12        self.workspace.voices()
13    }
14
15    /// A connection has left: every seat it was listening to drops it, and
16    /// each seat's subscribers hear the count it left behind.
17    pub fn voice_release(&self, client: u64) -> Vec<SessionSlot> {
18        self.workspace.voice_release(client)
19    }
20}
21
22#[cfg(test)]
23mod tests {
24    use std::sync::Arc;
25
26    use super::*;
27
28    /// A switched-off `[tts]` reads as off, and the directory is the
29    /// config's answer rather than the platform default.
30    #[test]
31    fn voices_reads_the_tts_settings() {
32        let (workspace, _dir) = crate::surface::testing::workspace();
33        let surface = ViewSurface::new(Arc::clone(&workspace));
34
35        let view = surface.voices();
36        assert!(!view.enabled, "the fixture's [tts] is absent, which is off");
37        assert!(
38            view.models_dir.as_ref().is_some_and(|dir| dir.ends_with("forge-tts")),
39            "an unset models_dir is the platform cache, got: {:?}",
40            view.models_dir,
41        );
42    }
43}