Skip to content

Commit

Permalink
Merge pull request #1429 from sdroege/gio-win32-streams-traits
Browse files Browse the repository at this point in the history
gio: Properly export Win32InputStream / Win32OutputStream traits
  • Loading branch information
sdroege authored Jun 8, 2024
2 parents 7cd0642 + 388f2a6 commit 0a0d316
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 41 deletions.
4 changes: 2 additions & 2 deletions gio/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1653,10 +1653,10 @@ status = "generate"
name = "Gio.Win32InputStream"
status = "manual"
cfg_condition = "windows"
manual_traits = ["Win32InputStreamExtManual"]
manual_traits = ["Win32InputStreamExt"]

[[object]]
name = "Gio.Win32OutputStream"
status = "manual"
cfg_condition = "windows"
manual_traits = ["Win32OutputStreamExtManual"]
manual_traits = ["Win32OutputStreamExt"]
8 changes: 4 additions & 4 deletions gio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ pub use crate::write_output_stream::WriteOutputStream;
mod dbus_proxy;
mod tls_connection;

#[cfg(target_family = "windows")]
#[cfg(windows)]
mod win32_input_stream;
#[cfg(target_family = "windows")]
#[cfg(windows)]
pub use self::win32_input_stream::Win32InputStream;

#[cfg(target_family = "windows")]
#[cfg(windows)]
mod win32_output_stream;
#[cfg(target_family = "windows")]
#[cfg(windows)]
pub use self::win32_output_stream::Win32OutputStream;
4 changes: 4 additions & 0 deletions gio/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ pub use crate::unix_input_stream::UnixInputStreamExtManual;
pub use crate::unix_output_stream::UnixOutputStreamExtManual;
#[cfg(unix)]
pub use crate::unix_socket_address::{UnixSocketAddressExtManual, UnixSocketAddressPath};
#[cfg(windows)]
pub use crate::win32_input_stream::Win32InputStreamExt;
#[cfg(windows)]
pub use crate::win32_output_stream::Win32OutputStreamExt;
pub use crate::{
action_map::ActionMapExtManual, application::ApplicationExtManual, auto::traits::*,
cancellable::CancellableExtManual, converter::ConverterExtManual,
Expand Down
5 changes: 4 additions & 1 deletion gio/src/subprocess_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use std::os::unix::io::IntoRawFd;
#[cfg(unix)]
use glib::translate::*;

use crate::{ffi, SubprocessLauncher};
#[cfg(unix)]
use crate::ffi;

use crate::SubprocessLauncher;

#[cfg(all(docsrs, not(unix)))]
pub trait IntoRawFd: Sized {
Expand Down
30 changes: 12 additions & 18 deletions gio/src/win32_input_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ glib::wrapper! {
}
}

pub trait Win32InputStreamExt: 'static {
#[doc(alias = "g_win32_input_stream_get_close_handle")]
#[doc(alias = "get_close_handle")]
fn closes_handle(&self) -> bool;
}

impl<O: IsA<Win32InputStream>> Win32InputStreamExt for O {
fn closes_handle(&self) -> bool {
unsafe {
from_glib(ffi::g_win32_input_stream_get_close_handle(
self.as_ref().to_glib_none().0,
))
}
}
}

impl Win32InputStream {
pub const NONE: Option<&'static Win32InputStream> = None;

Expand Down Expand Up @@ -73,7 +57,17 @@ mod sealed {
impl<T: super::IsA<super::Win32InputStream>> Sealed for T {}
}

pub trait Win32InputStreamExtManual: sealed::Sealed + IsA<Win32InputStream> + Sized {
pub trait Win32InputStreamExt: sealed::Sealed + IsA<Win32InputStream> + Sized {
#[doc(alias = "g_win32_input_stream_get_close_handle")]
#[doc(alias = "get_close_handle")]
fn closes_handle(&self) -> bool {
unsafe {
from_glib(ffi::g_win32_input_stream_get_close_handle(
self.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "g_win32_input_stream_get_handle")]
#[doc(alias = "get_handle")]
fn handle<T: FromRawHandle>(&self) -> T {
Expand All @@ -99,4 +93,4 @@ pub trait Win32InputStreamExtManual: sealed::Sealed + IsA<Win32InputStream> + Si
}
}

impl<O: IsA<Win32InputStream>> Win32InputStreamExtManual for O {}
impl<O: IsA<Win32InputStream>> Win32InputStreamExt for O {}
28 changes: 12 additions & 16 deletions gio/src/win32_output_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ glib::wrapper! {
}
}

pub trait Win32OutputStreamExt: IsA<Win32OutputStream> + 'static {
#[doc(alias = "g_win32_output_stream_get_close_handle")]
#[doc(alias = "get_close_handle")]
fn closes_handle(&self) -> bool {
unsafe {
from_glib(ffi::g_win32_output_stream_get_close_handle(
self.as_ref().to_glib_none().0,
))
}
}
}

impl<O: IsA<Win32OutputStream>> Win32OutputStreamExt for O {}

impl Win32OutputStream {
pub const NONE: Option<&'static Win32OutputStream> = None;

Expand Down Expand Up @@ -71,7 +57,17 @@ mod sealed {
impl<T: super::IsA<super::Win32OutputStream>> Sealed for T {}
}

pub trait Win32OutputStreamExtManual: sealed::Sealed + IsA<Win32OutputStream> + Sized {
pub trait Win32OutputStreamExt: sealed::Sealed + IsA<Win32OutputStream> + Sized {
#[doc(alias = "g_win32_output_stream_get_close_handle")]
#[doc(alias = "get_close_handle")]
fn closes_handle(&self) -> bool {
unsafe {
from_glib(ffi::g_win32_output_stream_get_close_handle(
self.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "g_win32_output_stream_get_handle")]
#[doc(alias = "get_handle")]
fn handle<T: FromRawHandle>(&self) -> T {
Expand All @@ -97,4 +93,4 @@ pub trait Win32OutputStreamExtManual: sealed::Sealed + IsA<Win32OutputStream> +
}
}

impl<O: IsA<Win32OutputStream>> Win32OutputStreamExtManual for O {}
impl<O: IsA<Win32OutputStream>> Win32OutputStreamExt for O {}

0 comments on commit 0a0d316

Please sign in to comment.