poppler/auto/
attachment.rs1use 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")]
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 #[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 {}