use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::rubase::ruentity::json_serial::JsonSerializable;
pub trait BaseEntity {
fn if_single(&self) -> bool { false }
fn init(&mut self) {}
fn shutdown(&mut self) {}
fn auto_init(&self) -> bool { false }
fn to_json(&self) -> Result<String, serde_json::Error>
where
Self: Serialize,
{
serde_json::to_string_pretty(self) }
fn from_json(&self, from: String) -> Result<Self, serde_json::Error>
where
Self: Serialize + DeserializeOwned,
{
serde_json::from_str(from.as_str())
}
}