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