pdfium_render/pdf/document/page/object/
unsupported.rs

1//! Defines the [PdfPageUnsupportedObject] struct, exposing functionality related to a single
2//! page object of type `PdfPageObjectType::Unsupported`.
3
4use crate::bindgen::{FPDF_DOCUMENT, FPDF_PAGEOBJECT};
5use crate::bindings::PdfiumLibraryBindings;
6use crate::error::PdfiumError;
7use crate::pdf::document::page::object::private::internal::PdfPageObjectPrivate;
8use crate::pdf::document::page::object::PdfPageObject;
9use crate::pdf::document::page::object::PdfPageObjectOwnership;
10
11/// A single `PdfPageObject` of any object type not supported by Pdfium.
12pub struct PdfPageUnsupportedObject<'a> {
13    object_handle: FPDF_PAGEOBJECT,
14    ownership: PdfPageObjectOwnership,
15    bindings: &'a dyn PdfiumLibraryBindings,
16}
17
18impl<'a> PdfPageUnsupportedObject<'a> {
19    pub(crate) fn from_pdfium(
20        object_handle: FPDF_PAGEOBJECT,
21        ownership: PdfPageObjectOwnership,
22        bindings: &'a dyn PdfiumLibraryBindings,
23    ) -> Self {
24        PdfPageUnsupportedObject {
25            object_handle,
26            ownership,
27            bindings,
28        }
29    }
30}
31
32impl<'a> PdfPageObjectPrivate<'a> for PdfPageUnsupportedObject<'a> {
33    #[inline]
34    fn object_handle(&self) -> FPDF_PAGEOBJECT {
35        self.object_handle
36    }
37
38    #[inline]
39    fn ownership(&self) -> &PdfPageObjectOwnership {
40        &self.ownership
41    }
42
43    #[inline]
44    fn set_ownership(&mut self, ownership: PdfPageObjectOwnership) {
45        self.ownership = ownership;
46    }
47
48    #[inline]
49    fn bindings(&self) -> &dyn PdfiumLibraryBindings {
50        self.bindings
51    }
52
53    #[inline]
54    fn is_copyable_impl(&self) -> bool {
55        false
56    }
57
58    #[inline]
59    fn try_copy_impl<'b>(
60        &self,
61        _: FPDF_DOCUMENT,
62        _: &'b dyn PdfiumLibraryBindings,
63    ) -> Result<PdfPageObject<'b>, PdfiumError> {
64        Err(PdfiumError::UnsupportedPdfPageObjectType)
65    }
66}