home_dto.rs 43 lignes · 1011 octets
/// Home Page Data Transfer Objects
/// Feature 004: UI Post-Auth
///
/// Defines the data structures for the home page after authentication.
use serde::{Deserialize, Serialize};

/// An account statistic to display
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountStatDTO {
    /// Stat label (e.g., "Username", "Email")
    pub label: String,

    /// Stat value
    pub value: String,

    /// Icon name
    pub icon: String,
}

impl AccountStatDTO {
    /// Create a new account stat
    pub fn new(label: &str, value: &str, icon: &str) -> Self {
        Self {
            label: label.to_string(),
            value: value.to_string(),
            icon: icon.to_string(),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_account_stat_new() {
        let stat = AccountStatDTO::new("Username", "john_doe", "user");

        assert_eq!(stat.label, "Username");
        assert_eq!(stat.value, "john_doe");
        assert_eq!(stat.icon, "user");
    }
}