libappstream/auto/
provided.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, ProvidedKind};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`ProvidedExt`][trait@crate::prelude::ProvidedExt]
    #[doc(alias = "AsProvided")]
    pub struct Provided(Object<ffi::AsProvided, ffi::AsProvidedClass>);

    match fn {
        type_ => || ffi::as_provided_get_type(),
    }
}

impl Provided {
    pub const NONE: Option<&'static Provided> = None;

    /// Creates a new [`Provided`][crate::Provided].
    ///
    /// # Returns
    ///
    /// a [`Provided`][crate::Provided]
    #[doc(alias = "as_provided_new")]
    pub fn new() -> Provided {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::as_provided_new()) }
    }
}

impl Default for Provided {
    fn default() -> Self {
        Self::new()
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Provided>> Sealed for T {}
}

/// Trait containing all [`struct@Provided`] methods.
///
/// # Implementors
///
/// [`Provided`][struct@crate::Provided]
pub trait ProvidedExt: IsA<Provided> + sealed::Sealed + 'static {
    /// Add a new provided item.
    #[doc(alias = "as_provided_add_item")]
    fn add_item(&self, item: &str) {
        unsafe {
            ffi::as_provided_add_item(self.as_ref().to_glib_none().0, item.to_glib_none().0);
        }
    }

    /// Get an array of provided data.
    ///
    /// # Returns
    ///
    /// An string list of provided items.
    #[doc(alias = "as_provided_get_items")]
    #[doc(alias = "get_items")]
    fn items(&self) -> Vec<glib::GString> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::as_provided_get_items(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// The kind of items this [`Provided`][crate::Provided] object stores.
    ///
    /// # Returns
    ///
    /// an enum of type [`ProvidedKind`][crate::ProvidedKind]
    #[doc(alias = "as_provided_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> ProvidedKind {
        unsafe { from_glib(ffi::as_provided_get_kind(self.as_ref().to_glib_none().0)) }
    }

    /// Check if the current [`Provided`][crate::Provided] contains an item
    /// of the given name.
    /// ## `item`
    /// the name of a provided item, e.g. "audio/x-vorbis" (in case the provided kind is a mimetype)
    ///
    /// # Returns
    ///
    /// [`true`] if found.
    #[doc(alias = "as_provided_has_item")]
    fn has_item(&self, item: &str) -> bool {
        unsafe {
            from_glib(ffi::as_provided_has_item(
                self.as_ref().to_glib_none().0,
                item.to_glib_none().0,
            ))
        }
    }

    /// Set the kind of items this [`Provided`][crate::Provided] object stores.
    /// ## `kind`
    /// the new [`ProvidedKind`][crate::ProvidedKind]
    #[doc(alias = "as_provided_set_kind")]
    fn set_kind(&self, kind: ProvidedKind) {
        unsafe {
            ffi::as_provided_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }
}

impl<O: IsA<Provided>> ProvidedExt for O {}