Skip to main content

paperless_api/
share_link.rs

1//! Types related to share links.
2
3use std::sync::Arc;
4
5use derive_more::Display;
6use serde::{Deserialize, Serialize};
7
8/// The version of the file provided by a share link.
9#[derive(Debug, Display, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
10#[serde(rename_all = "lowercase")]
11pub enum ShareLinkFileVersion {
12    /// The "current" file version in the paperless archive.
13    /// This version might be modified by paperless.
14    Archive,
15
16    /// The original file version initially uploaded to paperless.
17    Original,
18}
19
20/// A share link
21#[derive(Debug, Clone, Deserialize)]
22pub struct ShareLink {
23    /// Unique identifier of the share link.
24    pub id: crate::id::ShareLinkId,
25
26    /// Document of the share link.
27    pub document: crate::id::DocumentId,
28
29    /// File version of the share link.
30    pub file_version: ShareLinkFileVersion,
31
32    /// Slug of the share link.
33    pub slug: String,
34
35    #[serde(skip)]
36    pub(crate) base_url: Arc<str>,
37}
38
39impl ShareLink {
40    #[must_use]
41    pub fn url(&self) -> String {
42        format!("{}/share/{}", self.base_url, self.slug)
43    }
44}