clean_base/
lib.rs

1/// Defines default Data Transfer Auxiliary structs
2///
3/// This module contains all the auxiliary structs used to transfer data between
4/// layers. These structs are used to transfer data between layers and are not
5/// intended to be used as entities.
6///
7/// # Examples
8///
9/// If you want to create two related structs with database representations and
10/// the relationship between them is established by a foreign key, you can use
11/// Parent and Children.
12///
13/// ```
14/// struct Post {
15///    id: i32,
16///    title: String,
17///    comments: Children<Comment, i32>,
18/// }
19///
20/// struct Comment {
21///     post: Parent<Post, i32>,
22///     id: i32,
23///     text: String,
24/// }
25///
26/// ```
27///
28/// Note that the relationship between Post and Comment is established by the
29/// foreign key `parent` in Comment. This foreign key is represented by the
30/// `Parent` struct. The `Parent` receives two generic parameters, the first one
31/// is the type of the record and the second one is the type of the primary key.
32/// In this case, the first parameter is Post and the second one is i32.
33///
34/// This, the instance representation of Post with comments as IDs would be:
35///
36/// ```
37/// let post_with_comments_as_ids = Post {
38///     id: 1,
39///     title: "Hello World".to_string(),
40///     comments: Children::Ids(vec![1, 2, 3]),
41/// }
42///
43/// let post_with_comments_as_records = Post {
44///     id: 1,
45///     title: "Hello World".to_string(),
46///     comments: Children::Records(vec![
47///         Comment {
48///             post: Parent::Id(1),
49///             id: 1,
50///             text: "Hello World from comment 1".to_string(),
51///         },
52///         Comment {
53///             post: Parent::Id(1),
54///             id: 2,
55///             text: "Hello World from comment 2".to_string(),
56///         },
57///         Comment {
58///             post: Parent::Id(1),
59///             id: 3,
60///             text: "Hello World from comment 3".to_string(),
61///         },
62///     ]),
63/// }
64/// ```
65///
66pub mod dtos;
67
68/// Defines default entities for clean architecture based projects
69///
70/// This module contains all the entities used in the project. Entities are
71/// the core of the project and are used to represent the business logic.
72/// Entities are not intended to be used as Data Transfer Objects.
73pub mod entities;
74
75/// Defines common utilities for error management
76///
77/// This module contains all the utilities used to manage errors in the project.
78/// These utilities are used to manage errors in a clean way.
79pub mod utils;