Skip to main content

Crate matroskin

Crate matroskin 

Source
Expand description

§matroskin

WhatsMiner v3 ApiDoc: https://apidoc.whatsminer.com

matroskin is an asynchronous Rust library designed for interacting with WhatsMiner devices. It provides an actor-based API to send commands and receive responses from WhatsMiner hardware, facilitating monitoring and control functionalities.

Warning: This library is developed primarily for personal use and may not be fully optimized or extensively tested for public production environments. Hardware timeouts (300ms) remain operational risks, and no physical hardware has been verified in CI.

Note: Creating an Actor requires an active Tokio runtime context, as it spawns an internal background task to manage connection lifecycle and mailboxes.

Current status: list of done commands

§Usage Example

use matroskin::actor::Actor;
use matroskin::account::Account;
use matroskin::password::Password;
use matroskin::command::get_device_info::GetDeviceInfo;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 0. (Optional) init logger
    tracing_subscriber::fmt()
        .compact()
        .with_max_level(tracing::Level::INFO)
        .without_time()
        .init();

    // 1. Initialize the actor in `Created` state (requires active Tokio runtime).
    let actor = Actor::new("10.10.10.10:4433", Account::Super, Password::Super);

    // 2. Queue connection intent.
    actor.connect()?;

    // 3. Send an owned command by value.
    // The command mailbox waits until the actor establishes a Connected session.
    let response = actor.send(GetDeviceInfo::all()).await?;
    println!("Response: {:#?}", response);

    // 4. Graceful non-blocking shutdown intent.
    actor.shutdown()?;
    Ok(())
}

Modules§

account
Define account module
actor
Autonomous actor and its single-owner lifecycle state machine.
auth_data
Define Auth Data module
command
Trait for Whatsminer commands
error
Error types for the matroskin crate.
password
Declare password module
permission
User permission model for WhatsMiner devices.
redacted
Secure display utilities for sensitive data.
request
Declare request module
response
API response types: ResponseCode enum + Response<T> struct.