dstar_gateway/tokio_shell/
command.rs1use dstar_gateway_core::header::DStarHeader;
5use dstar_gateway_core::types::StreamId;
6use dstar_gateway_core::voice::VoiceFrame;
7
8use super::ShellError;
9
10#[derive(Debug)]
13pub enum Command {
14 SendHeader {
16 header: Box<DStarHeader>,
18 stream_id: StreamId,
20 reply: tokio::sync::oneshot::Sender<Result<(), ShellError>>,
22 },
23
24 SendVoice {
26 stream_id: StreamId,
28 seq: u8,
30 frame: Box<VoiceFrame>,
32 reply: tokio::sync::oneshot::Sender<Result<(), ShellError>>,
34 },
35
36 SendEot {
38 stream_id: StreamId,
40 seq: u8,
42 reply: tokio::sync::oneshot::Sender<Result<(), ShellError>>,
44 },
45
46 Disconnect {
48 reply: tokio::sync::oneshot::Sender<()>,
50 },
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56 use dstar_gateway_core::types::StreamId;
57
58 #[expect(clippy::unwrap_used, reason = "const-validated: 0x1234 is non-zero")]
59 const fn sid(n: u16) -> StreamId {
60 StreamId::new(n).unwrap()
61 }
62
63 #[test]
64 fn command_send_eot_constructs() {
65 let (tx, _rx) = tokio::sync::oneshot::channel();
66 let cmd = Command::SendEot {
67 stream_id: sid(0x1234),
68 seq: 5,
69 reply: tx,
70 };
71 assert!(matches!(cmd, Command::SendEot { .. }));
72 }
73}