rustuya 0.2.3

A fast and concurrent Tuya Local API implementation in Rust
Documentation
/**
 * Device Scanner Example
 *
 * This example demonstrates how to use the synchronous scanner to find
 * Tuya devices on the local network in real-time using a standard iterator.
 */
use rustuya::sync::Scanner;

fn main() {
    println!("--- Rustuya Device Scanner Example ---");
    println!("[INFO] Scanning the network for Tuya devices in real-time...");

    // 1. Get a scan_stream (mpsc::Receiver) directly from Scanner
    let stream = Scanner::scan_stream();

    let mut count = 0;

    // 2. Process devices as they are discovered
    // Receiver implements IntoIterator, so we can use it in a for loop
    for device in stream {
        count += 1;
        println!(
            "[{}] Found Device: ID={}, IP={}, Version={:?}",
            count, device.id, device.ip, device.version
        );
    }

    println!("[INFO] Scan finished. Total devices found: {count}");
}