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        Both,
25        /// Outgoing direction.
26        Out,
27        /// Incoming direction.
28        In,
29    }
30
31    /// Specifies the behavior if a resource already exists.
32    #[derive(Clone, Debug, PartialEq, Serialize, Default)]
33    pub enum IfExists {
34        /// Overwrite the existing resource.
35        #[serde(rename = "overwrite")]
36        #[default]
37        Overwrite,
38        /// Fail if the resource exists.
39        #[serde(rename = "fail")]
40        Fail,
41        /// Append to the existing resource.
42        #[serde(rename = "append")]
43        Append,
44    }
45
46    /// Specifies the termination condition for a call or event.
47    #[derive(Clone, Debug, PartialEq, Serialize, Default)]
48    pub enum TerminateOn {
49        /// No termination condition.
50        #[serde(rename = "none")]
51        #[default]
52        None,
53        /// Terminate on any condition.
54        #[serde(rename = "any")]
55        Any,
56        /// Terminate on the '*' key press.
57        #[serde(rename = "*")]
58        Start,
59        /// Terminate on the '#' key press.
60        #[serde(rename = "#")]
61        Hash,
62    }
63}
64
65/// Serializes an optional vector of strings by concatenating them with commas.
66///
67/// # Arguments
68///
69/// * `x` - The optional vector of strings to serialize.
70/// * `s` - The serializer to use.
71///
72/// # Returns
73///
74/// A result containing the serialized string or an error.
75fn concat_option_str<S>(x: &Option<Vec<String>>, s: S) -> Result<S::Ok, S::Error>
76where
77    S: Serializer,
78{
79    match x {
80        Some(x) => s.serialize_str(x.join(",").as_str()),
81        None => s.serialize_none(),
82    }
83}
84
85/// Serializes a vector of strings by concatenating them with commas.
86///
87/// # Arguments
88///
89/// * `x` - The vector of strings to serialize.
90/// * `s` - The serializer to use.
91///
92/// # Returns
93///
94/// A result containing the serialized string or an error.
95fn concat_str<S>(x: &[String], s: S) -> Result<S::Ok, S::Error>
96where
97    S: Serializer,
98{
99    s.serialize_str(x.join(",").as_str())
100}