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 /// A single target host/port that a network service is running on.
10 ///
11 /// SRV (service) records are used by some network protocols to provide
12 /// service-specific aliasing and load-balancing. For example, XMPP
13 /// (Jabber) uses SRV records to locate the XMPP server for a domain;
14 /// rather than connecting directly to ‘example.com’ or assuming a
15 /// specific server hostname like ‘xmpp.example.com’, an XMPP client
16 /// would look up the `xmpp-client` SRV record for ‘example.com’, and
17 /// then connect to whatever host was pointed to by that record.
18 ///
19 /// You can use [`ResolverExt::lookup_service()`][crate::prelude::ResolverExt::lookup_service()] or
20 /// [`ResolverExt::lookup_service_async()`][crate::prelude::ResolverExt::lookup_service_async()] to find the `GSrvTarget`s
21 /// for a given service. However, if you are simply planning to connect
22 /// to the remote service, you can use [`NetworkService`][crate::NetworkService]’s
23 /// [`SocketConnectable`][crate::SocketConnectable] interface and not need to worry about
24 /// `GSrvTarget` at all.
25 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
26 pub struct SrvTarget(Boxed<ffi::GSrvTarget>);
27
28 match fn {
29 copy => |ptr| ffi::g_srv_target_copy(mut_override(ptr)),
30 free => |ptr| ffi::g_srv_target_free(ptr),
31 type_ => || ffi::g_srv_target_get_type(),
32 }
33}
34
35impl SrvTarget {
36 /// Creates a new #GSrvTarget with the given parameters.
37 ///
38 /// You should not need to use this; normally #GSrvTargets are
39 /// created by #GResolver.
40 /// ## `hostname`
41 /// the host that the service is running on
42 /// ## `port`
43 /// the port that the service is running on
44 /// ## `priority`
45 /// the target's priority
46 /// ## `weight`
47 /// the target's weight
48 ///
49 /// # Returns
50 ///
51 /// a new #GSrvTarget.
52 #[doc(alias = "g_srv_target_new")]
53 pub fn new(hostname: &str, port: u16, priority: u16, weight: u16) -> SrvTarget {
54 unsafe {
55 from_glib_full(ffi::g_srv_target_new(
56 hostname.to_glib_none().0,
57 port,
58 priority,
59 weight,
60 ))
61 }
62 }
63
64 /// Gets @self's hostname (in ASCII form; if you are going to present
65 /// this to the user, you should use g_hostname_is_ascii_encoded() to
66 /// check if it contains encoded Unicode segments, and use
67 /// g_hostname_to_unicode() to convert it if it does.)
68 ///
69 /// # Returns
70 ///
71 /// @self's hostname
72 #[doc(alias = "g_srv_target_get_hostname")]
73 #[doc(alias = "get_hostname")]
74 pub fn hostname(&mut self) -> glib::GString {
75 unsafe { from_glib_none(ffi::g_srv_target_get_hostname(self.to_glib_none_mut().0)) }
76 }
77
78 /// Gets @self's port
79 ///
80 /// # Returns
81 ///
82 /// @self's port
83 #[doc(alias = "g_srv_target_get_port")]
84 #[doc(alias = "get_port")]
85 pub fn port(&mut self) -> u16 {
86 unsafe { ffi::g_srv_target_get_port(self.to_glib_none_mut().0) }
87 }
88
89 /// Gets @self's priority. 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 priority
96 #[doc(alias = "g_srv_target_get_priority")]
97 #[doc(alias = "get_priority")]
98 pub fn priority(&mut self) -> u16 {
99 unsafe { ffi::g_srv_target_get_priority(self.to_glib_none_mut().0) }
100 }
101
102 /// Gets @self's weight. You should not need to look at this;
103 /// #GResolver already sorts the targets according to the algorithm in
104 /// RFC 2782.
105 ///
106 /// # Returns
107 ///
108 /// @self's weight
109 #[doc(alias = "g_srv_target_get_weight")]
110 #[doc(alias = "get_weight")]
111 pub fn weight(&mut self) -> u16 {
112 unsafe { ffi::g_srv_target_get_weight(self.to_glib_none_mut().0) }
113 }
114
115 //#[doc(alias = "g_srv_target_list_sort")]
116 //pub fn list_sort(targets: /*Unimplemented*/&[&Basic: Pointer]) -> /*Unimplemented*/Vec<Basic: Pointer> {
117 // unsafe { TODO: call ffi:g_srv_target_list_sort() }
118 //}
119}