forge
Explore
Log in

Don't you dare go Hollow

hezarfen_backend

Clone
★ 0

0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits

pool_question_image.rs42 lines, 1.6 KiBHistoryRawDownload
1//! The photo of a pool question — one optional image row per question, the
2//! single-slot spelling of [`crate::domain::question_image`]'s child-table
3//! shape. The row carries metadata only; the bytes live on disk under
4//! [`crate::config::Config::files_path`] in a file named by `file` — a fresh
5//! server-generated id per upload, so a replace never overwrites bytes in
6//! place. The question row itself carries no image columns; the child row is
7//! the whole photo. The writes ride the parent's own transactions in
8//! [`crate::db::pool_question`] (pending-only, like every content write);
9//! the reads live in [`crate::db::pool_question_image`]; the web layer owns
10//! the blob I/O and its ordering (new blob before row, row before old blob).
11
12use crate::domain::note_file::FileContentType;
13use crate::domain::pool_question::PoolQuestionId;
14
15/// One question's photo row. `question` is the primary key — one image per
16/// question by construction, and a replace is a plain upsert.
17#[derive(Debug, Clone, sqlx::FromRow)]
18pub struct PoolQuestionImage {
19 pub(crate) question: PoolQuestionId,
20 /// The blob's on-disk name — a fresh server-generated id every upload.
21 pub(crate) file: String,
22 pub(crate) content_type: FileContentType,
23 pub(crate) size: i64,
24}
25
26impl PoolQuestionImage {
27 pub fn get_question(&self) -> &PoolQuestionId {
28 &self.question
29 }
30
31 pub fn get_file(&self) -> &str {
32 &self.file
33 }
34
35 pub fn get_content_type(&self) -> &FileContentType {
36 &self.content_type
37 }
38
39 pub fn get_size(&self) -> i64 {
40 self.size
41 }
42}