ruwebframe 0.1.2

a simple webframe for rust actix-web, based on rudi and rbatis.
Documentation
use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::rubase::rutils::jsonutils;

//多实例
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) -> String
    where
        Self: Serialize,
    {
        jsonutils::struct2json(&self).unwrap()
    }
    fn from_json( &self, from: String) -> Self
    where
        Self: Serialize+DeserializeOwned,
    {
        jsonutils::json2struct(from.as_str()).unwrap()
    }
}
 
// 使用 macro_rules! 定义派生宏
// 注意:语法为 derive() (struct ...)
// macro_rules! TraitEntity {
//     // derive() 规则处理结构体
//     derive() (struct $name:ident $($rest:tt)*) => {
//     impl TraitEntity for $name {
//     fn entity_name() -> &'static str {
//     stringify!($name)
//     }
//     }
//     };
//     // 可以添加更多规则以支持 enum、union 等
// }