json_placeholder_data/comments/
mod.rs1use crate::{by_id, from_json};
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5const PLACEHOLDER_JSON_COMMENTS: &str = include_str!("comments.json");
6
7#[skip_serializing_none]
8#[derive(Deserialize, Serialize)]
9pub struct Comment {
10 #[serde(rename = "postId")]
11 pub post_id: i32,
12 pub id: Option<i32>,
13 pub name: String,
14 pub email: String,
15 pub body: String,
16}
17
18pub fn get_all() -> Vec<Comment> {
26 from_json!(PLACEHOLDER_JSON_COMMENTS)
27}
28
29pub fn get(id: i32) -> Comment {
40 by_id!(id)
41}