1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use serde::Serialize;
use crate::utils;
use super::annotation::Annotation;
use super::book::Book;
#[derive(Debug, Default, Clone, Serialize)]
pub struct Entry {
pub book: Book,
pub annotations: Vec<Annotation>,
}
impl Entry {
#[must_use]
pub fn slug_name(&self) -> String {
format!(
"{}--{}",
utils::to_slug_string(&self.book.author, '-'),
utils::to_slug_string(&self.book.title, '-'),
)
}
}
impl From<Book> for Entry {
fn from(book: Book) -> Self {
Self {
book,
annotations: Vec::new(),
}
}
}