uda_connector/
credentials.rs

1use derive_getters::Getters;
2use std::fmt::{Debug, Formatter};
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Getters, PartialEq, Clone, Default)]
6pub struct UdaCredentials {
7    /// Should be something like `https://cfm2019training.reg.unicycling-software.com`
8    /// Beware of not including anything after the TLD. Otherwise, it may not work.
9    #[getter(skip)]
10    uda_url: String,
11    login: String,
12    password: String,
13}
14
15impl UdaCredentials {
16    pub fn uda_url(&self) -> &String {
17        &self.uda_url
18    }
19}
20
21impl Debug for UdaCredentials {
22    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
23        write!(
24            f,
25            "Uda Credentials {{uda={}, login={}, password=MASKED}}",
26            self.uda_url, self.login
27        )
28    }
29}
30
31#[cfg(any(test, feature = "test"))]
32impl UdaCredentials {
33    pub fn new(uda_url: String, login: String, password: String) -> Self {
34        Self {
35            uda_url,
36            login,
37            password,
38        }
39    }
40}