gio/auto/
bytes_icon.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Icon, LoadableIcon};
6use glib::translate::*;
7
8glib::wrapper! {
9    /// `GBytesIcon` specifies an image held in memory in a common format (usually
10    /// PNG) to be used as icon.
11    ///
12    /// ## Properties
13    ///
14    ///
15    /// #### `bytes`
16    ///  The bytes containing the icon.
17    ///
18    /// Readable | Writeable | Construct Only
19    ///
20    /// # Implements
21    ///
22    /// [`trait@glib::ObjectExt`], [`IconExt`][trait@crate::prelude::IconExt], [`LoadableIconExt`][trait@crate::prelude::LoadableIconExt]
23    #[doc(alias = "GBytesIcon")]
24    pub struct BytesIcon(Object<ffi::GBytesIcon>) @implements Icon, LoadableIcon;
25
26    match fn {
27        type_ => || ffi::g_bytes_icon_get_type(),
28    }
29}
30
31impl BytesIcon {
32    /// Creates a new icon for a bytes.
33    ///
34    /// This cannot fail, but loading and interpreting the bytes may fail later on
35    /// (for example, if g_loadable_icon_load() is called) if the image is invalid.
36    /// ## `bytes`
37    /// a #GBytes.
38    ///
39    /// # Returns
40    ///
41    /// a #GIcon for the given
42    ///   @bytes.
43    #[doc(alias = "g_bytes_icon_new")]
44    pub fn new(bytes: &glib::Bytes) -> BytesIcon {
45        unsafe { from_glib_full(ffi::g_bytes_icon_new(bytes.to_glib_none().0)) }
46    }
47
48    /// Gets the #GBytes associated with the given @self.
49    ///
50    /// # Returns
51    ///
52    /// a #GBytes.
53    #[doc(alias = "g_bytes_icon_get_bytes")]
54    #[doc(alias = "get_bytes")]
55    pub fn bytes(&self) -> glib::Bytes {
56        unsafe { from_glib_none(ffi::g_bytes_icon_get_bytes(self.to_glib_none().0)) }
57    }
58}