Skip to content

Commit 543bc2f

Browse files
authored
Merge pull request #822 from jf2048/socket-ctrl
gio: socket/stream extras
2 parents b7f6937 + c63f07c commit 543bc2f

19 files changed

+2010
-104
lines changed

gio/Gir.toml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ generate = [
9191
"Gio.OutputStreamSpliceFlags",
9292
"Gio.PasswordSave",
9393
"Gio.Permission",
94+
"Gio.PollableReturn",
9495
"Gio.PropertyAction",
9596
"Gio.Proxy",
9697
"Gio.ProxyResolver",
@@ -151,8 +152,10 @@ ignore = [
151152
manual = [
152153
"Gio.ActionEntry",
153154
"Gio.FileAttributeInfo",
155+
"Gio.InputMessage",
154156
"Gio.IOExtension",
155157
"Gio.IOExtensionPoint",
158+
"Gio.OutputMessage",
156159
"Gio.Task",
157160
"GLib.ByteArray",
158161
"GLib.Bytes",
@@ -448,6 +451,31 @@ status = "generate"
448451
name = "win32_pid"
449452
version = "2.72"
450453

454+
[[object]]
455+
name = "Gio.DatagramBased"
456+
status = "generate"
457+
manual_traits = ["DatagramBasedExtManual"]
458+
[[object.function]]
459+
name = "condition_wait"
460+
# needs Duration
461+
manual = true
462+
doc_trait_name = "DatagramBasedExtManual"
463+
[[object.function]]
464+
name = "create_source"
465+
# manual source implementation
466+
manual = true
467+
doc_trait_name = "DatagramBasedExtManual"
468+
[[object.function]]
469+
name = "receive_messages"
470+
# InputMessage is not a gtype
471+
manual = true
472+
doc_trait_name = "DatagramBasedExtManual"
473+
[[object.function]]
474+
name = "send_messages"
475+
# OutputMessage is not a gtype
476+
manual = true
477+
doc_trait_name = "DatagramBasedExtManual"
478+
451479
[[object]]
452480
name = "Gio.DataInputStream"
453481
manual_traits = ["DataInputStreamExtManual"]
@@ -497,7 +525,6 @@ generate_builder = true
497525
#finish functions not needed
498526
manual = true
499527

500-
501528
[[object]]
502529
name = "Gio.DataOutputStream"
503530
status = "generate"
@@ -1019,6 +1046,11 @@ manual_traits = ["OutputStreamExtManual"]
10191046
# special return value
10201047
manual = true
10211048
doc_trait_name = "OutputStreamExtManual"
1049+
[[object.function]]
1050+
pattern = "writev.*"
1051+
# OutputVector
1052+
manual = true
1053+
doc_trait_name = "OutputStreamExtManual"
10221054

10231055
[[object]]
10241056
name = "Gio.PollableInputStream"
@@ -1044,6 +1076,11 @@ manual_traits = ["PollableOutputStreamExtManual"]
10441076
# manual source implementation
10451077
manual = true
10461078
doc_trait_name = "PollableOutputStreamExtManual"
1079+
[[object.function]]
1080+
name = "writev_nonblocking"
1081+
# OutputVector
1082+
manual = true
1083+
doc_trait_name = "PollableOutputStreamExtManual"
10471084

10481085
[[object]]
10491086
name = "Gio.PowerProfileMonitor"
@@ -1187,6 +1224,22 @@ status = "generate"
11871224
[object.function.return]
11881225
nullable = true
11891226

1227+
[[object]]
1228+
name = "Gio.SocketControlMessage"
1229+
status = "generate"
1230+
manual_traits = ["SocketControlMessageExtManual"]
1231+
[[object.function]]
1232+
name = "deserialize"
1233+
# NULL indicates deserialization failure
1234+
# Glib MR: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3099
1235+
[object.function.return]
1236+
nullable = true
1237+
[[object.function]]
1238+
name = "serialize"
1239+
# writes to a void pointer
1240+
manual = true
1241+
doc_trait_name = "SocketControlMessageExtManual"
1242+
11901243
[[object]]
11911244
name = "Gio.Subprocess"
11921245
status = "generate"
@@ -1317,6 +1370,11 @@ status = "generate"
13171370
name = "set_value"
13181371
ignore = true
13191372

1373+
[[object]]
1374+
name = "Gio.UnixCredentialsMessage"
1375+
status = "generate"
1376+
cfg_condition = "unix"
1377+
13201378
[[object]]
13211379
name = "Gio.UnixFDList"
13221380
status = "generate"
@@ -1351,6 +1409,22 @@ manual_traits = ["UnixFDListExtManual"]
13511409
manual = true
13521410
doc_trait_name = "UnixFDListExtManual"
13531411

1412+
[[object]]
1413+
name = "Gio.UnixFDMessage"
1414+
status = "generate"
1415+
cfg_condition = "unix"
1416+
manual_traits = ["UnixFDMessageExtManual"]
1417+
[[object.function]]
1418+
name = "append_fd"
1419+
# has to use RawFd
1420+
manual = true
1421+
doc_trait_name = "UnixFDMessageExtManual"
1422+
[[object.function]]
1423+
name = "steal_fds"
1424+
# has to use RawFd
1425+
manual = true
1426+
doc_trait_name = "UnixFDMessageExtManual"
1427+
13541428
[[object]]
13551429
name = "Gio.UnixInputStream"
13561430
status = "generate"

gio/src/auto/datagram_based.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
5+
use glib::object::IsA;
6+
use glib::translate::*;
7+
use std::fmt;
8+
9+
glib::wrapper! {
10+
#[doc(alias = "GDatagramBased")]
11+
pub struct DatagramBased(Interface<ffi::GDatagramBased, ffi::GDatagramBasedInterface>);
12+
13+
match fn {
14+
type_ => || ffi::g_datagram_based_get_type(),
15+
}
16+
}
17+
18+
impl DatagramBased {
19+
pub const NONE: Option<&'static DatagramBased> = None;
20+
}
21+
22+
pub trait DatagramBasedExt: 'static {
23+
#[doc(alias = "g_datagram_based_condition_check")]
24+
fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition;
25+
}
26+
27+
impl<O: IsA<DatagramBased>> DatagramBasedExt for O {
28+
fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition {
29+
unsafe {
30+
from_glib(ffi::g_datagram_based_condition_check(
31+
self.as_ref().to_glib_none().0,
32+
condition.into_glib(),
33+
))
34+
}
35+
}
36+
}
37+
38+
impl fmt::Display for DatagramBased {
39+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
40+
f.write_str("DatagramBased")
41+
}
42+
}

gio/src/auto/enums.rs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,118 @@ impl From<PasswordSave> for glib::Value {
24092409
}
24102410
}
24112411

2412+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2413+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2414+
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
2415+
#[non_exhaustive]
2416+
#[doc(alias = "GPollableReturn")]
2417+
pub enum PollableReturn {
2418+
#[doc(alias = "G_POLLABLE_RETURN_FAILED")]
2419+
Failed,
2420+
#[doc(alias = "G_POLLABLE_RETURN_OK")]
2421+
Ok,
2422+
#[doc(alias = "G_POLLABLE_RETURN_WOULD_BLOCK")]
2423+
WouldBlock,
2424+
#[doc(hidden)]
2425+
__Unknown(i32),
2426+
}
2427+
2428+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2429+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2430+
impl fmt::Display for PollableReturn {
2431+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2432+
write!(
2433+
f,
2434+
"PollableReturn::{}",
2435+
match *self {
2436+
Self::Failed => "Failed",
2437+
Self::Ok => "Ok",
2438+
Self::WouldBlock => "WouldBlock",
2439+
_ => "Unknown",
2440+
}
2441+
)
2442+
}
2443+
}
2444+
2445+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2446+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2447+
#[doc(hidden)]
2448+
impl IntoGlib for PollableReturn {
2449+
type GlibType = ffi::GPollableReturn;
2450+
2451+
fn into_glib(self) -> ffi::GPollableReturn {
2452+
match self {
2453+
Self::Failed => ffi::G_POLLABLE_RETURN_FAILED,
2454+
Self::Ok => ffi::G_POLLABLE_RETURN_OK,
2455+
Self::WouldBlock => ffi::G_POLLABLE_RETURN_WOULD_BLOCK,
2456+
Self::__Unknown(value) => value,
2457+
}
2458+
}
2459+
}
2460+
2461+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2462+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2463+
#[doc(hidden)]
2464+
impl FromGlib<ffi::GPollableReturn> for PollableReturn {
2465+
unsafe fn from_glib(value: ffi::GPollableReturn) -> Self {
2466+
match value {
2467+
ffi::G_POLLABLE_RETURN_FAILED => Self::Failed,
2468+
ffi::G_POLLABLE_RETURN_OK => Self::Ok,
2469+
ffi::G_POLLABLE_RETURN_WOULD_BLOCK => Self::WouldBlock,
2470+
value => Self::__Unknown(value),
2471+
}
2472+
}
2473+
}
2474+
2475+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2476+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2477+
impl StaticType for PollableReturn {
2478+
fn static_type() -> Type {
2479+
unsafe { from_glib(ffi::g_pollable_return_get_type()) }
2480+
}
2481+
}
2482+
2483+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2484+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2485+
impl glib::value::ValueType for PollableReturn {
2486+
type Type = Self;
2487+
}
2488+
2489+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2490+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2491+
unsafe impl<'a> FromValue<'a> for PollableReturn {
2492+
type Checker = glib::value::GenericValueTypeChecker<Self>;
2493+
2494+
unsafe fn from_value(value: &'a glib::Value) -> Self {
2495+
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
2496+
}
2497+
}
2498+
2499+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2500+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2501+
impl ToValue for PollableReturn {
2502+
fn to_value(&self) -> glib::Value {
2503+
let mut value = glib::Value::for_value_type::<Self>();
2504+
unsafe {
2505+
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
2506+
}
2507+
value
2508+
}
2509+
2510+
fn value_type(&self) -> glib::Type {
2511+
Self::static_type()
2512+
}
2513+
}
2514+
2515+
#[cfg(any(feature = "v2_60", feature = "dox"))]
2516+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
2517+
impl From<PollableReturn> for glib::Value {
2518+
#[inline]
2519+
fn from(v: PollableReturn) -> Self {
2520+
ToValue::to_value(&v)
2521+
}
2522+
}
2523+
24122524
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
24132525
#[non_exhaustive]
24142526
#[doc(alias = "GResolverError")]

gio/src/auto/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ pub use self::data_input_stream::DataInputStream;
9898
mod data_output_stream;
9999
pub use self::data_output_stream::DataOutputStream;
100100

101+
mod datagram_based;
102+
pub use self::datagram_based::DatagramBased;
103+
101104
#[cfg(any(feature = "v2_72", feature = "dox"))]
102105
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_72")))]
103106
mod debug_controller;
@@ -316,6 +319,9 @@ pub use self::socket_connectable::SocketConnectable;
316319
mod socket_connection;
317320
pub use self::socket_connection::SocketConnection;
318321

322+
mod socket_control_message;
323+
pub use self::socket_control_message::SocketControlMessage;
324+
319325
mod socket_listener;
320326
pub use self::socket_listener::SocketListener;
321327

@@ -364,13 +370,27 @@ pub use self::tls_password::TlsPassword;
364370
mod tls_server_connection;
365371
pub use self::tls_server_connection::TlsServerConnection;
366372

373+
#[cfg(any(unix, feature = "dox"))]
374+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
375+
mod unix_credentials_message;
376+
#[cfg(any(unix, feature = "dox"))]
377+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
378+
pub use self::unix_credentials_message::UnixCredentialsMessage;
379+
367380
#[cfg(any(unix, feature = "dox"))]
368381
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
369382
mod unix_fd_list;
370383
#[cfg(any(unix, feature = "dox"))]
371384
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
372385
pub use self::unix_fd_list::UnixFDList;
373386

387+
#[cfg(any(unix, feature = "dox"))]
388+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
389+
mod unix_fd_message;
390+
#[cfg(any(unix, feature = "dox"))]
391+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
392+
pub use self::unix_fd_message::UnixFDMessage;
393+
374394
#[cfg(any(unix, feature = "dox"))]
375395
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
376396
mod unix_input_stream;
@@ -483,6 +503,9 @@ pub use self::enums::MountOperationResult;
483503
pub use self::enums::NetworkConnectivity;
484504
pub use self::enums::NotificationPriority;
485505
pub use self::enums::PasswordSave;
506+
#[cfg(any(feature = "v2_60", feature = "dox"))]
507+
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
508+
pub use self::enums::PollableReturn;
486509
pub use self::enums::ResolverError;
487510
pub use self::enums::ResolverRecordType;
488511
pub use self::enums::ResourceError;
@@ -704,6 +727,7 @@ pub mod traits {
704727
pub use super::converter_output_stream::ConverterOutputStreamExt;
705728
pub use super::data_input_stream::DataInputStreamExt;
706729
pub use super::data_output_stream::DataOutputStreamExt;
730+
pub use super::datagram_based::DatagramBasedExt;
707731
pub use super::dbus_interface::DBusInterfaceExt;
708732
pub use super::dbus_interface_skeleton::DBusInterfaceSkeletonExt;
709733
pub use super::dbus_object::DBusObjectExt;
@@ -768,6 +792,7 @@ pub mod traits {
768792
pub use super::socket_client::SocketClientExt;
769793
pub use super::socket_connectable::SocketConnectableExt;
770794
pub use super::socket_connection::SocketConnectionExt;
795+
pub use super::socket_control_message::SocketControlMessageExt;
771796
pub use super::socket_listener::SocketListenerExt;
772797
pub use super::socket_service::SocketServiceExt;
773798
pub use super::tcp_connection::TcpConnectionExt;
@@ -783,9 +808,15 @@ pub mod traits {
783808
pub use super::tls_server_connection::TlsServerConnectionExt;
784809
#[cfg(any(unix, feature = "dox"))]
785810
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
811+
pub use super::unix_credentials_message::UnixCredentialsMessageExt;
812+
#[cfg(any(unix, feature = "dox"))]
813+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
786814
pub use super::unix_fd_list::UnixFDListExt;
787815
#[cfg(any(unix, feature = "dox"))]
788816
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
817+
pub use super::unix_fd_message::UnixFDMessageExt;
818+
#[cfg(any(unix, feature = "dox"))]
819+
#[cfg_attr(feature = "dox", doc(cfg(unix)))]
789820
pub use super::unix_input_stream::UnixInputStreamExt;
790821
#[cfg(any(unix, feature = "dox"))]
791822
#[cfg_attr(feature = "dox", doc(cfg(unix)))]

0 commit comments

Comments
 (0)