Skip to main content

Module notification

Module notification 

Source
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§

ControllerActionDetail
Controller action event detail.
NextListItem
Next list item for node traversal.
NodeActionDetail
Node action event detail.
NodeNextListDetail
Node next list event detail.
NodePipelineNodeDetail
Node pipeline node event detail.
NodeRecognitionDetail
Node recognition event detail.
ResourceLoadingDetail
Resource loading event detail.
TaskerTaskDetail
Tasker task event detail.

Enums§

ContextEvent
Enum representing parsed Context events.
MaaEvent
Unified event enum for all framework notifications.
NotificationType
Type of notification event.

Traits§

ContextEventHandler
Trait for handling context/node events.
ControllerEventHandler
Trait for handling controller events.
ResourceEventHandler
Trait for handling resource events.
TaskerEventHandler
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.