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

use Certificate;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
    /// A collection of `Certificate` objects.
    ///
    /// # Implements
    ///
    /// [`CertificateListExt`](trait.CertificateListExt.html)
    pub struct CertificateList(Object<ffi::GMimeCertificateList, ffi::GMimeCertificateListClass>);

    match fn {
        get_type => || ffi::g_mime_certificate_list_get_type(),
    }
}

impl CertificateList {
    /// Creates a new `CertificateList`.
    ///
    /// # Returns
    ///
    /// a new `CertificateList`.
    pub fn new() -> CertificateList {
        unsafe {
            from_glib_full(ffi::g_mime_certificate_list_new())
        }
    }
}

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

/// Trait containing all `CertificateList` methods.
///
/// # Implementors
///
/// [`CertificateList`](struct.CertificateList.html)
pub trait CertificateListExt {
    /// Adds a `Certificate` to the `CertificateList`.
    /// ## `cert`
    /// a `Certificate`
    ///
    /// # Returns
    ///
    /// the index of the added `Certificate`.
    fn add(&self, cert: &Certificate) -> i32;

    /// Clears the list of certificates.
    fn clear(&self);

    /// Checks whether or not the specified `Certificate` is contained within
    /// the `CertificateList`.
    /// ## `cert`
    /// a `Certificate`
    ///
    /// # Returns
    ///
    /// `true` if the specified `Certificate` is contained within the
    /// specified `CertificateList` or `false` otherwise.
    fn contains(&self, cert: &Certificate) -> bool;

    /// Gets the `Certificate` at the specified index.
    /// ## `index`
    /// index of `Certificate` to get
    ///
    /// # Returns
    ///
    /// the `Certificate` at the specified
    /// index or `None` if the index is out of range.
    fn get_certificate(&self, index: i32) -> Option<Certificate>;

    /// Gets the index of the specified `Certificate` inside the
    /// `CertificateList`.
    /// ## `cert`
    /// a `Certificate`
    ///
    /// # Returns
    ///
    /// the index of the requested `Certificate` within the
    /// `CertificateList` or %-1 if it is not contained within the
    /// `CertificateList`.
    fn index_of(&self, cert: &Certificate) -> i32;

    /// Inserts a `Certificate` into the `CertificateList` at the specified
    /// index.
    /// ## `index`
    /// index to insert at
    /// ## `cert`
    /// a `Certificate`
    fn insert(&self, index: i32, cert: &Certificate);

    /// Gets the length of the list.
    ///
    /// # Returns
    ///
    /// the number of `Certificate` objects in the list.
    fn length(&self) -> i32;

    /// Removes a `Certificate` from the `CertificateList`.
    /// ## `cert`
    /// a `Certificate`
    ///
    /// # Returns
    ///
    /// `true` if the specified `Certificate` was removed or `false`
    /// otherwise.
    fn remove(&self, cert: &Certificate) -> bool;

    /// Removes a `Certificate` from the `CertificateList` at the specified
    /// index.
    /// ## `index`
    /// index of the certificate to remove
    ///
    /// # Returns
    ///
    /// `true` if a `Certificate` was removed or `false` otherwise.
    fn remove_at(&self, index: i32) -> bool;

    /// Sets the `Certificate` at the specified index to `cert`.
    /// ## `index`
    /// index of `Certificate` to set
    /// ## `cert`
    /// a `Certificate`
    fn set_certificate(&self, index: i32, cert: &Certificate);
}

impl<O: IsA<CertificateList>> CertificateListExt for O {
    fn add(&self, cert: &Certificate) -> i32 {
        unsafe {
            ffi::g_mime_certificate_list_add(self.to_glib_none().0, cert.to_glib_none().0)
        }
    }

    fn clear(&self) {
        unsafe {
            ffi::g_mime_certificate_list_clear(self.to_glib_none().0);
        }
    }

    fn contains(&self, cert: &Certificate) -> bool {
        unsafe {
            from_glib(ffi::g_mime_certificate_list_contains(self.to_glib_none().0, cert.to_glib_none().0))
        }
    }

    fn get_certificate(&self, index: i32) -> Option<Certificate> {
        unsafe {
            from_glib_full(ffi::g_mime_certificate_list_get_certificate(self.to_glib_none().0, index))
        }
    }

    fn index_of(&self, cert: &Certificate) -> i32 {
        unsafe {
            ffi::g_mime_certificate_list_index_of(self.to_glib_none().0, cert.to_glib_none().0)
        }
    }

    fn insert(&self, index: i32, cert: &Certificate) {
        unsafe {
            ffi::g_mime_certificate_list_insert(self.to_glib_none().0, index, cert.to_glib_none().0);
        }
    }

    fn length(&self) -> i32 {
        unsafe {
            ffi::g_mime_certificate_list_length(self.to_glib_none().0)
        }
    }

    fn remove(&self, cert: &Certificate) -> bool {
        unsafe {
            from_glib(ffi::g_mime_certificate_list_remove(self.to_glib_none().0, cert.to_glib_none().0))
        }
    }

    fn remove_at(&self, index: i32) -> bool {
        unsafe {
            from_glib(ffi::g_mime_certificate_list_remove_at(self.to_glib_none().0, index))
        }
    }

    fn set_certificate(&self, index: i32, cert: &Certificate) {
        unsafe {
            ffi::g_mime_certificate_list_set_certificate(self.to_glib_none().0, index, cert.to_glib_none().0);
        }
    }
}