use serde::{Deserialize, Serialize}; use time::format_description::well_known::Rfc3339; use utoipa::ToSchema; use uuid::Uuid; #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct DeviceView { pub id: Uuid, pub device_name: Option, pub device_type: Option, pub os: Option, pub user_agent: Option, pub is_trusted: bool, pub first_seen_at: String, pub last_seen_at: String, pub created_at: String, pub updated_at: String, } impl From for DeviceView { fn from(m: db::user::user_devices::Model) -> Self { Self { id: m.id, device_name: m.device_name, device_type: m.device_type, os: m.os, user_agent: m.user_agent, is_trusted: m.is_trusted, first_seen_at: m.first_seen_at.format(&Rfc3339).unwrap_or_default(), last_seen_at: m.last_seen_at.format(&Rfc3339).unwrap_or_default(), created_at: m.created_at.format(&Rfc3339).unwrap_or_default(), updated_at: m.updated_at.format(&Rfc3339).unwrap_or_default(), } } } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] pub struct UpdateDeviceCmd { pub device_name: Option>, pub is_trusted: Option, }