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")]
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 unsafe {
51 let f: &F = &*(f as *const F);
52 f(&from_glib_borrow(this))
53 }
54 }
55 unsafe {
56 let f: Box_<F> = Box_::new(f);
57 connect_raw(
58 self.as_ptr() as *mut _,
59 c"notify::file-info".as_ptr(),
60 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
61 notify_file_info_trampoline::<F> as *const (),
62 )),
63 Box_::into_raw(f),
64 )
65 }
66 }
67}