gio/
socket_control_message.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
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::{prelude::*, translate::*};

use crate::{prelude::*, SocketControlMessage};

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

pub trait SocketControlMessageExtManual:
    sealed::Sealed + IsA<SocketControlMessage> + Sized
{
    /// Converts the data in the message to bytes placed in the
    /// message.
    ///
    /// @data is guaranteed to have enough space to fit the size
    /// returned by g_socket_control_message_get_size() on this
    /// object.
    #[doc(alias = "g_socket_control_message_serialize")]
    fn serialize(&self, data: &mut [u8]) {
        assert!(data.len() >= self.size());
        unsafe {
            crate::ffi::g_socket_control_message_serialize(
                self.as_ref().to_glib_none().0,
                data.as_mut_ptr() as *mut _,
            );
        }
    }
}

impl<O: IsA<SocketControlMessage>> SocketControlMessageExtManual for O {}