Skip to content

Commit 54287df

Browse files
committed
gio: Manually implement new g_inet_address_new_from_bytes_with_ipv6_info() bindings
1 parent 6a3b25a commit 54287df

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

gio/Gir.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,10 @@ concurrency = "send+sync"
950950
name = "new_from_bytes"
951951
# broken and needs some closer integration with the corresponding std types
952952
manual = true
953+
[[object.function]]
954+
name = "new_from_bytes_with_ipv6_info"
955+
# broken and needs some closer integration with the corresponding std types
956+
manual = true
953957

954958
[[object.function]]
955959
name = "to_bytes"

gio/src/auto/inet_address.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ impl InetAddress {
2727
unsafe { from_glib_full(ffi::g_inet_address_new_any(family.into_glib())) }
2828
}
2929

30-
//#[cfg(feature = "v2_86")]
31-
//#[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))]
32-
//#[doc(alias = "g_inet_address_new_from_bytes_with_ipv6_info")]
33-
//#[doc(alias = "new_from_bytes_with_ipv6_info")]
34-
//pub fn from_bytes_with_ipv6_info(bytes: &[u8], family: SocketFamily, flowinfo: u32, scope_id: u32) -> InetAddress {
35-
// unsafe { TODO: call ffi:g_inet_address_new_from_bytes_with_ipv6_info() }
36-
//}
37-
3830
#[doc(alias = "g_inet_address_new_from_string")]
3931
#[doc(alias = "new_from_string")]
4032
pub fn from_string(string: &str) -> Option<InetAddress> {

gio/src/inet_address.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ impl InetAddress {
4040
))
4141
}
4242
}
43+
44+
#[cfg(feature = "v2_86")]
45+
#[cfg_attr(docsrs, doc(cfg(feature = "v2_86")))]
46+
#[doc(alias = "g_inet_address_new_from_bytes_with_ipv6_info")]
47+
#[doc(alias = "new_from_bytes_with_ipv6_info")]
48+
pub fn from_bytes_with_ipv6_info(
49+
inet_address_bytes: InetAddressBytes,
50+
flowinfo: u32,
51+
scope_id: u32,
52+
) -> InetAddress {
53+
let bytes = inet_address_bytes.deref();
54+
55+
let family = match inet_address_bytes {
56+
InetAddressBytes::V4(_) => SocketFamily::Ipv4,
57+
InetAddressBytes::V6(_) => SocketFamily::Ipv6,
58+
};
59+
unsafe {
60+
from_glib_full(ffi::g_inet_address_new_from_bytes_with_ipv6_info(
61+
bytes.to_glib_none().0,
62+
family.into_glib(),
63+
flowinfo,
64+
scope_id,
65+
))
66+
}
67+
}
4368
}
4469

4570
pub trait InetAddressExtManual: IsA<InetAddress> + 'static {

0 commit comments

Comments
 (0)