use fleascope_rs::{FleaScope, ProbeType};
use std::time::Duration;
fn sync_example() -> Result<(), Box<dyn std::error::Error>> {
println!("=== Synchronous Usage ===");
let mut fleascope = FleaScope::connect(None, None, true)?;
let lazy_frame = fleascope.read(ProbeType::X1, Duration::from_millis(50), None, None)?;
let df = lazy_frame.collect()?;
println!("Sync read: {} data points", df.height());
Ok(())
}
async fn async_example() -> Result<(), Box<dyn std::error::Error>> {
println!("=== Async Usage (spawn_blocking) ===");
let result = tokio::task::spawn_blocking(
|| -> Result<usize, Box<dyn std::error::Error + Send + Sync>> {
let mut fleascope = FleaScope::connect(None, None, true)?;
let lazy_frame =
fleascope.read(ProbeType::X1, Duration::from_millis(50), None, None)?;
let df = lazy_frame.collect()?;
Ok(df.height())
},
)
.await??;
println!("Async read: {} data points", result);
Ok(())
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
sync_example()?;
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async_example())?;
Ok(())
}