Skip to content
Clone
030e59e
41 lines 1.3 KB Rust
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<String>,
pub device_type: Option<String>,
pub os: Option<String>,
pub user_agent: Option<String>,
pub is_trusted: bool,
pub first_seen_at: String,
pub last_seen_at: String,
pub created_at: String,
pub updated_at: String,
}
impl From<db::user::user_devices::Model> 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<Option<String>>,
pub is_trusted: Option<bool>,
}