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
/// Defines default Data Transfer Auxiliary structs
///
/// This module contains all the auxiliary structs used to transfer data between
/// layers. These structs are used to transfer data between layers and are not
/// intended to be used as entities.
///
/// # Examples
///
/// If you want to create two related structs with database representations and
/// the relationship between them is established by a foreign key, you can use
/// Parent and Children.
///
/// ```
/// struct Post {
///    id: i32,
///    title: String,
///    comments: Children<Comment, i32>,
/// }
///
/// struct Comment {
///     post: Parent<Post, i32>,
///     id: i32,
///     text: String,
/// }
///
/// ```
///
/// Note that the relationship between Post and Comment is established by the
/// foreign key `parent` in Comment. This foreign key is represented by the
/// `Parent` struct. The `Parent` receives two generic parameters, the first one
/// is the type of the record and the second one is the type of the primary key.
/// In this case, the first parameter is Post and the second one is i32.
///
/// This, the instance representation of Post with comments as IDs would be:
///
/// ```
/// let post_with_comments_as_ids = Post {
///     id: 1,
///     title: "Hello World".to_string(),
///     comments: Children::Ids(vec![1, 2, 3]),
/// }
///
/// let post_with_comments_as_records = Post {
///     id: 1,
///     title: "Hello World".to_string(),
///     comments: Children::Records(vec![
///         Comment {
///             post: Parent::Id(1),
///             id: 1,
///             text: "Hello World from comment 1".to_string(),
///         },
///         Comment {
///             post: Parent::Id(1),
///             id: 2,
///             text: "Hello World from comment 2".to_string(),
///         },
///         Comment {
///             post: Parent::Id(1),
///             id: 3,
///             text: "Hello World from comment 3".to_string(),
///         },
///     ]),
/// }
/// ```
///
pub mod dtos;

/// Defines default entities for clean architecture based projects
///
/// This module contains all the entities used in the project. Entities are
/// the core of the project and are used to represent the business logic.
/// Entities are not intended to be used as Data Transfer Objects.
pub mod entities;

/// Defines common utilities for error management
///
/// This module contains all the utilities used to manage errors in the project.
/// These utilities are used to manage errors in a clean way.
pub mod utils;