asterisk_ari/apis/mod.rs
1use serde::Serializer;
2
3pub mod applications;
4pub mod asterisk;
5pub mod bridges;
6pub mod channels;
7pub mod client;
8pub mod device_stats;
9pub mod endpoints;
10pub mod events;
11pub mod mailboxes;
12pub mod playbacks;
13pub mod recordings;
14pub mod sounds;
15
16pub mod params {
17 use serde::{Deserialize, Serialize};
18
19 /// Represents the direction of a call or event.
20 #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
21 pub enum Direction {
22 /// Both directions (incoming and outgoing).
23 #[default]
24 #[serde(rename = "both")]
25 Both,
26 /// Outgoing direction.
27 #[serde(rename = "out")]
28 Out,
29 /// Incoming direction.
30 #[serde(rename = "in")]
31 In,
32 }
33
34 /// Specifies the behavior if a resource already exists.
35 #[derive(Clone, Debug, PartialEq, Serialize, Default)]
36 pub enum IfExists {
37 /// Overwrite the existing resource.
38 #[serde(rename = "overwrite")]
39 #[default]
40 Overwrite,
41 /// Fail if the resource exists.
42 #[serde(rename = "fail")]
43 Fail,
44 /// Append to the existing resource.
45 #[serde(rename = "append")]
46 Append,
47 }
48
49 /// Specifies the termination condition for a call or event.
50 #[derive(Clone, Debug, PartialEq, Serialize, Default)]
51 pub enum TerminateOn {
52 /// No termination condition.
53 #[serde(rename = "none")]
54 #[default]
55 None,
56 /// Terminate on any condition.
57 #[serde(rename = "any")]
58 Any,
59 /// Terminate on the '*' key press.
60 #[serde(rename = "*")]
61 Start,
62 /// Terminate on the '#' key press.
63 #[serde(rename = "#")]
64 Hash,
65 }
66}
67
68/// Serializes an optional vector of strings by concatenating them with commas.
69///
70/// # Arguments
71///
72/// * `x` - The optional vector of strings to serialize.
73/// * `s` - The serializer to use.
74///
75/// # Returns
76///
77/// A result containing the serialized string or an error.
78fn concat_option_str<S>(x: &Option<Vec<String>>, s: S) -> Result<S::Ok, S::Error>
79where
80 S: Serializer,
81{
82 match x {
83 Some(x) => s.serialize_str(x.join(",").as_str()),
84 None => s.serialize_none(),
85 }
86}
87
88/// Serializes a vector of strings by concatenating them with commas.
89///
90/// # Arguments
91///
92/// * `x` - The vector of strings to serialize.
93/// * `s` - The serializer to use.
94///
95/// # Returns
96///
97/// A result containing the serialized string or an error.
98fn concat_str<S>(x: &[String], s: S) -> Result<S::Ok, S::Error>
99where
100 S: Serializer,
101{
102 s.serialize_str(x.join(",").as_str())
103}