Skip to main content

poppler/auto/
attachment.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    #[doc(alias = "PopplerAttachment")]
11    pub struct Attachment(Object<ffi::PopplerAttachment, ffi::PopplerAttachmentClass>);
12
13    match fn {
14        type_ => || ffi::poppler_attachment_get_type(),
15    }
16}
17
18impl Attachment {
19    pub const NONE: Option<&'static Attachment> = None;
20}
21
22pub trait AttachmentExt: IsA<Attachment> + 'static {
23    //#[cfg(feature = "v20_9")]
24    //#[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
25    //#[doc(alias = "poppler_attachment_get_checksum")]
26    //#[doc(alias = "get_checksum")]
27    //fn checksum(&self) -> /*Ignored*/Option<glib::String> {
28    //    unsafe { TODO: call ffi:poppler_attachment_get_checksum() }
29    //}
30
31    #[cfg(feature = "v20_9")]
32    #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
33    #[doc(alias = "poppler_attachment_get_ctime")]
34    #[doc(alias = "get_ctime")]
35    fn ctime(&self) -> Option<glib::DateTime> {
36        unsafe {
37            from_glib_none(ffi::poppler_attachment_get_ctime(
38                self.as_ref().to_glib_none().0,
39            ))
40        }
41    }
42
43    #[cfg(feature = "v20_9")]
44    #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
45    #[doc(alias = "poppler_attachment_get_description")]
46    #[doc(alias = "get_description")]
47    fn description(&self) -> Option<glib::GString> {
48        unsafe {
49            from_glib_none(ffi::poppler_attachment_get_description(
50                self.as_ref().to_glib_none().0,
51            ))
52        }
53    }
54
55    #[cfg(feature = "v20_9")]
56    #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
57    #[doc(alias = "poppler_attachment_get_mtime")]
58    #[doc(alias = "get_mtime")]
59    fn mtime(&self) -> Option<glib::DateTime> {
60        unsafe {
61            from_glib_none(ffi::poppler_attachment_get_mtime(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66
67    #[cfg(feature = "v20_9")]
68    #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
69    #[doc(alias = "poppler_attachment_get_name")]
70    #[doc(alias = "get_name")]
71    fn name(&self) -> Option<glib::GString> {
72        unsafe {
73            from_glib_none(ffi::poppler_attachment_get_name(
74                self.as_ref().to_glib_none().0,
75            ))
76        }
77    }
78
79    #[cfg(feature = "v20_9")]
80    #[cfg_attr(docsrs, doc(cfg(feature = "v20_9")))]
81    #[doc(alias = "poppler_attachment_get_size")]
82    #[doc(alias = "get_size")]
83    fn size(&self) -> usize {
84        unsafe { ffi::poppler_attachment_get_size(self.as_ref().to_glib_none().0) }
85    }
86
87    #[doc(alias = "poppler_attachment_save")]
88    fn save(&self, filename: &str) -> Result<(), glib::Error> {
89        unsafe {
90            let mut error = std::ptr::null_mut();
91            let is_ok = ffi::poppler_attachment_save(
92                self.as_ref().to_glib_none().0,
93                filename.to_glib_none().0,
94                &mut error,
95            );
96            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
97            if error.is_null() {
98                Ok(())
99            } else {
100                Err(from_glib_full(error))
101            }
102        }
103    }
104
105    //#[doc(alias = "poppler_attachment_save_to_callback")]
106    //fn save_to_callback<P: FnMut(&Vec<u8>, usize, Option<&glib::Error>) -> bool>(&self, save_func: P) -> Result<(), glib::Error> {
107    //    unsafe { TODO: call ffi:poppler_attachment_save_to_callback() }
108    //}
109
110    #[cfg(feature = "v21_12")]
111    #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
112    #[doc(alias = "poppler_attachment_save_to_fd")]
113    fn save_to_fd(&self, fd: i32) -> Result<(), glib::Error> {
114        unsafe {
115            let mut error = std::ptr::null_mut();
116            let is_ok =
117                ffi::poppler_attachment_save_to_fd(self.as_ref().to_glib_none().0, fd, &mut error);
118            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
119            if error.is_null() {
120                Ok(())
121            } else {
122                Err(from_glib_full(error))
123            }
124        }
125    }
126}
127
128impl<O: IsA<Attachment>> AttachmentExt for O {}