gio/auto/ip_tos_message.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::{EcnCodePoint, SocketControlMessage, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// error);
10 /// ```text
11 ///
12 ///
13 /// # Implements
14 ///
15 /// [`SocketControlMessageExt`][trait@crate::prelude::SocketControlMessageExt], [`trait@glib::ObjectExt`], [`SocketControlMessageExtManual`][trait@crate::prelude::SocketControlMessageExtManual]
16 #[doc(alias = "GIPTosMessage")]
17 pub struct IPTosMessage(Object<ffi::GIPTosMessage, ffi::GIPTosMessageClass>) @extends SocketControlMessage;
18
19 match fn {
20 type_ => || ffi::g_ip_tos_message_get_type(),
21 }
22}
23
24impl IPTosMessage {
25 /// Creates a new type-of-service message with given DSCP and ECN values.
26 /// ## `dscp`
27 /// the DSCP value of the message
28 /// ## `ecn`
29 /// the ECN value of the message
30 ///
31 /// # Returns
32 ///
33 /// a new type-of-service message
34 #[doc(alias = "g_ip_tos_message_new")]
35 pub fn new(dscp: u8, ecn: EcnCodePoint) -> IPTosMessage {
36 unsafe {
37 SocketControlMessage::from_glib_full(ffi::g_ip_tos_message_new(dscp, ecn.into_glib()))
38 .unsafe_cast()
39 }
40 }
41
42 /// Gets the differentiated services code point stored in @self.
43 ///
44 /// # Returns
45 ///
46 /// A DSCP value as described in [RFC 2474](https://www.rfc-editor.org/rfc/rfc2474.html#section-3).
47 #[doc(alias = "g_ip_tos_message_get_dscp")]
48 #[doc(alias = "get_dscp")]
49 pub fn dscp(&self) -> u8 {
50 unsafe { ffi::g_ip_tos_message_get_dscp(self.to_glib_none().0) }
51 }
52
53 /// Gets the Explicit Congestion Notification code point stored in @self.
54 ///
55 /// # Returns
56 ///
57 /// An ECN value as described in [RFC 3168](https://www.rfc-editor.org/rfc/rfc3168#section-5).
58 #[doc(alias = "g_ip_tos_message_get_ecn")]
59 #[doc(alias = "get_ecn")]
60 pub fn ecn(&self) -> EcnCodePoint {
61 unsafe { from_glib(ffi::g_ip_tos_message_get_ecn(self.to_glib_none().0)) }
62 }
63}