Skip to content

Commit 5e7661c

Browse files
authored
Merge pull request #898 from pbor/proxy-strv
gio: use StrV for the simple proxy resolver API
2 parents e616855 + 801cd17 commit 5e7661c

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

gio/Gir.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,10 @@ manual_traits = ["TlsConnectionExtManual"]
13801380
name = "get_channel_binding_data"
13811381
# Gir confuses the mutability of the data
13821382
manual = true
1383+
[[object.function]]
1384+
name = "set_advertised_protocols"
1385+
# Use strv
1386+
manual = true
13831387

13841388
[[object]]
13851389
name = "Gio.TlsError"

gio/src/auto/tls_connection.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ pub trait TlsConnectionExt: 'static {
102102
io_priority: glib::Priority,
103103
) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>;
104104

105-
#[cfg(any(feature = "v2_60", feature = "dox"))]
106-
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
107-
#[doc(alias = "g_tls_connection_set_advertised_protocols")]
108-
fn set_advertised_protocols(&self, protocols: &[&str]);
109-
110105
#[doc(alias = "g_tls_connection_set_certificate")]
111106
fn set_certificate(&self, certificate: &impl IsA<TlsCertificate>);
112107

@@ -369,17 +364,6 @@ impl<O: IsA<TlsConnection>> TlsConnectionExt for O {
369364
))
370365
}
371366

372-
#[cfg(any(feature = "v2_60", feature = "dox"))]
373-
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
374-
fn set_advertised_protocols(&self, protocols: &[&str]) {
375-
unsafe {
376-
ffi::g_tls_connection_set_advertised_protocols(
377-
self.as_ref().to_glib_none().0,
378-
protocols.to_glib_none().0,
379-
);
380-
}
381-
}
382-
383367
fn set_certificate(&self, certificate: &impl IsA<TlsCertificate>) {
384368
unsafe {
385369
ffi::g_tls_connection_set_certificate(

gio/src/simple_proxy_resolver.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use glib::{prelude::*, translate::*};
3+
use glib::{prelude::*, translate::*, IntoStrV};
44

55
use crate::{ProxyResolver, SimpleProxyResolver};
66

77
impl SimpleProxyResolver {
88
#[doc(alias = "g_simple_proxy_resolver_new")]
99
#[allow(clippy::new_ret_no_self)]
10-
pub fn new(default_proxy: Option<&str>, ignore_hosts: &[&str]) -> ProxyResolver {
10+
pub fn new(default_proxy: Option<&str>, ignore_hosts: impl IntoStrV) -> ProxyResolver {
1111
unsafe {
12-
from_glib_full(ffi::g_simple_proxy_resolver_new(
13-
default_proxy.to_glib_none().0,
14-
ignore_hosts.to_glib_none().0,
15-
))
12+
ignore_hosts.run_with_strv(|ignore_hosts| {
13+
from_glib_full(ffi::g_simple_proxy_resolver_new(
14+
default_proxy.to_glib_none().0,
15+
ignore_hosts.as_ptr() as *mut _,
16+
))
17+
})
1618
}
1719
}
1820
}
1921

2022
pub trait SimpleProxyResolverExtManual: 'static {
2123
#[doc(alias = "g_simple_proxy_resolver_set_ignore_hosts")]
22-
fn set_ignore_hosts(&self, ignore_hosts: &[&str]);
24+
fn set_ignore_hosts(&self, ignore_hosts: impl IntoStrV);
2325
}
2426

2527
impl<O: IsA<SimpleProxyResolver>> SimpleProxyResolverExtManual for O {
26-
fn set_ignore_hosts(&self, ignore_hosts: &[&str]) {
28+
fn set_ignore_hosts(&self, ignore_hosts: impl IntoStrV) {
2729
unsafe {
28-
ffi::g_simple_proxy_resolver_set_ignore_hosts(
29-
self.as_ref().to_glib_none().0,
30-
ignore_hosts.to_glib_none().0,
31-
);
30+
ignore_hosts.run_with_strv(|ignore_hosts| {
31+
ffi::g_simple_proxy_resolver_set_ignore_hosts(
32+
self.as_ref().to_glib_none().0,
33+
ignore_hosts.as_ptr() as *mut _,
34+
);
35+
})
3236
}
3337
}
3438
}

gio/src/tls_connection.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ptr;
55

66
use glib::prelude::*;
77
#[cfg(any(feature = "v2_66", feature = "dox"))]
8-
use glib::translate::*;
8+
use glib::{translate::*, IntoStrV};
99

1010
#[cfg(any(feature = "v2_66", feature = "dox"))]
1111
use crate::TlsChannelBindingType;
@@ -20,6 +20,11 @@ pub trait TlsConnectionExtManual {
2020
&self,
2121
type_: TlsChannelBindingType,
2222
) -> Result<glib::ByteArray, glib::Error>;
23+
24+
#[cfg(any(feature = "v2_60", feature = "dox"))]
25+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
26+
#[doc(alias = "g_tls_connection_set_advertised_protocols")]
27+
fn set_advertised_protocols(&self, protocols: impl IntoStrV);
2328
}
2429

2530
impl<O: IsA<TlsConnection>> TlsConnectionExtManual for O {
@@ -45,4 +50,17 @@ impl<O: IsA<TlsConnection>> TlsConnectionExtManual for O {
4550
}
4651
}
4752
}
53+
54+
#[cfg(any(feature = "v2_60", feature = "dox"))]
55+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
56+
fn set_advertised_protocols(&self, protocols: impl IntoStrV) {
57+
unsafe {
58+
protocols.run_with_strv(|protocols| {
59+
ffi::g_tls_connection_set_advertised_protocols(
60+
self.as_ref().to_glib_none().0,
61+
protocols.as_ptr() as *mut _,
62+
);
63+
})
64+
}
65+
}
4866
}

0 commit comments

Comments
 (0)