pdfium_render/pdf/document/page/annotation/
redacted.rs

1//! Defines the [PdfPageRedactedAnnotation] struct, exposing functionality related to a single
2//! user annotation of type `PdfPageAnnotationType::Redacted`.
3
4use crate::bindgen::{FPDF_ANNOTATION, FPDF_DOCUMENT, FPDF_PAGE};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::pdf::document::page::annotation::attachment_points::PdfPageAnnotationAttachmentPoints;
7use crate::pdf::document::page::annotation::objects::PdfPageAnnotationObjects;
8use crate::pdf::document::page::annotation::private::internal::PdfPageAnnotationPrivate;
9
10/// A single `PdfPageAnnotation` of type `PdfPageAnnotationType::Redacted`.
11pub struct PdfPageRedactedAnnotation<'a> {
12    handle: FPDF_ANNOTATION,
13    objects: PdfPageAnnotationObjects<'a>,
14    attachment_points: PdfPageAnnotationAttachmentPoints<'a>,
15    bindings: &'a dyn PdfiumLibraryBindings,
16}
17
18impl<'a> PdfPageRedactedAnnotation<'a> {
19    pub(crate) fn from_pdfium(
20        document_handle: FPDF_DOCUMENT,
21        page_handle: FPDF_PAGE,
22        annotation_handle: FPDF_ANNOTATION,
23        bindings: &'a dyn PdfiumLibraryBindings,
24    ) -> Self {
25        PdfPageRedactedAnnotation {
26            handle: annotation_handle,
27            objects: PdfPageAnnotationObjects::from_pdfium(
28                document_handle,
29                page_handle,
30                annotation_handle,
31                bindings,
32            ),
33            attachment_points: PdfPageAnnotationAttachmentPoints::from_pdfium(
34                annotation_handle,
35                bindings,
36            ),
37            bindings,
38        }
39    }
40}
41
42impl<'a> PdfPageAnnotationPrivate<'a> for PdfPageRedactedAnnotation<'a> {
43    #[inline]
44    fn handle(&self) -> FPDF_ANNOTATION {
45        self.handle
46    }
47
48    #[inline]
49    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
50        self.bindings
51    }
52
53    #[inline]
54    fn objects_impl(&self) -> &PdfPageAnnotationObjects {
55        &self.objects
56    }
57
58    #[inline]
59    fn objects_mut_impl(&mut self) -> &mut PdfPageAnnotationObjects<'a> {
60        &mut self.objects
61    }
62
63    #[inline]
64    fn attachment_points_impl(&self) -> &PdfPageAnnotationAttachmentPoints {
65        &self.attachment_points
66    }
67
68    #[inline]
69    fn attachment_points_mut_impl(&mut self) -> &mut PdfPageAnnotationAttachmentPoints<'a> {
70        &mut self.attachment_points
71    }
72}