Skip to main content

gtk/
selection_data.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::SelectionData;
4use glib::translate::*;
5use std::mem;
6
7impl SelectionData {
8    /// Retrieves the raw data of the selection.
9    ///
10    /// # Returns
11    ///
12    /// the raw data of the selection.
13    #[doc(alias = "gtk_selection_data_get_data_with_length")]
14    #[doc(alias = "get_data")]
15    pub fn data(&self) -> Vec<u8> {
16        unsafe {
17            let mut length = mem::MaybeUninit::uninit();
18            FromGlibContainer::from_glib_none_num(
19                ffi::gtk_selection_data_get_data_with_length(
20                    self.to_glib_none().0,
21                    length.as_mut_ptr(),
22                ),
23                length.assume_init() as usize,
24            )
25        }
26    }
27}