gio/auto/
zlib_decompressor.rs1use crate::{ffi, Converter, FileInfo, ZlibCompressorFormat};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GZlibDecompressor")]
15 pub struct ZlibDecompressor(Object<ffi::GZlibDecompressor, ffi::GZlibDecompressorClass>) @implements Converter;
16
17 match fn {
18 type_ => || ffi::g_zlib_decompressor_get_type(),
19 }
20}
21
22impl ZlibDecompressor {
23 #[doc(alias = "g_zlib_decompressor_new")]
24 pub fn new(format: ZlibCompressorFormat) -> ZlibDecompressor {
25 unsafe { from_glib_full(ffi::g_zlib_decompressor_new(format.into_glib())) }
26 }
27
28 #[doc(alias = "g_zlib_decompressor_get_file_info")]
29 #[doc(alias = "get_file_info")]
30 #[doc(alias = "file-info")]
31 pub fn file_info(&self) -> Option<FileInfo> {
32 unsafe {
33 from_glib_none(ffi::g_zlib_decompressor_get_file_info(
34 self.to_glib_none().0,
35 ))
36 }
37 }
38
39 pub fn format(&self) -> ZlibCompressorFormat {
40 ObjectExt::property(self, "format")
41 }
42
43 #[doc(alias = "file-info")]
44 pub fn connect_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
45 unsafe extern "C" fn notify_file_info_trampoline<F: Fn(&ZlibDecompressor) + 'static>(
46 this: *mut ffi::GZlibDecompressor,
47 _param_spec: glib::ffi::gpointer,
48 f: glib::ffi::gpointer,
49 ) {
50 let f: &F = &*(f as *const F);
51 f(&from_glib_borrow(this))
52 }
53 unsafe {
54 let f: Box_<F> = Box_::new(f);
55 connect_raw(
56 self.as_ptr() as *mut _,
57 c"notify::file-info".as_ptr() as *const _,
58 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
59 notify_file_info_trampoline::<F> as *const (),
60 )),
61 Box_::into_raw(f),
62 )
63 }
64 }
65}