lib/models/
dummy.rs

1//! Defines dummy implementations for template validation.
2
3use std::collections::BTreeSet;
4
5use uuid::Uuid;
6
7use super::annotation::{Annotation, AnnotationMetadata, AnnotationStyle};
8use super::book::{Book, BookMetadata};
9use super::datetime::DateTimeUtc;
10use super::entry::Entry;
11
12impl Entry {
13    #[must_use]
14    pub(crate) fn dummy() -> Self {
15        let id = uuid::Uuid::new_v4();
16        Self {
17            book: Book::dummy(id),
18            annotations: vec![
19                Annotation::dummy(id),
20                Annotation::dummy(id),
21                Annotation::dummy(id),
22            ],
23        }
24    }
25}
26
27impl Book {
28    #[must_use]
29    pub(crate) fn dummy(id: Uuid) -> Self {
30        Self {
31            title: "Excepteur Sit Commodo".to_string(),
32            author: "Laborum Cillum".to_string(),
33            metadata: BookMetadata {
34                id: id.to_string(),
35                last_opened: Some(DateTimeUtc::default()),
36            },
37        }
38    }
39}
40
41impl Annotation {
42    #[must_use]
43    pub(crate) fn dummy(book_id: Uuid) -> Self {
44        Self {
45            body: "Elit consequat pariatur incididunt excepteur mollit.".to_string(),
46            style: AnnotationStyle::Underline,
47            notes: "Dolor ipsum officia non cillum.".to_string(),
48            tags: BTreeSet::from_iter(["#laboris", "#magna", "#nisi"].map(String::from)),
49            metadata: AnnotationMetadata {
50                id: Uuid::new_v4().to_string(),
51                book_id: book_id.to_string(),
52                created: DateTimeUtc::default(),
53                modified: DateTimeUtc::default(),
54                location: String::new(),
55                epubcfi: String::new(),
56            },
57        }
58    }
59}