Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Reference

Links to detailed API documentation and developer resources.

Rustdoc Documentation

The complete API documentation is available in the rustdoc section of this site.

Public API Overview

Core Functions

Output Modules

CLI Interface

Usage Examples

Basic Library Usage

use gold_digger::{rows_to_strings, csv};
use mysql::{Pool, Row};
use std::fs::File;

// Convert database rows and write CSV
let rows: Vec<Row> = /* query results */;
let string_rows = rows_to_strings(rows)?;
let output = File::create("output.csv")?;
csv::write(string_rows, output)?;

Custom Format Implementation

use anyhow::Result;
use std::io::Write;

pub fn write<W: Write>(rows: Vec<Vec<String>>, mut output: W) -> Result<()> {
    for row in rows {
        writeln!(output, "{}", row.join("|"))?;
    }
    Ok(())
}

Type Definitions

Key types used throughout the codebase:

  • Vec<Vec<String>> - Standard row format for output modules
  • anyhow::Result<T> - Error handling pattern
  • mysql::Row - Database result row type

Error Handling

All public functions return anyhow::Result<T> for consistent error handling:

use anyhow::Result;

fn example_function() -> Result<()> {
    // Function implementation
    Ok(())
}

Feature Flags

Conditional compilation based on Cargo features:

#[cfg(feature = "csv")]
pub mod csv;

#[cfg(feature = "json")]
pub mod json;

#[cfg(feature = "verbose")]
println!("Debug information");