========================================

wd<em>event GitHub Actions wd</em>event on crates.io wd_event on docs.rs License

This is a Rust async event Crate. Compared to the previous version, this is a brand new version. Not compatible with previous versions

Getting Started

wd_event is available on crates.io. It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.

At the point of the last update of this README, the latest published version could be used like this:

Add the following dependency to your Cargo manifest... rust [dependencies] wd_event = "0.4"

Example

```rust struct Message{ id : u64, value: V, } impl Message { fn new(id:u64,value:V)->Message{ Self{id,value} } } fn generateevententity()->Event{ EventSchedule::default() .register(|ctx:Context, mut msg:Message|{ println!("this is first Message handler ID[{}]--> {}",msg.id,msg.value); msg.value.pushstr("->one"); ctx.next(msg) // no need async }) .register(|ctx:Context, mut msg:Message|async{ println!("this is second Message handler ID[{}]--> {}",msg.id,msg.value); msg.value.pushstr("->two"); ctx.next(msg).await //all is async }) .register(|ctx:Context, mut msg:Message|{ println!("this is third Message handle ID[{}]--> {}",msg.id,msg.value); msg.value = 3; async move{ ctx.next(msg).await //part is async } }) .build() }

[tokio::test]

async fn testmessage(){ let event = generateevententity(); let res = event.launch(Context::default(),Message::new(1,"hello world".tostring())).await.expect("first test handle failed"); asserteq!(res.value.asstr(),"hello world->one->two","Message result assert failed"); let res = event.launch(Context::default(),Message::new(1,1i64)).await.expect("second test failed"); assert_eq!(res.value,3i64,"Message result assert failed") } `` **attention:** - the event handler executes in the order of registration,ctx.nextrepresenting the next handler to execute the event -Context` can deliver messages in context - Settings on context take precedence over global Settings

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.