gdk4/content_formats.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{translate::*, Slice};
4
5use crate::{ffi, ContentFormats, ContentFormatsBuilder};
6
7impl ContentFormats {
8 /// Gets the `GType`s included in @self.
9 ///
10 /// Note that @self may not contain any `GType`s, in particular when
11 /// they are empty. In that case [`None`] will be returned.
12 ///
13 /// # Returns
14 ///
15 ///
16 /// `G_TYPE_INVALID`-terminated array of types included in @self
17 #[doc(alias = "gdk_content_formats_get_gtypes")]
18 #[doc(alias = "get_gtypes")]
19 pub fn types(&self) -> Slice<glib::Type> {
20 unsafe {
21 let mut n_types = std::mem::MaybeUninit::uninit();
22 let types =
23 ffi::gdk_content_formats_get_gtypes(self.to_glib_none().0, n_types.as_mut_ptr());
24
25 Slice::from_glib_none_num(types, n_types.assume_init() as _)
26 }
27 }
28
29 // rustdoc-stripper-ignore-next
30 /// Creates a new builder-pattern struct instance to construct
31 /// [`ContentFormats`] objects.
32 ///
33 /// This method returns an instance of
34 /// [`ContentFormatsBuilder`](crate::builders::ContentFormatsBuilder) which
35 /// can be used to create [`ContentFormats`] objects.
36 pub fn builder() -> ContentFormatsBuilder {
37 ContentFormatsBuilder::default()
38 }
39}
40
41#[cfg(feature = "v4_4")]
42#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
43impl std::str::FromStr for ContentFormats {
44 type Err = glib::BoolError;
45 fn from_str(s: &str) -> Result<Self, Self::Err> {
46 skip_assert_initialized!();
47 ContentFormats::parse(s)
48 }
49}