Skip to main content

gio/auto/
srv_target.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// s
10    /// [`SocketConnectable`][crate::SocketConnectable] interface and not need to worry about
11    /// `GSrvTarget` at all.
12    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13    pub struct SrvTarget(Boxed<ffi::GSrvTarget>);
14
15    match fn {
16        copy => |ptr| ffi::g_srv_target_copy(mut_override(ptr)),
17        free => |ptr| ffi::g_srv_target_free(ptr),
18        type_ => || ffi::g_srv_target_get_type(),
19    }
20}
21
22impl SrvTarget {
23    /// Creates a new #GSrvTarget with the given parameters.
24    ///
25    /// You should not need to use this; normally #GSrvTargets are
26    /// created by #GResolver.
27    /// ## `hostname`
28    /// the host that the service is running on
29    /// ## `port`
30    /// the port that the service is running on
31    /// ## `priority`
32    /// the target's priority
33    /// ## `weight`
34    /// the target's weight
35    ///
36    /// # Returns
37    ///
38    /// a new #GSrvTarget.
39    #[doc(alias = "g_srv_target_new")]
40    pub fn new(hostname: &str, port: u16, priority: u16, weight: u16) -> SrvTarget {
41        unsafe {
42            from_glib_full(ffi::g_srv_target_new(
43                hostname.to_glib_none().0,
44                port,
45                priority,
46                weight,
47            ))
48        }
49    }
50
51    /// Gets @self's hostname (in ASCII form; if you are going to present
52    /// this to the user, you should use g_hostname_is_ascii_encoded() to
53    /// check if it contains encoded Unicode segments, and use
54    /// g_hostname_to_unicode() to convert it if it does.)
55    ///
56    /// # Returns
57    ///
58    /// @self's hostname
59    #[doc(alias = "g_srv_target_get_hostname")]
60    #[doc(alias = "get_hostname")]
61    pub fn hostname(&mut self) -> glib::GString {
62        unsafe { from_glib_none(ffi::g_srv_target_get_hostname(self.to_glib_none_mut().0)) }
63    }
64
65    /// Gets @self's port
66    ///
67    /// # Returns
68    ///
69    /// @self's port
70    #[doc(alias = "g_srv_target_get_port")]
71    #[doc(alias = "get_port")]
72    pub fn port(&mut self) -> u16 {
73        unsafe { ffi::g_srv_target_get_port(self.to_glib_none_mut().0) }
74    }
75
76    /// Gets @self's priority. You should not need to look at this;
77    /// #GResolver already sorts the targets according to the algorithm in
78    /// RFC 2782.
79    ///
80    /// # Returns
81    ///
82    /// @self's priority
83    #[doc(alias = "g_srv_target_get_priority")]
84    #[doc(alias = "get_priority")]
85    pub fn priority(&mut self) -> u16 {
86        unsafe { ffi::g_srv_target_get_priority(self.to_glib_none_mut().0) }
87    }
88
89    /// Gets @self's weight. You should not need to look at this;
90    /// #GResolver already sorts the targets according to the algorithm in
91    /// RFC 2782.
92    ///
93    /// # Returns
94    ///
95    /// @self's weight
96    #[doc(alias = "g_srv_target_get_weight")]
97    #[doc(alias = "get_weight")]
98    pub fn weight(&mut self) -> u16 {
99        unsafe { ffi::g_srv_target_get_weight(self.to_glib_none_mut().0) }
100    }
101
102    //#[doc(alias = "g_srv_target_list_sort")]
103    //pub fn list_sort(targets: /*Unimplemented*/&[&Basic: Pointer]) -> /*Unimplemented*/Vec<Basic: Pointer> {
104    //    unsafe { TODO: call ffi:g_srv_target_list_sort() }
105    //}
106}