Skip to main content

backbone_bucket/domain/value_objects/
actors.rs

1//! Actors value object
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! This is a DDD Value Object - immutable, no identity, equality by attributes.
6
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9#[cfg(feature = "openapi")]
10use utoipa::ToSchema;
11
12#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
13#[cfg_attr(feature = "openapi", derive(ToSchema))]
14pub struct Actors {
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub created_by: Option<Uuid>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub updated_by: Option<Uuid>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub deleted_by: Option<Uuid>,
21}
22
23impl Default for Actors {
24    fn default() -> Self {
25        Self {
26            created_by: None,
27            updated_by: None,
28            deleted_by: None,
29        }
30    }
31}
32
33impl Actors {
34    /// Create a new Actors value object
35    pub fn new(created_by: Option<Uuid>, updated_by: Option<Uuid>, deleted_by: Option<Uuid>) -> Self {
36        Self {
37            created_by,
38            updated_by,
39            deleted_by,
40        }
41    }
42
43    /// Create a builder for Actors
44    pub fn builder() -> ActorsBuilder {
45        <ActorsBuilder as Default>::default()
46    }
47
48}
49
50/// Builder for Actors value object
51#[derive(Debug, Clone, Default)]
52pub struct ActorsBuilder {
53    created_by: Option<Uuid>,
54    updated_by: Option<Uuid>,
55    deleted_by: Option<Uuid>,
56}
57
58impl ActorsBuilder {
59    /// Set the created_by field
60    pub fn created_by(mut self, value: Uuid) -> Self {
61        self.created_by = Some(value);
62        self
63    }
64
65    /// Set the updated_by field
66    pub fn updated_by(mut self, value: Uuid) -> Self {
67        self.updated_by = Some(value);
68        self
69    }
70
71    /// Set the deleted_by field
72    pub fn deleted_by(mut self, value: Uuid) -> Self {
73        self.deleted_by = Some(value);
74        self
75    }
76
77    /// Build the Actors value object
78    pub fn build(self) -> Result<Actors, String> {
79
80        let value = Actors {
81            created_by: self.created_by,
82            updated_by: self.updated_by,
83            deleted_by: self.deleted_by,
84        };
85
86        Ok(value)
87    }
88
89}