Skip to main content

pdfkit/
notifications.rs

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