ibapi 2.11.1

A Rust implementation of the Interactive Brokers TWS API, providing a reliable and user friendly interface for TWS and IB Gateway. Designed with a focus on simplicity and performance.
Documentation
//! Test trace functionality

use ibapi::client::blocking::Client;
use ibapi::trace;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init();

    println!("Testing trace functionality in sync mode...");

    // Connect to TWS/Gateway
    let client = Client::connect("127.0.0.1:4002", 100)?;
    println!("Connected to TWS/Gateway");

    // Make a simple request to trigger trace recording
    let server_time = client.server_time()?;
    println!("Server time: {server_time}");

    // Check if we captured the interaction
    if let Some(interaction) = trace::blocking::last_interaction() {
        println!("\nCaptured interaction:");
        println!("Request: {}", interaction.request);
        println!("Responses: {} response(s)", interaction.responses.len());
        for (i, response) in interaction.responses.iter().enumerate() {
            println!("  Response {}: {} bytes", i + 1, response.len());
            // Print first 100 chars of response
            if response.len() > 100 {
                println!("    {}...", &response[..100]);
            } else {
                println!("    {response}");
            }
        }
    } else {
        println!("No interaction captured (this shouldn't happen with debug logging)");
    }

    Ok(())
}