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

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