Expand description
The [dispatch!] macro — ergonomic, pattern-matching update handler.
Instead of writing giant match blocks, dispatch! lets you register
named handlers with optional guard clauses:
use layer_client::{Client, dispatch};
use layer_client::update::Update;
dispatch!(client, update,
NewMessage(msg) if !msg.outgoing() => {
println!("Got: {:?}", msg.text());
},
MessageEdited(msg) => {
println!("Edited: {:?}", msg.text());
},
CallbackQuery(cb) => {
client.answer_callback_query(cb.query_id, Some("✓"), false).await?;
},
_ => {} // catch-all for unhandled variants
);Each arm is VariantName(binding) [if guard] => { body }.
The macro expands to a plain match statement — zero overhead.