pdfium_render/pdf/document/page/objects/
private.rs

1pub(crate) mod internal {
2    // We want to make the PdfPageObjectsPrivate trait private while providing a blanket
3    // implementation of PdfPageObjectsCommon for any type T where T: PdfPageObjectsPrivate.
4    // Rust complains, however, that by doing so we are leaking the private trait outside
5    // the crate.
6
7    // Instead of making the PdfPageObjectsPrivate trait private, we leave it public but place it
8    // inside this pub(crate) module in order to prevent it from being visible outside the crate.
9
10    use crate::bindings::PdfiumLibraryBindings;
11    use crate::error::PdfiumError;
12    use crate::pdf::document::page::object::PdfPageObject;
13    use crate::pdf::document::page::objects::common::{PdfPageObjectIndex, PdfPageObjectsIterator};
14    use crate::pdf::document::page::PdfPageObjectOwnership;
15
16    /// Internal crate-specific functionality common to all [PdfPageObjects] collections.
17    pub(crate) trait PdfPageObjectsPrivate<'a> {
18        /// Returns the ownership hierarchy for this page objects collection.
19        fn ownership(&self) -> &PdfPageObjectOwnership;
20
21        /// Returns the [PdfiumLibraryBindings] used by this page objects collection.
22        fn bindings(&self) -> &'a dyn PdfiumLibraryBindings;
23
24        /// Internal implementation of [PdfPageObjectsCommon::len()].
25        fn len_impl(&self) -> PdfPageObjectIndex;
26
27        /// Internal implementation of [PdfPageObjectsCommon::get()].
28        fn get_impl(&self, index: PdfPageObjectIndex) -> Result<PdfPageObject<'a>, PdfiumError>;
29
30        /// Internal implementation of [PdfPageObjectsCommon::iter()].
31        fn iter_impl(&'a self) -> PdfPageObjectsIterator<'a>;
32
33        /// Internal implementation of [PdfPageObjectsCommon::add_object()].
34        fn add_object_impl(
35            &mut self,
36            object: PdfPageObject<'a>,
37        ) -> Result<PdfPageObject<'a>, PdfiumError>;
38
39        /// Internal implementation of [PdfPageObjectsCommon::remove_object()].
40        fn remove_object_impl(
41            &mut self,
42            object: PdfPageObject<'a>,
43        ) -> Result<PdfPageObject<'a>, PdfiumError>;
44    }
45}