35 lines
818 B
35 lines
818 B
use crate::models::schema::*; |
|
use diesel::{Insertable, Queryable}; |
|
use serde::{Deserialize, Serialize}; |
|
use std::time::SystemTime; |
|
use uuid::Uuid; |
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, Queryable, Insertable, PartialEq)] |
|
#[table_name = "errors"] |
|
pub struct AgentError { |
|
pub agent_id: Uuid, |
|
pub created: SystemTime, |
|
pub id: Uuid, |
|
pub msg: String, |
|
} |
|
|
|
impl AgentError { |
|
pub fn from_msg(msg: impl Into<String>, agent_id: Uuid) -> Self { |
|
AgentError { |
|
agent_id, |
|
msg: msg.into(), |
|
..Default::default() |
|
} |
|
} |
|
} |
|
|
|
impl Default for AgentError { |
|
fn default() -> Self { |
|
Self { |
|
agent_id: Uuid::new_v4(), |
|
created: SystemTime::now(), |
|
id: Uuid::new_v4(), |
|
msg: String::new(), |
|
} |
|
} |
|
}
|
|
|