unistore-macros

Crates.iounistore-macros
lib.rsunistore-macros
version0.1.0
created_at2026-01-20 01:50:09.213721+00
updated_at2026-01-20 01:50:09.213721+00
descriptionProcedural macros for unistore framework
homepagehttps://github.com/yangbo1317/unistore
repositoryhttps://github.com/yangbo1317/unistore
max_upload_size
id2055650
size19,102
(yangbo1317)

documentation

https://docs.rs/unistore-macros

README

unistore-macros

Crates.io Documentation License

unistore 框架的过程宏集合

功能

#[derive(Event)] - 事件派生宏

自动为结构体实现 Event trait,用于 UniStore 的事件系统。

使用示例

基本用法

use unistore_macros::Event;

#[derive(Clone, Event)]
struct OrderCreated {
    order_id: u64,
    amount: f64,
}

// 自动生成 event_name() 方法,返回 "OrderCreated"

自定义事件名

#[derive(Clone, Event)]
#[event(name = "order.created")]
struct OrderCreated {
    order_id: u64,
}

// event_name() 返回 "order.created"

约束条件

  • 使用 #[derive(Event)] 的类型必须同时 derive Clone
  • 事件类型建议使用简单的数据结构

安装

[dependencies]
unistore-macros = "0.1.0"

License

Licensed under either of:

at your option.

Commit count: 0

cargo fmt