1
//! Metadata about the user's project
2

            
3
use serde::{Deserialize, Serialize};
4

            
5
/// [`ProjectAttribute`] - Metadata about the user's project
6
/// * `name` - The C++ project's name
7
/// * `authors` - A comma separated list of strings indicating the
8
///     authors that are responsible for the project
9
///
10
/// ### Tests
11
///
12
/// ```rust
13
/// use zork::config_file::project::ProjectAttribute;
14
///
15
/// const CONFIG_FILE_MOCK: &str = r#"
16
///     #[project]
17
///     name = 'Zork++ serde tests'
18
///     authors = ['zerodaycode.gz@gmail.com']
19
///     compilation_db = true
20
///"#;
21
///
22
/// let config: ProjectAttribute = toml::from_str(CONFIG_FILE_MOCK)
23
///    .expect("A failure happened parsing the Zork toml file");
24
///
25
/// assert_eq!(config.name, "Zork++ serde tests");
26
/// assert_eq!(config.authors, Some(vec!["zerodaycode.gz@gmail.com"]));
27
/// assert_eq!(config.compilation_db, Some(true));
28
/// assert_eq!(config.code_root, None);
29
/// ```
30
///
31
/// > Note: TOML table are toml commented (#) to allow us to parse
32
/// > the inner attributes as the direct type that they belongs to.
33
/// > That commented tables aren't the real TOML, they are just there
34
/// > for testing and exemplification purposes of the inner attributes
35
/// > of the configuration file.
36
///
37
/// For a test over a real example, please look at the
38
/// [`zork::config_file::ZorkConfigFile`] doc-test
39
107
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
40
#[serde(deny_unknown_fields)]
41
pub struct ProjectAttribute<'a> {
42
    #[serde(borrow)]
43
    pub name: &'a str,
44
    #[serde(borrow)]
45
    pub authors: Option<Vec<&'a str>>,
46
    pub compilation_db: Option<bool>,
47
    #[serde(borrow)]
48
    pub code_root: Option<&'a str>,
49
}