gdk4/auto/
content_serializer.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Serializes content for inter-application data transfers.
10    ///
11    /// The [`ContentSerializer`][crate::ContentSerializer] transforms an object that is identified
12    /// by a GType into a serialized form (i.e. a byte stream) that is
13    /// identified by a mime type.
14    ///
15    /// GTK provides serializers and deserializers for common data types
16    /// such as text, colors, images or file lists. To register your own
17    /// serialization functions, use [`content_register_serializer()`][crate::content_register_serializer()].
18    ///
19    /// Also see [`ContentDeserializer`][crate::ContentDeserializer].
20    #[doc(alias = "GdkContentSerializer")]
21    pub struct ContentSerializer(Object<ffi::GdkContentSerializer>);
22
23    match fn {
24        type_ => || ffi::gdk_content_serializer_get_type(),
25    }
26}
27
28impl ContentSerializer {
29    /// Gets the cancellable for the current operation.
30    ///
31    /// This is the `GCancellable` that was passed to [`content_serialize_async()`][crate::content_serialize_async()].
32    ///
33    /// # Returns
34    ///
35    /// the cancellable for the current operation
36    #[doc(alias = "gdk_content_serializer_get_cancellable")]
37    #[doc(alias = "get_cancellable")]
38    pub fn cancellable(&self) -> Option<gio::Cancellable> {
39        unsafe {
40            from_glib_none(ffi::gdk_content_serializer_get_cancellable(
41                self.to_glib_none().0,
42            ))
43        }
44    }
45
46    /// Gets the `GType` to of the object to serialize.
47    ///
48    /// # Returns
49    ///
50    /// the `GType` for the current operation
51    #[doc(alias = "gdk_content_serializer_get_gtype")]
52    #[doc(alias = "get_gtype")]
53    pub fn type_(&self) -> glib::types::Type {
54        unsafe { from_glib(ffi::gdk_content_serializer_get_gtype(self.to_glib_none().0)) }
55    }
56
57    /// Gets the mime type to serialize to.
58    ///
59    /// # Returns
60    ///
61    /// the mime type for the current operation
62    #[doc(alias = "gdk_content_serializer_get_mime_type")]
63    #[doc(alias = "get_mime_type")]
64    pub fn mime_type(&self) -> glib::GString {
65        unsafe {
66            from_glib_none(ffi::gdk_content_serializer_get_mime_type(
67                self.to_glib_none().0,
68            ))
69        }
70    }
71
72    /// Gets the output stream for the current operation.
73    ///
74    /// This is the stream that was passed to [`content_serialize_async()`][crate::content_serialize_async()].
75    ///
76    /// # Returns
77    ///
78    /// the output stream for the current operation
79    #[doc(alias = "gdk_content_serializer_get_output_stream")]
80    #[doc(alias = "get_output_stream")]
81    pub fn output_stream(&self) -> gio::OutputStream {
82        unsafe {
83            from_glib_none(ffi::gdk_content_serializer_get_output_stream(
84                self.to_glib_none().0,
85            ))
86        }
87    }
88
89    /// Gets the `GValue` to read the object to serialize from.
90    ///
91    /// # Returns
92    ///
93    /// the `GValue` for the current operation
94    #[doc(alias = "gdk_content_serializer_get_value")]
95    #[doc(alias = "get_value")]
96    pub fn value(&self) -> glib::Value {
97        unsafe { from_glib_none(ffi::gdk_content_serializer_get_value(self.to_glib_none().0)) }
98    }
99
100    /// Indicate that the serialization has been successfully completed.
101    #[doc(alias = "gdk_content_serializer_return_success")]
102    pub fn return_success(&self) {
103        unsafe {
104            ffi::gdk_content_serializer_return_success(self.to_glib_none().0);
105        }
106    }
107}