pdfium_render/pdf/document/page/annotation/
highlight.rs1use std::marker::PhantomData;
5
6use crate::bindgen::{FPDF_ANNOTATION, FPDF_DOCUMENT, FPDF_PAGE};
7use crate::pdf::document::page::annotation::attachment_points::PdfPageAnnotationAttachmentPoints;
8use crate::pdf::document::page::annotation::objects::PdfPageAnnotationObjects;
9use crate::pdf::document::page::annotation::private::internal::PdfPageAnnotationPrivate;
10use crate::pdf::document::page::object::ownership::PdfPageObjectOwnership;
11use crate::pdf::document::page::objects::private::internal::PdfPageObjectsPrivate;
12use crate::pdfium::PdfiumLibraryBindingsAccessor;
13
14#[cfg(doc)]
15use {
16 crate::pdf::document::page::annotation::PdfPageAnnotation,
17 crate::pdf::document::page::annotation::PdfPageAnnotationType,
18};
19
20pub struct PdfPageHighlightAnnotation<'a> {
22 handle: FPDF_ANNOTATION,
23 objects: PdfPageAnnotationObjects<'a>,
24 attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
25 lifetime: PhantomData<&'a FPDF_ANNOTATION>,
26}
27
28impl<'a> PdfPageHighlightAnnotation<'a> {
29 pub(crate) fn from_pdfium(
30 document_handle: FPDF_DOCUMENT,
31 page_handle: FPDF_PAGE,
32 annotation_handle: FPDF_ANNOTATION,
33 ) -> Self {
34 PdfPageHighlightAnnotation {
35 handle: annotation_handle,
36 objects: PdfPageAnnotationObjects::from_pdfium(
37 document_handle,
38 page_handle,
39 annotation_handle,
40 ),
41 attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(annotation_handle),
42 lifetime: PhantomData,
43 }
44 }
45
46 #[inline]
48 pub fn attachment_points_mut(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
49 &mut self.attachment_points
50 }
51}
52
53impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageHighlightAnnotation<'a> {
54 #[inline]
55 fn handle(&self) -> FPDF_ANNOTATION {
56 self.handle
57 }
58
59 #[inline]
60 fn ownership(&self) -> &PdfPageObjectOwnership {
61 self.objects_impl().ownership()
62 }
63
64 #[inline]
65 fn objects_impl(&self) -> &PdfPageAnnotationObjects<'_> {
66 &self.objects
67 }
68
69 #[inline]
70 fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints<'_> {
71 &self.attachment_points
72 }
73}
74
75impl<'a> PdfiumLibraryBindingsAccessor<'a> for PdfPageHighlightAnnotation<'a> {}
76
77#[cfg(feature = "thread_safe")]
78unsafe impl<'a> Send for PdfPageHighlightAnnotation<'a> {}
79
80#[cfg(feature = "thread_safe")]
81unsafe impl<'a> Sync for PdfPageHighlightAnnotation<'a> {}