gio/auto/zlib_decompressor.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use 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 /// `GZlibDecompressor` is an implementation of [`Converter`][crate::Converter] that
15 /// decompresses data compressed with zlib.
16 ///
17 /// ## Properties
18 ///
19 ///
20 /// #### `file-info`
21 /// A #GFileInfo containing the information found in the GZIP header
22 /// of the data stream processed, or [`None`] if the header was not yet
23 /// fully processed, is not present at all, or the compressor's
24 /// #GZlibDecompressor:format property is not [`ZlibCompressorFormat::Gzip`][crate::ZlibCompressorFormat::Gzip].
25 ///
26 /// Readable
27 ///
28 ///
29 /// #### `format`
30 /// The format of the compressed data.
31 ///
32 /// Readable | Writeable | Construct Only
33 ///
34 /// # Implements
35 ///
36 /// [`trait@glib::ObjectExt`], [`ConverterExt`][trait@crate::prelude::ConverterExt], [`ConverterExtManual`][trait@crate::prelude::ConverterExtManual]
37 #[doc(alias = "GZlibDecompressor")]
38 pub struct ZlibDecompressor(Object<ffi::GZlibDecompressor, ffi::GZlibDecompressorClass>) @implements Converter;
39
40 match fn {
41 type_ => || ffi::g_zlib_decompressor_get_type(),
42 }
43}
44
45impl ZlibDecompressor {
46 /// Creates a new #GZlibDecompressor.
47 /// ## `format`
48 /// The format to use for the compressed data
49 ///
50 /// # Returns
51 ///
52 /// a new #GZlibDecompressor
53 #[doc(alias = "g_zlib_decompressor_new")]
54 pub fn new(format: ZlibCompressorFormat) -> ZlibDecompressor {
55 unsafe { from_glib_full(ffi::g_zlib_decompressor_new(format.into_glib())) }
56 }
57
58 /// Retrieves the #GFileInfo constructed from the GZIP header data
59 /// of compressed data processed by @compressor, or [`None`] if @self's
60 /// #GZlibDecompressor:format property is not [`ZlibCompressorFormat::Gzip`][crate::ZlibCompressorFormat::Gzip],
61 /// or the header data was not fully processed yet, or it not present in the
62 /// data stream at all.
63 ///
64 /// # Returns
65 ///
66 /// a #GFileInfo, or [`None`]
67 #[doc(alias = "g_zlib_decompressor_get_file_info")]
68 #[doc(alias = "get_file_info")]
69 #[doc(alias = "file-info")]
70 pub fn file_info(&self) -> Option<FileInfo> {
71 unsafe {
72 from_glib_none(ffi::g_zlib_decompressor_get_file_info(
73 self.to_glib_none().0,
74 ))
75 }
76 }
77
78 /// The format of the compressed data.
79 pub fn format(&self) -> ZlibCompressorFormat {
80 ObjectExt::property(self, "format")
81 }
82
83 #[doc(alias = "file-info")]
84 pub fn connect_file_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
85 unsafe extern "C" fn notify_file_info_trampoline<F: Fn(&ZlibDecompressor) + 'static>(
86 this: *mut ffi::GZlibDecompressor,
87 _param_spec: glib::ffi::gpointer,
88 f: glib::ffi::gpointer,
89 ) {
90 let f: &F = &*(f as *const F);
91 f(&from_glib_borrow(this))
92 }
93 unsafe {
94 let f: Box_<F> = Box_::new(f);
95 connect_raw(
96 self.as_ptr() as *mut _,
97 b"notify::file-info\0".as_ptr() as *const _,
98 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
99 notify_file_info_trampoline::<F> as *const (),
100 )),
101 Box_::into_raw(f),
102 )
103 }
104 }
105}