cadmus_core/library/db/
models.rs

1use crate::db::types::{OptionalUuid7, UnixTimestamp, Uuid7};
2use sqlx::FromRow;
3
4/// Database row for the books table
5#[derive(Debug, Clone, FromRow)]
6pub struct BookRow {
7    pub fingerprint: String,
8    pub title: String,
9    pub subtitle: String,
10    pub year: String,
11    pub language: String,
12    pub publisher: String,
13    pub series: String,
14    pub edition: String,
15    pub volume: String,
16    pub number: String,
17    pub identifier: String,
18    pub file_path: String,
19    pub absolute_path: String,
20    pub file_kind: String,
21    pub file_size: i64,
22    pub added_at: UnixTimestamp,
23}
24
25/// Database row for the reading_states table
26#[derive(Debug, Clone, FromRow)]
27pub struct ReadingStateRow {
28    pub fingerprint: String,
29    pub opened: UnixTimestamp,
30    pub current_page: i64,
31    pub pages_count: i64,
32    pub finished: i64,
33    pub dithered: i64,
34    pub zoom_mode: Option<String>,
35    pub scroll_mode: Option<String>,
36    pub page_offset_x: Option<i64>,
37    pub page_offset_y: Option<i64>,
38    pub rotation: Option<i64>,
39    pub cropping_margins_json: Option<String>,
40    pub margin_width: Option<i64>,
41    pub screen_margin_width: Option<i64>,
42    pub font_family: Option<String>,
43    pub font_size: Option<f64>,
44    pub text_align: Option<String>,
45    pub line_height: Option<f64>,
46    pub contrast_exponent: Option<f64>,
47    pub contrast_gray: Option<f64>,
48    pub page_names_json: Option<String>,
49    pub bookmarks_json: Option<String>,
50    pub annotations_json: Option<String>,
51}
52
53/// Database row for the toc_entries table
54#[derive(Debug, Clone, FromRow)]
55pub struct TocEntryRow {
56    pub book_fingerprint: String,
57    pub id: Uuid7,
58    pub parent_id: OptionalUuid7,
59    pub position: i64,
60    pub title: String,
61    pub location_kind: String,
62    pub location_exact: Option<i64>,
63    pub location_uri: Option<String>,
64}