1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//!
//! Privacy by Design (PbD) is more important than ever in the industry.
//! No matter if you're an architects, software engineers, test engineer, release manager, or business analyst,   
//! designing systems with privacy in mind is a critical part of your work. For this reason, this library provides
//! functionality and components that help you implement PbD best practices.
//!
//!
//! #### Usage
//!
//! This crate follows the [privacy design strategies and tactics](https://github.com/dsietz/pbd/blob/master/docs/DESIGN-STRATEGIES.md) and is broken down into aligned features.
//! These features can be specified in Cargo.toml as a dependency.
//!
//! >[dependencies.pbd]
//! >version = "0.3"
//! >default-features = false
//! >features = ["dua"]
//!  
//!
//! ##### Feature List
//!
//! | Feature              | Package  | Default | Descripotion                                 |
//! | :------------------- | :------: | :-----: | :------------------------------------------- |
//! | Data Privacy Inspector | dpi    | true    | Inspects data to determine if it contains sensative content and requires data privacy handling |
//! | Data Tracker Chain   | dtc      | true    | Auditing of the data lineage                 |
//! | Data Security Guard  | dsg      | true    | Encryption and decryption of the data        |
//! | Data Usage Agreement | dua      | true    | Management of how data is allowed to be used |
//!
//!
//!
extern crate env_logger;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
extern crate derive_more;
extern crate json;
extern crate serde_json;

#[allow(dead_code)]
fn add(u: usize, i: i8) -> usize {
    if i.is_negative() {
        match u >= i.wrapping_abs() as usize {
            true => u - i.wrapping_abs() as u8 as usize,
            false => u,
        }
    } else {
        u + i as usize
    }
}

/// Takes a list of &str and returns a list of String
///
/// # Arguments
///
/// * list: Vec<&str> - The list of &str to convert to String.</br>
///
/// #Example
///
/// ```rust
/// use pbd::to_vec_string;
///
/// assert_eq!(
///     to_vec_string(vec!["one", "two", "three"]),
///     vec!["one".to_string(), "two".to_string(), "three".to_string()]
/// );
/// ```
#[allow(dead_code)]
pub fn to_vec_string(list: Vec<&str>) -> Vec<String> {
    list.iter().map(|s| s.to_string()).collect()
}

// Modules
#[cfg(feature = "dpi")]
pub mod dpi;
#[cfg(feature = "dsg")]
pub mod dsg;
#[cfg(feature = "dtc")]
pub mod dtc;
#[cfg(feature = "dua")]
pub mod dua;

// Unit Tests
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add() {
        let x: usize = 2;
        let y: i8 = -1;
        assert_eq!(add(x, y), 1);
    }

    #[test]
    fn test_to_vec_string() {
        assert_eq!(
            to_vec_string(vec!["one", "two", "three"]),
            vec!["one".to_string(), "two".to_string(), "three".to_string()]
        );
    }
}