Skip to main content

paperless_api/
id.rs

1use derive_more::Display;
2use serde::{Deserialize, Serialize};
3
4/// Macro for defining ID wrapper types
5macro_rules! define_ids {
6    ($($def:tt),* $(,)?) => {
7        $(define_ids!(@single $def);)*
8    };
9
10    (@single ($name:ident, $type:ty)) => {
11        #[derive(Debug, Display, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
12        #[repr(transparent)]
13        pub struct $name(pub $type);
14    };
15    (@single ($name:ident, $type:ty, noncopy)) => {
16        #[derive(Debug, Display, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
17        #[repr(transparent)]
18        pub struct $name(pub $type);
19    };
20}
21
22define_ids!(
23    (CorrespondentId, u32),
24    (CustomFieldId, u32),
25    (DocumentId, u32),
26    (DocumentTypeId, u32),
27    (NoteId, u32),
28    (ShareLinkId, u32),
29    (TagId, u32),
30    (TaskId, String, noncopy),
31    (UserId, u32),
32    (WorkflowActionId, u32),
33    (WorkflowId, u32),
34    (WorkflowTriggerId, u32),
35    (WebhookActionId, u32),
36);