gdk4/content_provider.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, prelude::*, ContentProvider};
6
7// rustdoc-stripper-ignore-next
8/// Trait containing manually implemented methods of
9/// [`ContentProvider`](crate::ContentProvider).
10pub trait ContentProviderExtManual: IsA<ContentProvider> {
11 /// Gets the contents of @self stored in @value.
12 ///
13 /// The @value will have been initialized to the `GType` the value should be
14 /// provided in. This given `GType` does not need to be listed in the formats
15 /// returned by [`ContentProviderExt::formats()`][crate::prelude::ContentProviderExt::formats()]. However, if the
16 /// given `GType` is not supported, this operation can fail and
17 /// `G_IO_ERROR_NOT_SUPPORTED` will be reported.
18 ///
19 /// # Returns
20 ///
21 /// [`true`] if the value was set successfully. Otherwise
22 /// @error will be set to describe the failure.
23 ///
24 /// ## `value`
25 /// the `GValue` to fill
26 #[doc(alias = "gdk_content_provider_get_value")]
27 fn value(&self, type_: glib::Type) -> Result<glib::Value, glib::Error> {
28 unsafe {
29 let mut error = std::ptr::null_mut();
30 let mut value = glib::Value::from_type(type_);
31 let _ = ffi::gdk_content_provider_get_value(
32 self.as_ref().to_glib_none().0,
33 value.to_glib_none_mut().0,
34 &mut error,
35 );
36 if error.is_null() {
37 Ok(value)
38 } else {
39 Err(from_glib_full(error))
40 }
41 }
42 }
43}
44
45impl<O: IsA<ContentProvider>> ContentProviderExtManual for O {}