Skip to main content

pdfkit/
notifications.rs

1/// Wraps `PDFDocument notification` constants.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum PdfDocumentNotification {
4    /// Wraps the corresponding `PDFDocument` notification constant.
5    DidUnlock,
6    /// Wraps the corresponding `PDFDocument` notification constant.
7    DidBeginFind,
8    /// Wraps the corresponding `PDFDocument` notification constant.
9    DidEndFind,
10    /// Wraps the corresponding `PDFDocument` notification constant.
11    DidBeginPageFind,
12    /// Wraps the corresponding `PDFDocument` notification constant.
13    DidEndPageFind,
14    /// Wraps the corresponding `PDFDocument` notification constant.
15    DidFindMatch,
16    /// Wraps the corresponding `PDFDocument` notification constant.
17    DidBeginWrite,
18    /// Wraps the corresponding `PDFDocument` notification constant.
19    DidEndWrite,
20    /// Wraps the corresponding `PDFDocument` notification constant.
21    DidBeginPageWrite,
22    /// Wraps the corresponding `PDFDocument` notification constant.
23    DidEndPageWrite,
24}
25
26impl PdfDocumentNotification {
27    /// Returns the corresponding PDFKit constant name.
28    #[must_use]
29    pub const fn name(self) -> &'static str {
30        match self {
31            Self::DidUnlock => "PDFDocumentDidUnlockNotification",
32            Self::DidBeginFind => "PDFDocumentDidBeginFindNotification",
33            Self::DidEndFind => "PDFDocumentDidEndFindNotification",
34            Self::DidBeginPageFind => "PDFDocumentDidBeginPageFindNotification",
35            Self::DidEndPageFind => "PDFDocumentDidEndPageFindNotification",
36            Self::DidFindMatch => "PDFDocumentDidFindMatchNotification",
37            Self::DidBeginWrite => "PDFDocumentDidBeginWriteNotification",
38            Self::DidEndWrite => "PDFDocumentDidEndWriteNotification",
39            Self::DidBeginPageWrite => "PDFDocumentDidBeginPageWriteNotification",
40            Self::DidEndPageWrite => "PDFDocumentDidEndPageWriteNotification",
41        }
42    }
43
44    pub(crate) const fn from_raw(raw: i32) -> Option<Self> {
45        match raw {
46            0 => Some(Self::DidUnlock),
47            1 => Some(Self::DidBeginFind),
48            2 => Some(Self::DidEndFind),
49            3 => Some(Self::DidBeginPageFind),
50            4 => Some(Self::DidEndPageFind),
51            5 => Some(Self::DidFindMatch),
52            6 => Some(Self::DidBeginWrite),
53            7 => Some(Self::DidEndWrite),
54            8 => Some(Self::DidBeginPageWrite),
55            9 => Some(Self::DidEndPageWrite),
56            _ => None,
57        }
58    }
59}
60
61/// Wraps `PDFDocument notification user-info key` constants.
62#[derive(Debug, Clone, Copy, PartialEq, Eq)]
63pub enum PdfDocumentNotificationUserInfoKey {
64    /// Wraps the corresponding `PDFDocument` user-info key.
65    FoundSelection,
66    /// Wraps the corresponding `PDFDocument` user-info key.
67    PageIndex,
68}
69
70impl PdfDocumentNotificationUserInfoKey {
71    /// Returns the corresponding PDFKit constant name.
72    #[must_use]
73    pub const fn name(self) -> &'static str {
74        match self {
75            Self::FoundSelection => "PDFDocumentFoundSelection",
76            Self::PageIndex => "PDFDocumentPageIndex",
77        }
78    }
79}
80
81/// Wraps `PDFView notification` constants.
82#[derive(Debug, Clone, Copy, PartialEq, Eq)]
83pub enum PdfViewNotification {
84    /// Wraps the corresponding `PDFView` notification constant.
85    AnnotationHit,
86    /// Wraps the corresponding `PDFView` notification constant.
87    AnnotationWillHit,
88    /// Wraps the corresponding `PDFView` notification constant.
89    ChangedHistory,
90    /// Wraps the corresponding `PDFView` notification constant.
91    CopyPermission,
92    /// Wraps the corresponding `PDFView` notification constant.
93    DisplayBoxChanged,
94    /// Wraps the corresponding `PDFView` notification constant.
95    DisplayModeChanged,
96    /// Wraps the corresponding `PDFView` notification constant.
97    DocumentChanged,
98    /// Wraps the corresponding `PDFView` notification constant.
99    PageChanged,
100    /// Wraps the corresponding `PDFView` notification constant.
101    PrintPermission,
102    /// Wraps the corresponding `PDFView` notification constant.
103    ScaleChanged,
104    /// Wraps the corresponding `PDFView` notification constant.
105    SelectionChanged,
106    /// Wraps the corresponding `PDFView` notification constant.
107    VisiblePagesChanged,
108}
109
110impl PdfViewNotification {
111    /// Returns the corresponding PDFKit constant name.
112    #[must_use]
113    pub const fn name(self) -> &'static str {
114        match self {
115            Self::AnnotationHit => "PDFViewAnnotationHitNotification",
116            Self::AnnotationWillHit => "PDFViewAnnotationWillHitNotification",
117            Self::ChangedHistory => "PDFViewChangedHistoryNotification",
118            Self::CopyPermission => "PDFViewCopyPermissionNotification",
119            Self::DisplayBoxChanged => "PDFViewDisplayBoxChangedNotification",
120            Self::DisplayModeChanged => "PDFViewDisplayModeChangedNotification",
121            Self::DocumentChanged => "PDFViewDocumentChangedNotification",
122            Self::PageChanged => "PDFViewPageChangedNotification",
123            Self::PrintPermission => "PDFViewPrintPermissionNotification",
124            Self::ScaleChanged => "PDFViewScaleChangedNotification",
125            Self::SelectionChanged => "PDFViewSelectionChangedNotification",
126            Self::VisiblePagesChanged => "PDFViewVisiblePagesChangedNotification",
127        }
128    }
129}
130
131/// Wraps `PDFThumbnailView notification` constants.
132#[derive(Debug, Clone, Copy, PartialEq, Eq)]
133pub enum PdfThumbnailViewNotification {
134    /// Wraps the corresponding `PDFThumbnailView` notification constant.
135    DocumentEdited,
136}
137
138impl PdfThumbnailViewNotification {
139    /// Returns the corresponding PDFKit constant name.
140    #[must_use]
141    pub const fn name(self) -> &'static str {
142        match self {
143            Self::DocumentEdited => "PDFThumbnailViewDocumentEditedNotification",
144        }
145    }
146}