mycelium_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/// use mycelium_base::dtos::{Children, Parent};
15/// use serde::{Deserialize, Serialize};
16/// use utoipa::ToSchema;
17///
18/// #[derive(Debug, Deserialize, Serialize, Eq, PartialEq, ToSchema)]
19/// struct Post {
20///    id: i32,
21///    title: String,
22///    comments: Children<Comment, i32>,
23/// };
24///
25/// #[derive(Debug, Deserialize, Serialize, Eq, PartialEq, ToSchema)]
26/// struct Comment {
27///     post: Parent<Post, i32>,
28///     id: i32,
29///     text: String,
30/// };
31///
32/// let post_with_comments_as_ids = Post {
33///     id: 1,
34///     title: "Hello World".to_string(),
35///     comments: Children::Ids(vec![1, 2, 3]),
36/// };
37///
38/// let post_with_comments_as_records = Post {
39///     id: 1,
40///     title: "Hello World".to_string(),
41///     comments: Children::Records(vec![
42///         Comment {
43///             post: Parent::Id(1),
44///             id: 1,
45///             text: "Hello World from comment 1".to_string(),
46///         },
47///         Comment {
48///             post: Parent::Id(1),
49///             id: 2,
50///             text: "Hello World from comment 2".to_string(),
51///         },
52///         Comment {
53///             post: Parent::Id(1),
54///             id: 3,
55///             text: "Hello World from comment 3".to_string(),
56///         },
57///     ]),
58/// };
59/// ```
60///
61pub mod dtos;
62
63/// Defines default entities for clean architecture based projects
64///
65/// This module contains all the entities used in the project. Entities are
66/// the core of the project and are used to represent the business logic.
67/// Entities are not intended to be used as Data Transfer Objects.
68pub mod entities;
69
70/// Defines common utilities for error management
71///
72/// This module contains all the utilities used to manage errors in the project.
73/// These utilities are used to manage errors in a clean way.
74pub mod utils;