[go: up one dir, main page]

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    #[doc(alias = "gdk_content_formats_get_gtypes")]
9    #[doc(alias = "get_gtypes")]
10    pub fn types(&self) -> Slice<glib::Type> {
11        unsafe {
12            let mut n_types = std::mem::MaybeUninit::uninit();
13            let types =
14                ffi::gdk_content_formats_get_gtypes(self.to_glib_none().0, n_types.as_mut_ptr());
15
16            Slice::from_glib_none_num(types, n_types.assume_init() as _)
17        }
18    }
19
20    // rustdoc-stripper-ignore-next
21    /// Creates a new builder-pattern struct instance to construct
22    /// [`ContentFormats`] objects.
23    ///
24    /// This method returns an instance of
25    /// [`ContentFormatsBuilder`](crate::builders::ContentFormatsBuilder) which
26    /// can be used to create [`ContentFormats`] objects.
27    pub fn builder() -> ContentFormatsBuilder {
28        ContentFormatsBuilder::default()
29    }
30}
31
32#[cfg(feature = "v4_4")]
33#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
34impl std::str::FromStr for ContentFormats {
35    type Err = glib::BoolError;
36    fn from_str(s: &str) -> Result<Self, Self::Err> {
37        skip_assert_initialized!();
38        ContentFormats::parse(s)
39    }
40}