json-placeholder-data 0.2.1

Copy of the data on https://jsonplaceholder.typicode.com/ used in testing
Documentation
use crate::{by_id, from_json};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;

const PLACEHOLDER_JSON_PHOTOS: &str = include_str!("photos.json");

#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
pub struct Photo {
    #[serde(rename = "albumId")]
    pub album_id: i32,
    pub id: Option<i32>,
    pub title: String,
    pub url: String,
    #[serde(rename = "thumbnailUrl")]
    pub thumbnail_url: String,
}

/// Get all the photos available
///
/// # Example
/// ```
/// use json_placeholder_data::photos::get_all;
/// assert_eq!(get_all().len(), 5000);
/// ```
pub fn get_all() -> Vec<Photo> {
    from_json!(PLACEHOLDER_JSON_PHOTOS)
}

/// Get a photo by id
///
/// # Example
/// ```
/// use json_placeholder_data::photos::get;
/// assert_eq!(
///     get(3421).url.as_str(),
///     "https://via.placeholder.com/600/b13cb8",
/// );
/// ```
pub fn get(id: i32) -> Photo {
    by_id!(id)
}