Expand description
Structured notification parsing for event callbacks.
This module provides typed structures and parsing utilities for the event notifications from MaaFramework. Instead of manually parsing JSON strings, use these helpers to work with strongly-typed event data.
§Example
use maa_framework::notification::{self, NotificationType};
use maa_framework::tasker::Tasker;
fn example(tasker: &Tasker) -> maa_framework::error::MaaResult<()> {
tasker.add_sink(|message, details| {
let noti_type = notification::parse_type(message);
if message.starts_with("Resource.Loading") {
if let Some(detail) = notification::parse_resource_loading(details) {
println!("Resource {} loading: {:?}", detail.res_id, noti_type);
}
}
})?;
Ok(())
}Modules§
- msg
- Notification message constants.
Structs§
- Controller
Action Detail - Controller action event detail.
- Next
List Item - Next list item for node traversal.
- Node
Action Detail - Node action event detail.
- Node
Next List Detail - Node next list event detail.
- Node
Pipeline Node Detail - Node pipeline node event detail.
- Node
Recognition Detail - Node recognition event detail.
- Resource
Loading Detail - Resource loading event detail.
- Tasker
Task Detail - Tasker task event detail.
Enums§
- Context
Event - Enum representing parsed Context events.
- MaaEvent
- Unified event enum for all framework notifications.
- Notification
Type - Type of notification event.
Traits§
- Context
Event Handler - Trait for handling context/node events.
- Controller
Event Handler - Trait for handling controller events.
- Resource
Event Handler - Trait for handling resource events.
- Tasker
Event Handler - Trait for handling tasker events.
Functions§
- parse_
controller_ action - Parse controller action event detail from JSON.
- parse_
node_ action - Parse node action event detail from JSON.
- parse_
node_ next_ list - Parse node next list event detail from JSON.
- parse_
node_ pipeline_ node - Parse node pipeline node event detail from JSON.
- parse_
node_ recognition - Parse node recognition event detail from JSON.
- parse_
resource_ loading - Parse resource loading event detail from JSON.
- parse_
tasker_ task - Parse tasker task event detail from JSON.
- parse_
type - Parse notification type from message string.