use crate::rubase::BaseEntity;
use crate::rulog;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use displaydoc::Display;
use crate::rubase::getself::GetSelf;
#[derive(Serialize, Default, Display,Deserialize, Debug, Clone)]
pub struct Person {
pub id: i64,
pub name: String,
pub age: u16,
pub active: bool,
}
impl BaseEntity for Person {}
impl GetSelf for Person {}
impl Display for Person {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_json().as_str())
}
}
impl Person {
pub fn log(&self) -> &Person {
rulog::info(self.to_json().as_str());
self
}
pub fn new() -> Person {
Person::default()
}
pub fn new_as(id: i64, name: String, age: u16, active: bool) -> Person {
Person {
id,
name,
age,
active,
}
}
}