open-library-api-rs 0.1.0

Async Rust client for the Open Library API
Documentation
// v0.0.1
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Response from the Volumes (Partner) API.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumesResponse {
    #[serde(default)]
    pub records: HashMap<String, VolumeRecord>,
    #[serde(default)]
    pub items: Vec<VolumeItem>,
}

/// Bibliographic record for one book in a volumes response.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeRecord {
    #[serde(default)]
    pub url: Option<String>,
    #[serde(default)]
    pub key: Option<String>,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub authors: Option<Vec<VolumeAuthor>>,
    #[serde(default)]
    pub cover: Option<VolumeCover>,
    #[serde(default)]
    pub identifiers: Option<serde_json::Value>,
    #[serde(default)]
    pub classifications: Option<serde_json::Value>,
    #[serde(default)]
    pub publishers: Option<Vec<NamedEntity>>,
    #[serde(default)]
    pub publish_date: Option<String>,
    #[serde(default)]
    pub subjects: Option<Vec<NamedEntity>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeAuthor {
    #[serde(default)]
    pub url: Option<String>,
    #[serde(default)]
    pub name: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeCover {
    #[serde(default)]
    pub small: Option<String>,
    #[serde(default)]
    pub medium: Option<String>,
    #[serde(default)]
    pub large: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NamedEntity {
    pub name: String,
}

/// An item (borrowable/readable copy) in a volumes response.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeItem {
    #[serde(default)]
    pub match_type: Option<VolumeMatch>,
    #[serde(default)]
    pub status: Option<VolumeStatus>,
    #[serde(default)]
    pub from_record: Option<String>,
    #[serde(default)]
    pub url: Option<String>,
    #[serde(default)]
    pub cover: Option<VolumeCover>,
}

/// How closely this item matches the requested identifier.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum VolumeMatch {
    Exact,
    Similar,
    #[serde(other)]
    Other,
}

/// Borrowing/reading availability status.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum VolumeStatus {
    Borrowable,
    Readable,
    Limited,
    Unavailable,
    #[serde(other)]
    Other,
}