cal_core/device/
queue.rs

1use crate::device::device::Connector;
2use crate::{ConnectState, FlowState};
3use serde::{Deserialize, Serialize};
4use std::fmt::{Debug, Formatter};
5
6#[derive(Serialize, Deserialize, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct Queue {
9    #[serde(default = "crate::device::shared::build_connect_to")]
10    pub connect_to: String,
11    // #[serde(default)]
12    // hangup: bool,
13    // #[serde(rename = "loop")]
14    // loop_count: u8,
15    // queue_name: String,
16    // ring_endpoints: bool,
17    // tts_language: String,
18    // items: Vec<QueueItem>,
19}
20
21impl Connector for Queue {
22    fn get_connect_to(&mut self, _state: &mut FlowState) -> ConnectState {
23        ConnectState::default(&self.connect_to, None)
24    }
25}
26
27#[derive(Serialize, Deserialize, Clone)]
28#[serde(rename_all = "camelCase")]
29pub struct QueueItem {
30    pub text: String,
31    #[serde(rename = "type")]
32    pub item_type: QueueItemType,
33}
34
35impl Debug for QueueItem {
36    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
37        f.debug_struct("QueueItem")
38            .field("text", &self.text)
39            .field("item_type", &self.item_type)
40            .finish()
41    }
42}
43
44impl Debug for Queue {
45    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
46        f.debug_struct("Queue")
47            .field("connect_to", &self.connect_to)
48            .finish()
49    }
50}
51
52
53#[derive(Serialize, Deserialize, Clone)]
54pub enum QueueItemType {
55    #[serde(rename = "play")]
56    Play,
57    #[serde(rename = "say")]
58    Say,
59    #[serde(rename = "pause")]
60    Pause,
61}
62
63impl Debug for QueueItemType {
64    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
65        match self {
66            QueueItemType::Play => write!(f, "QueueItemType::Play"),
67            QueueItemType::Say => write!(f, "QueueItemType::Say"),
68            QueueItemType::Pause => write!(f, "QueueItemType::Pause"),
69        }
70    }
71}