gio/auto/
zlib_decompressor.rs1use crate::{Converter, FileInfo, ZlibCompressorFormat, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GZlibDecompressor")]
36 pub struct ZlibDecompressor(Object<ffi::GZlibDecompressor, ffi::GZlibDecompressorClass>) @implements Converter;
37
38 match fn {
39 type_ => || ffi::g_zlib_decompressor_get_type(),
40 }
41}
42
43impl ZlibDecompressor {
44 #[doc(alias = "g_zlib_decompressor_new")]
52 pub fn new(format: ZlibCompressorFormat) -> ZlibDecompressor {
53 unsafe { from_glib_full(ffi::g_zlib_decompressor_new(format.into_glib())) }
54 }
55
56 #[doc(alias = "g_zlib_decompressor_get_file_info")]
62 #[doc(alias = "get_file_info")]
63 #[doc(alias = "file-info")]
64 pub fn file_info(&self) -> Option<FileInfo> {
65 unsafe {
66 from_glib_none(ffi::g_zlib_decompressor_get_file_info(
67 self.to_glib_none().0,
68 ))
69 }
70 }
71
72 pub fn format(&self) -> ZlibCompressorFormat {
74 ObjectExt::property(self, "format")
75 }
76
77 #[doc(alias = "file-info")]
78 pub fn connect_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
79 unsafe extern "C" fn notify_file_info_trampoline<F: Fn(&ZlibDecompressor) + 'static>(
80 this: *mut ffi::GZlibDecompressor,
81 _param_spec: glib::ffi::gpointer,
82 f: glib::ffi::gpointer,
83 ) {
84 unsafe {
85 let f: &F = &*(f as *const F);
86 f(&from_glib_borrow(this))
87 }
88 }
89 unsafe {
90 let f: Box_<F> = Box_::new(f);
91 connect_raw(
92 self.as_ptr() as *mut _,
93 c"notify::file-info".as_ptr(),
94 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
95 notify_file_info_trampoline::<F> as *const (),
96 )),
97 Box_::into_raw(f),
98 )
99 }
100 }
101}