json_placeholder_data/todos/
mod.rs1use crate::{by_id, from_json};
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5const PLACEHOLDER_JSON_TODOS: &str = include_str!("todos.json");
6
7#[skip_serializing_none]
8#[derive(Deserialize, Serialize)]
9pub struct Todo {
10 #[serde(rename = "userId")]
11 pub user_id: i32,
12 pub id: Option<i32>,
13 pub title: String,
14 pub completed: bool,
15}
16
17pub fn get_all() -> Vec<Todo> {
25 from_json!(PLACEHOLDER_JSON_TODOS)
26}
27
28pub fn get(id: i32) -> Todo {
39 by_id!(id)
40}