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
//! DTO traits and helpers.
use serde::Serialize;
use crate::id::{ItemId, PaperlessId};
/// Marker trait for DTOs used to create new items.
pub trait CreateDto: Serialize {
/// The ID type for this item.
type Id: PaperlessId;
/// The base type for the DTO.
type BaseType: serde::de::DeserializeOwned;
}
/// Marker trait for DTOs used to update existing items.
pub trait UpdateDto: Serialize {
/// The ID type for this item.
type Id: PaperlessId;
/// The base type for the DTO.
type BaseType: serde::de::DeserializeOwned;
}
/// Trait for items that can be managed via the Paperless API.
pub trait Item: serde::de::DeserializeOwned {
/// The ID type for this item.
type Id: ItemId;
/// Returns the API endpoint for this item.
#[inline]
#[must_use]
fn endpoint() -> &'static str {
Self::Id::endpoint()
}
/// Returns the ID of this item.
#[must_use]
fn id(&self) -> Self::Id;
}