Expand description
§MaaFramework Rust Bindings
High-performance, safe Rust bindings for MaaFramework, a game automation framework based on image recognition.
§Quick Start
use maa_framework::toolkit::Toolkit;
use maa_framework::controller::Controller;
use maa_framework::resource::Resource;
use maa_framework::tasker::Tasker;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 0. Load library (Dynamic only)
#[cfg(feature = "dynamic")]
maa_framework::load_library(std::path::Path::new("MaaFramework.dll"))?;
// 1. Find devices
let devices = Toolkit::find_adb_devices()?;
let device = devices.first().expect("No device found");
// 2. Create controller
let controller = Controller::new_adb(
device.adb_path.to_str().unwrap(),
&device.address,
"{}",
None,
)?;
// 3. Create resource and tasker
let resource = Resource::new()?;
let tasker = Tasker::new()?;
// 4. Bind and run
tasker.bind(&resource, &controller)?;
let job = tasker.post_task("StartTask", "{}")?;
job.wait();
Ok(())
}§Core Modules
| Module | Description |
|---|---|
tasker | Task execution and pipeline management |
resource | Resource loading (images, models, pipelines) |
controller | Device control (ADB, Win32, PlayCover) |
context | Task execution context for custom components |
toolkit | Device discovery utilities |
pipeline | Pipeline configuration types |
job | Asynchronous job management |
event_sink | Event sink system for typed callbacks |
buffer | Safe data buffers for FFI |
custom | Custom recognizer and action traits |
custom_controller | Custom controller implementation |
notification | Structured event notification parsing |
common | Common types and data structures |
error | Error types and handling |
util | Miscellaneous utility functions |
agent_client | Remote custom component client |
agent_server | Remote custom component server |
§Feature Flags
adb- ADB controller support (default)win32- Win32 controller support (Windows only)custom- Custom recognizer/action/controller supporttoolkit- Device discovery utilitiesimage- Integration with theimagecrate
Re-exports§
pub use common::ControllerFeature;pub use common::MaaStatus;pub use error::MaaError;pub use error::MaaResult;pub use maa_framework_sys as sys;
Modules§
- agent_
client - Agent client for connecting to AgentServer.
- agent_
server - Agent server for hosting custom components.
- buffer
- Safe buffer types for FFI data exchange.
- callback
- Internal callback infrastructure for FFI event handling.
- common
- Common types and data structures used throughout the SDK.
- context
- Task execution context for pipeline runtime operations.
- controller
- Device controller for input, screen capture, and app management.
- custom
- Custom recognizer and action components.
- custom_
controller - Custom controller implementation for user-defined device control.
- error
- Error types and result aliases for the MAA framework.
- event_
sink - Event sink system for typed callback notifications.
- job
- Asynchronous job management for tracking operation status and results.
- notification
- Structured notification parsing for event callbacks.
- pipeline
- Pipeline configuration types for recognition and action definitions.
- resource
- Resource management for pipelines, models, and images.
- tasker
- Task execution and pipeline management.
- toolkit
- Device discovery and configuration utilities.
- util
- Miscellaneous utility functions.
Functions§
- configure_
logging - Configure the log output directory.
- load_
plugin - Load a plugin from the specified path.
- maa_
version - Get the MaaFramework version string.
- set_
debug_ mode - Enable or disable debug mode.
- set_
draw_ quality - Set JPEG quality for saved draw images (0-100, default 85).
- set_
global_ option - Set a global framework option.
- set_
reco_ image_ cache_ limit - Set the recognition image cache limit (default 4096).
- set_
save_ draw - Enable/disable saving recognition visualizations to log directory.
- set_
save_ on_ error - Enable/disable saving screenshots on error.
- set_
stdout_ level - Set the log level for stdout output.