pdfium/struct_element_attr_value.rs
1// PDFium-rs -- Modern Rust wrapper to PDFium, the PDF library from Google
2//
3// Copyright (c) 2025 Martin van der Werff <github (at) newinnovations.nl>
4//
5// This file is part of PDFium-rs.
6//
7// PDFium-rs is free software: you can redistribute it and/or modify it under the terms of
8// the GNU General Public License as published by the Free Software Foundation, either version 3
9// of the License, or (at your option) any later version.
10//
11// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
12// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
13// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
16// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
17// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20use crate::{
21 error::{PdfiumError, PdfiumResult},
22 pdfium_types::FPDF_STRUCTELEMENT_ATTR_VALUE,
23};
24
25/// # Rust interface to FPDF_STRUCTELEMENT_ATTR_VALUE
26pub struct PdfiumStructElementAttrValue {
27 handle: FPDF_STRUCTELEMENT_ATTR_VALUE,
28}
29
30impl PdfiumStructElementAttrValue {
31 pub(crate) fn new_from_handle(handle: FPDF_STRUCTELEMENT_ATTR_VALUE) -> PdfiumResult<Self> {
32 if handle.is_null() {
33 Err(PdfiumError::NullHandle)
34 } else {
35 #[cfg(feature = "debug_print")]
36 println!("New struct_element_attr_value {handle:?}");
37 Ok(Self { handle })
38 }
39 }
40}
41
42impl From<&PdfiumStructElementAttrValue> for FPDF_STRUCTELEMENT_ATTR_VALUE {
43 fn from(value: &PdfiumStructElementAttrValue) -> Self {
44 value.handle
45 }
46}
47
48// TODO: check lifecycle FPDF_STRUCTELEMENT_ATTR_VALUE
49
50impl Drop for PdfiumStructElementAttrValue {
51 /// # Closes this [`PdfiumStructElementAttrValue`], releasing held memory.
52 fn drop(&mut self) {
53 #[cfg(feature = "debug_print")]
54 println!("Closing struct_element_attr_value {:?}", self.handle);
55 }
56}