libappstream/auto/
agreement.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
// 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, AgreementKind, AgreementSection};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`AgreementExt`][trait@crate::prelude::AgreementExt]
    #[doc(alias = "AsAgreement")]
    pub struct Agreement(Object<ffi::AsAgreement, ffi::AsAgreementClass>);

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

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

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

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

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

/// Trait containing all [`struct@Agreement`] methods.
///
/// # Implementors
///
/// [`Agreement`][struct@crate::Agreement]
pub trait AgreementExt: IsA<Agreement> + sealed::Sealed + 'static {
    #[doc(alias = "as_agreement_add_section")]
    fn add_section(&self, agreement_section: &impl IsA<AgreementSection>) {
        unsafe {
            ffi::as_agreement_add_section(
                self.as_ref().to_glib_none().0,
                agreement_section.as_ref().to_glib_none().0,
            );
        }
    }

    /// Gets the agreement kind.
    ///
    /// # Returns
    ///
    /// a string, e.g. [`AgreementKind::Eula`][crate::AgreementKind::Eula]
    #[doc(alias = "as_agreement_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> AgreementKind {
        unsafe { from_glib(ffi::as_agreement_get_kind(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the first section in the agreement.
    ///
    /// # Returns
    ///
    /// agreement section, or [`None`]
    #[doc(alias = "as_agreement_get_section_default")]
    #[doc(alias = "get_section_default")]
    fn section_default(&self) -> Option<AgreementSection> {
        unsafe {
            from_glib_none(ffi::as_agreement_get_section_default(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets all the sections in the agreement.
    ///
    /// # Returns
    ///
    /// array
    #[doc(alias = "as_agreement_get_sections")]
    #[doc(alias = "get_sections")]
    fn sections(&self) -> Vec<AgreementSection> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::as_agreement_get_sections(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the agreement version_id.
    ///
    /// # Returns
    ///
    /// a string, e.g. "1.4a", or NULL
    #[doc(alias = "as_agreement_get_version_id")]
    #[doc(alias = "get_version_id")]
    fn version_id(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::as_agreement_get_version_id(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Sets the agreement kind.
    /// ## `kind`
    /// the agreement kind, e.g. [`AgreementKind::Eula`][crate::AgreementKind::Eula]
    #[doc(alias = "as_agreement_set_kind")]
    fn set_kind(&self, kind: AgreementKind) {
        unsafe {
            ffi::as_agreement_set_kind(self.as_ref().to_glib_none().0, kind.into_glib());
        }
    }

    /// Sets the agreement version identifier.
    /// ## `version_id`
    /// the agreement version ID, e.g. "1.4a"
    #[doc(alias = "as_agreement_set_version_id")]
    fn set_version_id(&self, version_id: &str) {
        unsafe {
            ffi::as_agreement_set_version_id(
                self.as_ref().to_glib_none().0,
                version_id.to_glib_none().0,
            );
        }
    }
}

impl<O: IsA<Agreement>> AgreementExt for O {}