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