libappstream/auto/
relation.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
// 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, ControlKind, DisplaySideKind, RelationCompare, RelationItemKind, RelationKind};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`RelationExt`][trait@crate::prelude::RelationExt]
    #[doc(alias = "AsRelation")]
    pub struct Relation(Object<ffi::AsRelation, ffi::AsRelationClass>);

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

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

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

    //#[doc(alias = "as_relation_check_results_get_compatibility_score")]
    //pub fn check_results_get_compatibility_score(rc_results: /*Ignored*/&[RelationCheckResult]) -> i32 {
    //    unsafe { TODO: call ffi:as_relation_check_results_get_compatibility_score() }
    //}
}

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

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

/// Trait containing all [`struct@Relation`] methods.
///
/// # Implementors
///
/// [`Relation`][struct@crate::Relation]
pub trait RelationExt: IsA<Relation> + sealed::Sealed + 'static {
    #[doc(alias = "as_relation_get_compare")]
    #[doc(alias = "get_compare")]
    fn compare(&self) -> RelationCompare {
        unsafe { from_glib(ffi::as_relation_get_compare(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the display side kind, in case this item is of
    /// kind [`RelationItemKind::DisplayLength`][crate::RelationItemKind::DisplayLength]
    ///
    /// # Returns
    ///
    /// a [`DisplaySideKind`][crate::DisplaySideKind] or [`DisplaySideKind::Unknown`][crate::DisplaySideKind::Unknown]
    #[doc(alias = "as_relation_get_display_side_kind")]
    #[doc(alias = "get_display_side_kind")]
    fn display_side_kind(&self) -> DisplaySideKind {
        unsafe {
            from_glib(ffi::as_relation_get_display_side_kind(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// The kind of the item of this [`Relation`][crate::Relation].
    ///
    /// # Returns
    ///
    /// an enum of type [`RelationItemKind`][crate::RelationItemKind]
    #[doc(alias = "as_relation_get_item_kind")]
    #[doc(alias = "get_item_kind")]
    fn item_kind(&self) -> RelationItemKind {
        unsafe {
            from_glib(ffi::as_relation_get_item_kind(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// The type (and thereby strength) of this [`Relation`][crate::Relation].
    ///
    /// # Returns
    ///
    /// an enum of type [`RelationKind`][crate::RelationKind]
    #[doc(alias = "as_relation_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> RelationKind {
        unsafe { from_glib(ffi::as_relation_get_kind(self.as_ref().to_glib_none().0)) }
    }

    /// Get the value of this [`Relation`][crate::Relation] item as [`ControlKind`][crate::ControlKind] if the
    /// type of this relation is [`RelationItemKind::Control`][crate::RelationItemKind::Control].
    /// Otherwise return [`ControlKind::Unknown`][crate::ControlKind::Unknown]
    ///
    /// # Returns
    ///
    /// a [`ControlKind`][crate::ControlKind] or [`ControlKind::Unknown`][crate::ControlKind::Unknown] in case the item is not of the right kind.
    #[doc(alias = "as_relation_get_value_control_kind")]
    #[doc(alias = "get_value_control_kind")]
    fn value_control_kind(&self) -> ControlKind {
        unsafe {
            from_glib(ffi::as_relation_get_value_control_kind(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// The value of this [`Relation`][crate::Relation] item as an integer. Returns 0 if the value was no integer.
    #[doc(alias = "as_relation_get_value_int")]
    #[doc(alias = "get_value_int")]
    fn value_int(&self) -> i32 {
        unsafe { ffi::as_relation_get_value_int(self.as_ref().to_glib_none().0) }
    }

    /// If this [`Relation`][crate::Relation] is of kind [`RelationItemKind::Internet`][crate::RelationItemKind::Internet], return the
    /// minimum bandwidth requirement of the component, if set.
    ///
    /// If the relation is of a different kind, or the requirement isn’t set, this
    /// returns `0`.
    ///
    /// # Returns
    ///
    /// The minimum bandwidth requirement, in Mbit/s.
    #[doc(alias = "as_relation_get_value_internet_bandwidth")]
    #[doc(alias = "get_value_internet_bandwidth")]
    fn value_internet_bandwidth(&self) -> u32 {
        unsafe { ffi::as_relation_get_value_internet_bandwidth(self.as_ref().to_glib_none().0) }
    }

    //#[doc(alias = "as_relation_get_value_internet_kind")]
    //#[doc(alias = "get_value_internet_kind")]
    //fn value_internet_kind(&self) -> /*Ignored*/InternetKind {
    //    unsafe { TODO: call ffi:as_relation_get_value_internet_kind() }
    //}

    /// In case this [`Relation`][crate::Relation] is of kind [`RelationItemKind::DisplayLength`][crate::RelationItemKind::DisplayLength],
    /// return the set logical pixel amount.
    ///
    /// # Returns
    ///
    /// The logical pixel amount for this display length, value <= 0 on error.
    #[doc(alias = "as_relation_get_value_px")]
    #[doc(alias = "get_value_px")]
    fn value_px(&self) -> i32 {
        unsafe { ffi::as_relation_get_value_px(self.as_ref().to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// The value of the item this [`Relation`][crate::Relation] is about, as a string.
    #[doc(alias = "as_relation_get_value_str")]
    #[doc(alias = "get_value_str")]
    fn value_str(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::as_relation_get_value_str(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// The version of the item this [`Relation`][crate::Relation] is about.
    #[doc(alias = "as_relation_get_version")]
    #[doc(alias = "get_version")]
    fn version(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::as_relation_get_version(self.as_ref().to_glib_none().0)) }
    }

    //#[doc(alias = "as_relation_is_satisfied")]
    //fn is_satisfied(&self, system_info: /*Ignored*/Option<&SystemInfo>, pool: Option<&impl IsA<Pool>>) -> Result</*Ignored*/Option<RelationCheckResult>, glib::Error> {
    //    unsafe { TODO: call ffi:as_relation_is_satisfied() }
    //}

    #[doc(alias = "as_relation_set_compare")]
    fn set_compare(&self, compare: RelationCompare) {
        unsafe {
            ffi::as_relation_set_compare(self.as_ref().to_glib_none().0, compare.into_glib());
        }
    }

    /// Sets the display side kind, in case this item is of
    /// kind [`RelationItemKind::DisplayLength`][crate::RelationItemKind::DisplayLength]
    /// ## `kind`
    /// the new [`DisplaySideKind`][crate::DisplaySideKind].
    #[doc(alias = "as_relation_set_display_side_kind")]
    fn set_display_side_kind(&self, kind: DisplaySideKind) {
        unsafe {
            ffi::as_relation_set_display_side_kind(
                self.as_ref().to_glib_none().0,
                kind.into_glib(),
            );
        }
    }

    /// Set the kind of the item this [`Relation`][crate::Relation] is about.
    /// ## `kind`
    /// the new [`RelationItemKind`][crate::RelationItemKind]
    #[doc(alias = "as_relation_set_item_kind")]
    fn set_item_kind(&self, kind: RelationItemKind) {
        unsafe {
            ffi::as_relation_set_item_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }

    /// Set the kind of this [`Relation`][crate::Relation].
    /// ## `kind`
    /// the new [`RelationKind`][crate::RelationKind]
    #[doc(alias = "as_relation_set_kind")]
    fn set_kind(&self, kind: RelationKind) {
        unsafe {
            ffi::as_relation_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }

    /// Set relation item value from an [`ControlKind`][crate::ControlKind].
    /// ## `kind`
    /// an [`ControlKind`][crate::ControlKind]
    #[doc(alias = "as_relation_set_value_control_kind")]
    fn set_value_control_kind(&self, kind: ControlKind) {
        unsafe {
            ffi::as_relation_set_value_control_kind(
                self.as_ref().to_glib_none().0,
                kind.into_glib(),
            );
        }
    }

    /// Sets the item value as an integer, if the given item type
    /// of this [`Relation`][crate::Relation] permits integer values.
    /// ## `value`
    /// the new value.
    #[doc(alias = "as_relation_set_value_int")]
    fn set_value_int(&self, value: i32) {
        unsafe {
            ffi::as_relation_set_value_int(self.as_ref().to_glib_none().0, value);
        }
    }

    #[doc(alias = "as_relation_set_value_internet_bandwidth")]
    fn set_value_internet_bandwidth(&self, bandwidth_mbitps: u32) {
        unsafe {
            ffi::as_relation_set_value_internet_bandwidth(
                self.as_ref().to_glib_none().0,
                bandwidth_mbitps,
            );
        }
    }

    //#[doc(alias = "as_relation_set_value_internet_kind")]
    //fn set_value_internet_kind(&self, kind: /*Ignored*/InternetKind) {
    //    unsafe { TODO: call ffi:as_relation_set_value_internet_kind() }
    //}

    /// Sets the item value as logical pixel count. This requires the relation
    /// to be of item kind [`RelationItemKind::DisplayLength`][crate::RelationItemKind::DisplayLength].
    /// ## `logical_px`
    /// logical pixel count.
    #[doc(alias = "as_relation_set_value_px")]
    fn set_value_px(&self, logical_px: i32) {
        unsafe {
            ffi::as_relation_set_value_px(self.as_ref().to_glib_none().0, logical_px);
        }
    }

    /// Sets the item value as a string, if the given item type
    /// of this [`Relation`][crate::Relation] permits string values.
    /// ## `value`
    /// the new value.
    #[doc(alias = "as_relation_set_value_str")]
    fn set_value_str(&self, value: &str) {
        unsafe {
            ffi::as_relation_set_value_str(self.as_ref().to_glib_none().0, value.to_glib_none().0);
        }
    }

    /// Sets the item version.
    /// ## `version`
    /// the new version.
    #[doc(alias = "as_relation_set_version")]
    fn set_version(&self, version: &str) {
        unsafe {
            ffi::as_relation_set_version(self.as_ref().to_glib_none().0, version.to_glib_none().0);
        }
    }

    #[doc(alias = "as_relation_version_compare")]
    fn version_compare(&self, version: &str) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::as_relation_version_compare(
                self.as_ref().to_glib_none().0,
                version.to_glib_none().0,
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }
}

impl<O: IsA<Relation>> RelationExt for O {}