grp_core/config.rs
1
2/// # Config
3/// is the configuration needed to interact with any platform
4/// it contains 4 atributes
5///
6/// 1. `pconf`: the name for the _configuration_, showed in the error messages.
7/// 2. `user`: the _user_ or _org-name_ registerd in the **platform**.
8/// 3. `token`: the token to _authenticate_ the user.
9/// 4. `endpont`: the _endpoint_ used to interact with the **platform**.
10///
11/// # Example
12/// ~~~
13/// use grp_core::Config;
14///
15/// let config = Config::new("internal", "feraxhp", "gh-******", "api.github.com");
16/// ~~~
17///
18#[derive(Clone)]
19pub struct Config {
20 pub pconf: String,
21 pub user: String,
22 pub token: String,
23 pub endpoint: String,
24}
25
26impl Config {
27 pub fn new<T: Into<String>>(
28 pconf: T, user: T,
29 token: T, endpoint: T
30 ) -> Self {
31 Config {
32 pconf: pconf.into(),
33 user: user.into(),
34 token: token.into(),
35 endpoint: endpoint.into()
36 }
37 }
38}