asterisk_ari/
config.rs

1/// Configuration for the ARI client.
2///
3/// This struct holds the necessary information to configure the ARI client,
4/// including the API base URL, username, and password.
5#[derive(Clone, Debug, PartialEq)]
6pub struct Config {
7    /// The base URL for the ARI API.
8    pub(crate) api_base: String,
9    /// The username for authentication with the ARI API.
10    pub(crate) username: String,
11    /// The password for authentication with the ARI API.
12    pub(crate) password: String,
13}
14
15impl Default for Config {
16    /// Provides a default configuration for the ARI client.
17    ///
18    /// # Returns
19    ///
20    /// A `Config` instance with default values.
21    fn default() -> Self {
22        Config {
23            api_base: "http://localhost:8088/ari".to_string(),
24            username: "".to_string(),
25            password: "".to_string(),
26        }
27    }
28}
29
30impl Config {
31    /// Creates a new `Config` instance with the specified parameters.
32    ///
33    /// # Arguments
34    ///
35    /// * `api_base` - The base URL for the ARI API.
36    /// * `username` - The username for authentication with the ARI API.
37    /// * `password` - The password for authentication with the ARI API.
38    ///
39    /// # Returns
40    ///
41    /// A new `Config` instance with the provided values.
42    pub fn new(
43        api_base: impl Into<String>,
44        username: impl Into<String>,
45        password: impl Into<String>,
46    ) -> Self {
47        Config {
48            api_base: api_base.into(),
49            username: username.into(),
50            password: password.into(),
51        }
52    }
53}