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

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`BundleExt`][trait@crate::prelude::BundleExt]
    #[doc(alias = "AsBundle")]
    pub struct Bundle(Object<ffi::AsBundle, ffi::AsBundleClass>);

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

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

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

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

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

/// Trait containing all [`struct@Bundle`] methods.
///
/// # Implementors
///
/// [`Bundle`][struct@crate::Bundle]
pub trait BundleExt: IsA<Bundle> + sealed::Sealed + 'static {
    /// Gets the ID for this bundle.
    ///
    /// # Returns
    ///
    /// ID, e.g. "foobar-1.0.2"
    #[doc(alias = "as_bundle_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::as_bundle_get_id(self.as_ref().to_glib_none().0)) }
    }

    /// Gets the bundle kind.
    ///
    /// # Returns
    ///
    /// the [`BundleKind`][crate::BundleKind]
    #[doc(alias = "as_bundle_get_kind")]
    #[doc(alias = "get_kind")]
    fn kind(&self) -> BundleKind {
        unsafe { from_glib(ffi::as_bundle_get_kind(self.as_ref().to_glib_none().0)) }
    }

    /// Sets the ID for this bundle.
    /// ## `id`
    /// the URL.
    #[doc(alias = "as_bundle_set_id")]
    fn set_id(&self, id: &str) {
        unsafe {
            ffi::as_bundle_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
        }
    }

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

impl<O: IsA<Bundle>> BundleExt for O {}