gdk4/
content_serializer.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{translate::*, value::FromValue};
4
5use crate::{ffi, ContentSerializer};
6
7impl ContentSerializer {
8    #[doc(alias = "gdk_content_serializer_get_priority")]
9    #[doc(alias = "get_priority")]
10    pub fn priority(&self) -> glib::Priority {
11        unsafe {
12            from_glib(ffi::gdk_content_serializer_get_priority(
13                self.to_glib_none().0,
14            ))
15        }
16    }
17
18    // rustdoc-stripper-ignore-next
19    /// Similar to [`Self::value`] but panics if the value is of a different
20    /// type.
21    #[doc(alias = "gdk_content_serializer_get_value")]
22    #[doc(alias = "get_value")]
23    pub fn value_as<V: for<'b> FromValue<'b> + 'static>(&self) -> V {
24        self.value()
25            .get_owned::<V>()
26            .expect("Failed to get the value")
27    }
28
29    #[doc(alias = "gdk_content_serializer_return_error")]
30    pub fn return_error(&self, error: glib::Error) {
31        unsafe {
32            ffi::gdk_content_serializer_return_error(
33                self.to_glib_none().0,
34                mut_override(error.into_glib_ptr()),
35            );
36        }
37    }
38}