readwhitepaper 0.1.1

Rust client for ReadWhitepaper — blockchain whitepaper database with 30 whitepapers, 163 glossary terms, and 15-language translations
Documentation
//! Type definitions for ReadWhitepaper API responses.
//!
//! 30 cryptocurrency whitepapers, 163 glossary terms,
//! 3,458 translations across 15 languages.

use serde::{Deserialize, Serialize};

/// Cryptocurrency metadata associated with a whitepaper.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Crypto {
    pub name: String,
    pub ticker: String,
    pub slug: String,
    pub website_url: String,
    pub brand_color: String,
    pub market_cap_rank: i32,
}

/// Whitepaper summary from list endpoint.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Whitepaper {
    pub crypto: Crypto,
    pub title: String,
    pub authors: Vec<String>,
    pub year: i32,
    #[serde(rename = "abstract")]
    pub abstract_text: String,
    pub total_sections: i32,
    pub available_languages: Vec<String>,
}

/// A section of whitepaper content.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Section {
    pub order: i32,
    pub section_number: String,
    pub heading_level: i32,
    #[serde(alias = "heading")]
    pub heading_text: String,
    pub content: String,
}

/// Full whitepaper detail including sections.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WhitepaperDetail {
    pub crypto: Crypto,
    pub title: String,
    pub authors: Vec<String>,
    pub year: i32,
    #[serde(rename = "abstract")]
    pub abstract_text: String,
    pub source_url: String,
    pub total_sections: i32,
    pub available_languages: Vec<String>,
    pub sections: Vec<Section>,
}

/// Table of contents entry.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TocEntry {
    pub order: i32,
    pub section_number: String,
    pub heading_level: i32,
    pub anchor_id: String,
    pub heading_en: String,
    pub heading: String,
    pub translated: bool,
}

/// TOC response wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TocResponse {
    pub slug: String,
    pub toc: Vec<TocEntry>,
}

/// Coverage for a single language.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LanguageCoverage {
    pub language: String,
    pub translated_sections: i32,
    pub total_sections: i32,
    pub completion_percent: f64,
}

/// Translation coverage for a whitepaper.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Coverage {
    pub slug: String,
    pub total_sections: i32,
    pub languages: Vec<LanguageCoverage>,
}

/// Blockchain glossary term with definition.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GlossaryTerm {
    pub term: String,
    pub slug: String,
    pub category: String,
    pub aliases: Vec<String>,
    pub definition: String,
    pub definition_html: String,
    pub occurrence_count: i32,
    pub translated_term: Option<String>,
    pub translated_definition: Option<String>,
    pub translated_definition_html: Option<String>,
}

/// A single search result from full-text search.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResult {
    pub slug: String,
    pub crypto: String,
    pub section_order: i32,
    pub anchor_id: String,
    pub language: String,
    pub heading: String,
    pub snippet: String,
    pub url: String,
}

/// Search response from the API.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResponse {
    pub query: String,
    pub language: String,
    pub count: i32,
    pub results: Vec<SearchResult>,
}

/// Aggregate counts.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatsTotals {
    pub active_cryptocurrencies: i32,
    pub whitepapers: i32,
    pub sections: i32,
    pub translations: i32,
}

/// Per-whitepaper statistics.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WhitepaperStats {
    pub slug: String,
    pub ticker: String,
    pub total_sections: i32,
    pub languages: Vec<serde_json::Value>,
}

/// Overall platform statistics.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stats {
    pub totals: StatsTotals,
    pub supported_languages: Vec<String>,
    pub by_slug: Vec<WhitepaperStats>,
}

/// Supported language metadata.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Language {
    pub code: String,
    pub name: String,
    pub native_name: String,
    pub direction: String,
}

/// Languages response wrapper.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LanguagesResponse {
    pub count: i32,
    pub results: Vec<Language>,
}

/// Node in the relationship graph.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphNode {
    pub id: String,
    pub label: String,
    #[serde(rename = "type")]
    pub node_type: String,
    pub slug: String,
    pub ticker: String,
    pub color: String,
    pub year: i32,
}

/// Edge in the relationship graph.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphEdge {
    pub source: String,
    pub target: String,
    #[serde(rename = "type")]
    pub edge_type: String,
    #[serde(default = "default_weight")]
    pub weight: f64,
}

fn default_weight() -> f64 {
    1.0
}

/// Full relationship graph data.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphData {
    pub nodes: Vec<GraphNode>,
    pub edges: Vec<GraphEdge>,
}

/// Paginated API response.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaginatedResponse<T> {
    pub count: i32,
    pub next: Option<String>,
    pub previous: Option<String>,
    pub results: Vec<T>,
}