backbone-bucket 0.3.0

Bucket Bounded Context: File Storage Module for Backbone Framework
Documentation
//! StorageSize value object
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This is a DDD Value Object - immutable, no identity, equality by attributes.

use serde::{Deserialize, Serialize};
#[cfg(feature = "openapi")]
use utoipa::ToSchema;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct StorageSize {
    pub size_bytes: i64,
}

impl StorageSize {
    /// Create a new StorageSize value object
    pub fn new(size_bytes: i64) -> Self {
        Self {
            size_bytes,
        }
    }

    /// Create a builder for StorageSize
    pub fn builder() -> StorageSizeBuilder {
        <StorageSizeBuilder as Default>::default()
    }

}

/// Builder for StorageSize value object
#[derive(Debug, Clone, Default)]
pub struct StorageSizeBuilder {
    size_bytes: Option<i64>,
}

impl StorageSizeBuilder {
    /// Set the size_bytes field
    pub fn size_bytes(mut self, value: i64) -> Self {
        self.size_bytes = Some(value);
        self
    }

    /// Build the StorageSize value object
    pub fn build(self) -> Result<StorageSize, String> {
        let size_bytes = self.size_bytes.ok_or_else(|| "size_bytes is required".to_string())?;

        let value = StorageSize {
            size_bytes,
        };

        Ok(value)
    }

}