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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::{ffi, Feature};
use glib::translate::*;

glib::wrapper! {
    /// Contains a set of toggle-able web engine features.
    ///
    /// The list supports passing around a set of [`Feature`][crate::Feature] objects and
    /// iterating over them:
    ///
    /// **⚠️ The following code is in c ⚠️**
    ///
    /// ```c
    /// g_autoptr(WebKitFeatureList) list = webkit_settings_get_experimental_features();
    /// for (gsize i = 0; i < webkit_feature_list_get_length(list): i++) {
    ///     WebKitFeature *feature = webkit_feature_list_get(list, i);
    ///     // Do something with "feature".
    /// }
    /// ```
    ///
    /// Lists of features can be obtained with
    /// `get_experimental_features()`,
    /// `get_development_features()`, and
    /// `get_all_features()`.
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct FeatureList(Shared<ffi::WebKitFeatureList>);

    match fn {
        ref => |ptr| ffi::webkit_feature_list_ref(ptr),
        unref => |ptr| ffi::webkit_feature_list_unref(ptr),
        type_ => || ffi::webkit_feature_list_get_type(),
    }
}

impl FeatureList {
    /// Gets a feature given its index.
    /// ## `index`
    /// index of the feature
    ///
    /// # Returns
    ///
    /// The feature at @index.
    #[doc(alias = "webkit_feature_list_get")]
    pub fn get(&self, index: usize) -> Option<Feature> {
        unsafe { from_glib_none(ffi::webkit_feature_list_get(self.to_glib_none().0, index)) }
    }

    /// Gets the number of elements in the feature list.
    ///
    /// # Returns
    ///
    /// number of elements.
    ///
    /// Since 2.42
    #[doc(alias = "webkit_feature_list_get_length")]
    #[doc(alias = "get_length")]
    pub fn length(&self) -> usize {
        unsafe { ffi::webkit_feature_list_get_length(self.to_glib_none().0) }
    }
}