// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{EcnCodePoint, SocketControlMessage, ffi};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "GIPTosMessage")]
    pub struct IPTosMessage(Object<ffi::GIPTosMessage, ffi::GIPTosMessageClass>) @extends SocketControlMessage;

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

impl IPTosMessage {
    #[doc(alias = "g_ip_tos_message_new")]
    pub fn new(dscp: u8, ecn: EcnCodePoint) -> IPTosMessage {
        unsafe {
            SocketControlMessage::from_glib_full(ffi::g_ip_tos_message_new(dscp, ecn.into_glib()))
                .unsafe_cast()
        }
    }

    #[doc(alias = "g_ip_tos_message_get_dscp")]
    #[doc(alias = "get_dscp")]
    pub fn dscp(&self) -> u8 {
        unsafe { ffi::g_ip_tos_message_get_dscp(self.to_glib_none().0) }
    }

    #[doc(alias = "g_ip_tos_message_get_ecn")]
    #[doc(alias = "get_ecn")]
    pub fn ecn(&self) -> EcnCodePoint {
        unsafe { from_glib(ffi::g_ip_tos_message_get_ecn(self.to_glib_none().0)) }
    }
}
