open_library/models/
works.rs

1use crate::format::KeyedValue;
2use crate::models::authors::{AuthorReference, AuthorType};
3use crate::models::{OpenLibraryModel, OpenLibraryResource};
4use chrono::NaiveDate;
5use serde::{Deserialize, Deserializer, Serialize};
6
7/// Represents a logical collection of similar Editions.
8// The fields present per Work varies by instance so to better understand the distribution a key
9// frequency distribution was created with 10 million records. This client won't support anything
10// over 20% until a reason to do so presents itself. For a detailed view of field frequencies, view
11// `models` directory README.
12#[derive(Deserialize, Debug, Eq, PartialEq, Serialize)]
13pub struct Work {
14    pub title: String,
15    #[serde(default)]
16    #[serde(skip_serializing_if = "Vec::is_empty")]
17    pub covers: Vec<i32>,
18    #[serde(default)]
19    #[serde(skip_serializing_if = "Vec::is_empty")]
20    pub subject_places: Vec<String>,
21    #[serde(default)]
22    #[serde(skip_serializing_if = "Vec::is_empty")]
23    pub subjects: Vec<String>,
24    pub key: OpenLibraryResource,
25    pub authors: Vec<AuthorReference>,
26    pub latest_revision: u32,
27    pub revision: u32,
28    // pub created: TODO need to support
29    // pub last_modified TODO need to support
30}
31
32impl OpenLibraryModel for Work {}